feat: add Weibo channel via mcp-server-weibo (#107)

Adds WeiboChannel integrating qinyuanpei/mcp-server-weibo (34+ stars,
MIT, 10 tools) via mcporter. Addresses #75.

Files changed (3 files, +57 lines):
- agent_reach/channels/weibo.py — new channel (54 lines)
- agent_reach/channels/__init__.py — register WeiboChannel
- tests/test_channel_contracts.py — add weibo URL sample

Co-authored-by: AICodeLion <AICodeLion@users.noreply.github.com>
This commit is contained in:
AICodeLion
2026-03-08 21:54:35 +08:00
committed by GitHub
parent 3a3d38acce
commit db20c5d5d3
3 changed files with 57 additions and 0 deletions
+2
View File
@@ -20,6 +20,7 @@ from .douyin import DouyinChannel
from .linkedin import LinkedInChannel from .linkedin import LinkedInChannel
from .bosszhipin import BossZhipinChannel from .bosszhipin import BossZhipinChannel
from .wechat import WeChatChannel from .wechat import WeChatChannel
from .weibo import WeiboChannel
# Channel registry # Channel registry
@@ -34,6 +35,7 @@ ALL_CHANNELS: List[Channel] = [
LinkedInChannel(), LinkedInChannel(),
BossZhipinChannel(), BossZhipinChannel(),
WeChatChannel(), WeChatChannel(),
WeiboChannel(),
RSSChannel(), RSSChannel(),
ExaSearchChannel(), ExaSearchChannel(),
WebChannel(), WebChannel(),
+54
View File
@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
"""Weibo (微博) — check if mcporter + mcp-server-weibo is available."""
import shutil
import subprocess
from .base import Channel
class WeiboChannel(Channel):
name = "weibo"
description = "微博动态与热搜"
backends = ["mcp-server-weibo"]
tier = 1
def can_handle(self, url: str) -> bool:
from urllib.parse import urlparse
d = urlparse(url).netloc.lower()
return "weibo.com" in d or "weibo.cn" in d
def check(self, config=None):
mcporter = shutil.which("mcporter")
if not mcporter:
return "off", (
"需要 mcporter + mcp-server-weibo。安装步骤:\n"
" 1. npm install -g mcporter\n"
" 2. uvx mcp-server-weibo(或 pip install mcp-server-weibo\n"
" 3. mcporter config add weibo --command 'uvx mcp-server-weibo'\n"
" 详见 https://github.com/qinyuanpei/mcp-server-weibo"
)
try:
r = subprocess.run(
[mcporter, "config", "list"], capture_output=True,
encoding="utf-8", errors="replace", timeout=5
)
if "weibo" not in r.stdout:
return "off", (
"mcporter 已装但微博 MCP 未配置。运行:\n"
" uvx mcp-server-weibo # 或 pip install mcp-server-weibo\n"
" mcporter config add weibo --command 'uvx mcp-server-weibo'\n"
" # 海外服务器需配置 WEIBO_COOKIE 环境变量,\n"
" # 详见 SKILL.md 微博章节"
)
except Exception:
return "off", "mcporter 连接异常"
try:
r = subprocess.run(
[mcporter, "list", "weibo"], capture_output=True,
encoding="utf-8", errors="replace", timeout=15
)
if r.returncode == 0 and "search_users" in r.stdout:
return "ok", "完整可用(热搜、搜索、用户动态、评论)"
return "warn", "MCP 已配置但工具加载失败,检查 mcp-server-weibo 版本"
except Exception:
return "warn", "MCP 连接异常,检查 mcp-server-weibo 是否可用"
+1
View File
@@ -116,6 +116,7 @@ def test_channel_can_handle_contract():
"douyin": "https://www.douyin.com/video/123", "douyin": "https://www.douyin.com/video/123",
"linkedin": "https://www.linkedin.com/in/test", "linkedin": "https://www.linkedin.com/in/test",
"bosszhipin": "https://www.zhipin.com/web/geek/job?query=python", "bosszhipin": "https://www.zhipin.com/web/geek/job?query=python",
"weibo": "https://weibo.com/u/1749127163",
"rss": "https://example.com/feed.xml", "rss": "https://example.com/feed.xml",
"exa_search": "https://example.com", "exa_search": "https://example.com",
"web": "https://example.com", "web": "https://example.com",