微博/雪球言论观测 MCP Server. 封装 RSSHub 数据获取能力为标准化 MCP tools, 让 AI 客户端直接查询社交媒体帖子、管理监控账号、搜索历史内容.
- 获取微博/雪球用户最新帖子
- 监控账号管理 (增删查)
- 全量轮询所有启用账号
- 帖子搜索与统计
- Cookie 健康检查
- RSSHub 服务状态检查
# 克隆项目
git clone <repo-url> rsshub-mcp
cd rsshub-mcp
# 安装 (推荐在 conda 或 venv 环境中)
pip install -e .
# 开发安装 (含 pytest)
pip install -e ".[dev]"要求 Python >= 3.10.
复制 config.example.yaml 为 config.yaml 并编辑:
cp config.example.yaml config.yaml主要配置项:
rsshub_base_url: "http://localhost:1200"
access_key: "your-access-key-here"
weibo_cookies: ""
xueqiu_cookies: ""
db_path: "data/social_posts.duckdb"
accounts_file: "data/accounts.json"
transport: "stdio"所有配置项支持 RSSHUB_MCP_ 前缀的环境变量:
export RSSHUB_MCP_RSSHUB_BASE_URL="http://localhost:1200"
export RSSHUB_MCP_ACCESS_KEY="your-key"
export RSSHUB_MCP_WEIBO_COOKIES="your-weibo-cookie"
export RSSHUB_MCP_XUEQIU_COOKIES="your-xueqiu-cookie"CLI 参数 > YAML 文件 > 环境变量 > 内置默认值
项目自带 docker-compose.yml, 一键启动 RSSHub + Redis:
# 复制环境变量模板
cp .env.example .env
# 编辑 .env, 填入 ACCESS_KEY 和 Cookie
# 生成随机 ACCESS_KEY: openssl rand -hex 16
# 启动
docker compose up -d
# 验证 RSSHub 可用
curl http://localhost:1200/healthzRSSHub 监听 localhost:1200, Redis 仅内部通信不暴露端口.
详见 COOKIE_GUIDE.md 获取微博/雪球 Cookie.
在 opencode.json 的 mcp 部分添加:
{
"mcp": {
"rsshub": {
"type": "local",
"command": ["python", "-m", "rsshub_mcp", "--transport", "stdio"]
}
}
}如果项目不在 PATH 中, 指定完整路径:
{
"mcp": {
"rsshub": {
"type": "local",
"command": ["python", "-m", "rsshub_mcp", "--transport", "stdio"],
"cwd": "/path/to/rsshub-mcp"
}
}
}在 claude_desktop_config.json 中添加:
{
"mcpServers": {
"rsshub": {
"command": "python",
"args": ["-m", "rsshub_mcp", "--transport", "stdio"],
"cwd": "/path/to/rsshub-mcp"
}
}
}在 Cursor MCP 设置中添加相同的 stdio 配置. 填入 command python, args -m rsshub_mcp --transport stdio, 以及项目 cwd.
共 11 个 MCP tools, 分为四组.
| Tool | 参数 | 说明 |
|---|---|---|
weibo_get_posts |
uid (str, 必填), limit (int, 默认 20) |
获取微博用户最新帖子. uid 为纯数字 UID |
xueqiu_get_posts |
user_id (str, 必填), type (int, 默认 10), limit (int, 默认 20) |
获取雪球用户帖子. type: 0=原创, 2=长文, 4=问答, 9=热门, 11=交易, 10=全部 |
run_poll |
platform (str, 可选) |
全量轮询所有启用账号. platform 可填 "weibo" 或 "xueqiu" 过滤 |
| Tool | 参数 | 说明 |
|---|---|---|
add_account |
platform (str), uid (str), name (str), category (str, 默认 "default") |
添加监控账号. platform 为 "weibo" 或 "xueqiu" |
remove_account |
platform (str), uid (str) |
移除监控账号 |
list_accounts |
platform (str, 可选) |
列出所有监控账号, 可按平台过滤 |
| Tool | 参数 | 说明 |
|---|---|---|
search_posts |
keyword (str, 可选), platform (str, 可选), author (str, 可选), days (int, 默认 7) |
搜索已采集帖子. 支持关键词、平台、作者、时间范围组合过滤 |
get_stats |
无 | 获取采集统计: 总帖数、各平台帖数和最近采集时间 |
| Tool | 参数 | 说明 |
|---|---|---|
check_cookies |
无 | 检查微博/雪球 Cookie 健康状态 (valid/configured/not_set/expired/error) |
extract_uid |
url (str, 必填) |
从微博或雪球 URL 提取用户 UID, 返回平台和 ID |
check_rsshub_health |
无 | 检查 RSSHub 服务是否可用 |
# stdio 模式 (MCP 客户端直连, 默认)
rsshub-mcp --transport stdio
# HTTP 模式 (独立服务)
rsshub-mcp --transport streamable-http --port 8000
# 指定配置文件
rsshub-mcp --config /path/to/config.yaml --transport stdio也可以直接用 Python 模块方式运行:
python -m rsshub_mcp --transport stdiorsshub-mcp/
src/rsshub_mcp/
__main__.py # 入口
server.py # MCP server + 11 tools
config.py # 配置加载
rsshub_client.py # RSSHub HTTP 客户端
parser.py # RSS XML 解析
db.py # DuckDB 存储
account_manager.py # 监控账号管理
cookie_manager.py # Cookie 健康检查
tests/
config.example.yaml
docker-compose.yml
.env.example
COOKIE_GUIDE.md
# 运行测试
pytest -v
# 代码检查
ruff check src/MIT