Get real-time B站热榜数据 using bilibili-mcp MCP tool with easy setup and fast API access
The bilibili-mcp tool serves as an MCP (Model Context Protocol) server, designed to provide real-time access to hot video data from Bilibili's API. Built with FastMCP and leveraging Bilibili’s public APIs, this server can be registered with various AI applications through the Cursor or other MCP clients. It delivers valuable insights directly into your AI workflows, making it an indispensable resource for developers integrating AI tools.
The bilibili-mcp tool is equipped with several key features that align perfectly with Model Context Protocol requirements:
GET Popular Video: Exposing a get_popular function to fetch the top-billed videos on Bilibili. This allows AI applications to seamlessly access trending content without worrying about API handling.
import mcp
# Registering the tool with FastMCP
@mcp.tool(name="get_popular")
def get_popular(top_k: int = 3):
"""
Fetches popular video data from Bilibili.
Arguments:
top_k (int): The number of top videos to retrieve. Maximum limit is 10.
Returns:
List[dict]: A list containing dictionary objects representing the selected videos. Each object includes attributes like 'title', 'view', and 'like'.
"""
# Fetch data from Bilibili API
popular_videos = fetch_bilibili_api()
return popular_videos[:top_k]
MCP Server Registration: The bilibili-mcp automatically registers as a standard MCP tool, ready to be discovered by any compatible MCP client.
The server leverages the httpx library for asynchronous requests and integrates with FastMCP to ensure seamless communication with AI applications. This setup is designed to handle real-time data fetching efficiently while maintaining compatibility across different environments.
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph TD;
A[API Request] --> B[MCP Server];
B --> C[Database/Cache];
C --> D[Data Source];
D --> E[Video Data Collection];
E --> F[API Response];
F --> G[MCP Client];
To set up and run the bilibili-mcp server, follow these steps:
Ensure Python version ≥ 3.12 is installed.
Install the required dependencies:
pip install httpx "mcp[cli]>=1.6.0"
Define your project structure with a main code file named bilibili_mcp.py along with necessary configuration files.
Run the server using the following command:
uv tool run bilibili-mcp
Alternatively, you can use a JSON configuration to start the tool automatically when running via an MCP client like Cursor:
"bilibili-mcp": {
"command": "uv",
"args": [
"tool",
"run",
"bilibili-mcp"
]
}
The bilibili-mcp server is ideal for integrating real-time video information into various AI workflows, such as:
The server is compatible with a range of MCP clients, including but not limited to:
get_popular tool.table
| MCP Client | Resources | Tools | Prompts |
|------------|-----------|-------|---------|
| Claude Desktop | ✅ | ✅ | ✅ | Full Support |
| Continue | ✅ | ✅ | ✅ | Full Support |
| Cursor | ❌ | ✅ | ❌ | Tools Only |
For advanced users, here are some configuration options:
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
Ensure to secure your environment variables and API keys for production environments.
Q: How can I integrate the bilibili-mcp server with my AI application?
get_popular tool provided by FastMCP to access Bilibili hot video data. Register your tool and start fetching real-time video information.Q: Is there any limitation on the use of this server?
Q: Can I change the User-Agent string?
User-Agent in your environment variables or configuration files as needed.Q: What kind of data is returned by the get_popular method?
Q: Are there any performance guarantees provided by this setup?
Contributions are welcome! Here’s how you can help:
Please follow standard Pull Request guidelines for detailed instructions.
The bilibili-mcp server stands as a robust solution for AI applications looking to integrate real-time video data from Bilibili. By supporting MCP standards and delivering efficient, scalable access to trending content, this tool can significantly enhance the capabilities of your AI workflows.
By understanding how bilibili-mcp fits into the broader MCP ecosystem, developers can leverage its functionalities with confidence, ensuring seamless integration across various platforms and applications.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration