loading…
Search for a command to run...
loading…
MCP server that fetches Weibo hot search trends. Supports Stdio, SSE, and Streamable HTTP.
MCP server that fetches Weibo hot search trends. Supports Stdio, SSE, and Streamable HTTP.
通过获取前 N 条微博热搜的 MCP 服务进行示例,演示基于 fastmcp 构建,内置 Stdio、本地 SSE、Streamable HTTP 三种MCP运行脚本,适配本地和远程多端场景。
git clone https://github.com/bossdong955/mcp-server-example.git
cd weibo-mcp-server
# 创建并进入 Conda 环境
conda create -n mcp-server-example python=3.11
conda activate mcp-server-example
# 安装依赖(注意:请确认本机已卸载旧版 mcp 包)
pip install -r requirements.txt
requirements.txt 默认包含:
| 模式 | 脚本 | 典型场景 | 监听方式 |
|---|---|---|---|
| Stdio | resou_stdio.py |
Claude Desktop / VS Code Cline 本地插件 | 标准输入输出 |
| SSE | resou_sse.py |
部署在服务器,通过 SSE 远程连接 | http://HOST:PORT/sse |
| Streamable HTTP | resou_streamable_http.py |
支持 HTTP 长连接的客户端 | http://HOST:PORT/mcp |
启动任意脚本后都可以调用 hot_search(n=20) 获取热搜,n 为返回条数上限。
python resou_stdio.py
VS Code Cline / Claude Desktop mcpServers 示例(将路径替换成你本机的脚本路径):
{
"mcpServers": {
"weiboresou": {
"command": "conda",
"args": [
"run",
"-n",
"weibo-mcp-server",
"--no-capture-output",
"python",
"E:/your/path/resou_stdio.py"
],
"env": {
"PYTHONUTF8": "1"
}
}
}
}
已在脚本中调用
mcp.run(transport="stdio"),无需再使用mcp run ...。

python resou_sse.py --host 0.0.0.0 --port 8006
在 VS Code Cline -> Remote Servers 中设置:
http://<host>:8006/sseAuthorization 等自定义认证信息(如有需要)
python resou_streamable_http.py --host 0.0.0.0 --port 8005
远程客户端配置示例:
http://<host>:8005/mcpPYTHONUTF8=1。mcp 包,请先卸载 pip uninstall mcp,再安装 fastmcp。hot_search 默认 10s 超时。可在脚本中调整 httpx.AsyncClient 的 timeout 参数。Run in your terminal:
claude mcp add weibo-hot-search-mcp-server -- npx Security
Low riskAutomated heuristic from public metadata — not a security guarantee.