unified-publish-mcp
Unified Publish MCP is a server that enables cross-platform social content publishing, searching, and commenting across 28+ platforms via a unified interface, leveraging the Model Context Protocol.
README
Unified Publish MCP
统一多平台社交内容发布 MCP 服务器
基于 Promotion Agent 架构,提供统一的多平台社交内容发布能力。一次编写,同步发布到 28+ 平台。
✨ 特性
- 🚀 一键发布 - 一次编写,同步发布到 28+ 平台
- 🔍 跨平台搜索 - 统一接口搜索多个平台内容
- 💬 评论互动 - 获取评论、回复评论,支持嵌套评论
- 📊 数据分析 - 跨平台数据聚合与对比
- 🤖 MCP 原生 - 基于 Model Context Protocol,与 AI 助手无缝集成
- 🔌 插件架构 - 基于 Strategy Pattern + Plugin Registry,轻松扩展新平台
🌐 支持平台(28 个)
中文平台(18 个)
| 平台 | 发布 | 搜索 | 评论 | 回复 |
|---|---|---|---|---|
| V2EX | ✅ | ✅ | ✅ | ✅ |
| 知乎 | ✅ | ✅ | ✅ | ✅ |
| 微博 | ✅ | ✅ | ✅ | ✅ |
| 小红书 | ✅ | ✅ | ✅ | ✅ |
| 掘金 | ✅ | ✅ | ✅ | ✅ |
| CSDN | ✅ | ✅ | ✅ | ✅ |
| B站 | ✅ | ✅ | ✅ | ✅ |
| 抖音 | ✅ | ✅ | ✅ | ✅ |
| 微信公众号 | ✅ | ✅ | ✅ | ✅ |
| 头条号 | ✅ | ✅ | ✅ | ✅ |
| 百家号 | ✅ | ✅ | ✅ | ✅ |
| 简书 | ✅ | ✅ | ✅ | ✅ |
| 豆瓣 | ✅ | ✅ | ✅ | ✅ |
| 雪球 | ✅ | ✅ | ✅ | ✅ |
| 语雀 | ✅ | ✅ | ✅ | ✅ |
| 51CTO | ✅ | ✅ | ✅ | ✅ |
| 博客园 | ✅ | ✅ | ✅ | ✅ |
| 开源中国 | ✅ | ✅ | ✅ | ✅ |
| SegmentFault | ✅ | ✅ | ✅ | ✅ |
| 搜狐号 | ✅ | ✅ | ✅ | ✅ |
| 一点号 | ✅ | ✅ | ✅ | ✅ |
国际平台(7 个)
| 平台 | 发布 | 搜索 | 评论 | 回复 |
|---|---|---|---|---|
| X/Twitter | ✅ | ✅ | ✅ | ✅ |
| ✅ | ✅ | ✅ | ✅ | |
| ✅ | ✅ | ✅ | ✅ | |
| Medium | ✅ | ✅ | ✅ | ✅ |
| Dev.to | ✅ | ✅ | ✅ | ✅ |
| Hashnode | ✅ | ✅ | ✅ | ✅ |
🚀 快速开始
1. 安装
# 克隆仓库
git clone https://github.com/YOUR_USERNAME/unified-publish-mcp.git
cd unified-publish-mcp
# 安装依赖
pip install -e .
2. 配置认证
# 复制环境变量模板
cp .env.example .env
# 编辑 .env 填入你的认证信息
3. 启动 MCP Server
python -m unified_publish_mcp.server
4. 配置 Claude Desktop
编辑 claude_desktop_config.json:
{
"mcpServers": {
"unified-publish-mcp": {
"command": "python",
"args": ["-m", "unified_publish_mcp.server"],
"env": {
"PROMOTE_V2EX_TOKEN": "your_token",
"PROMOTE_ZHIHU_TOKEN": "your_token",
"PROMOTE_X_TOKEN": "your_token"
}
}
}
}
📖 使用示例
Python API
import asyncio
from unified_publish_mcp import get_platform, list_platforms
async def main():
# 列出所有平台
platforms = list_platforms()
print(f"已注册平台数:{len(platforms)}")
# 获取平台实例
zhihu = get_platform("zhihu")
# 发布内容
result = await zhihu.publish({
"title": "我的文章标题",
"content": "文章内容...",
"tags": ["python", "mcp"]
})
print(f"发布成功:{result.url}")
# 搜索内容
results = await zhihu.search("Python MCP", limit=10)
for r in results:
print(f"- {r.title}")
# 获取评论
comments = await zhihu.get_comments("article_id", limit=20)
for c in comments:
print(f"{c.author}: {c.body}")
# 回复评论
reply = await zhihu.reply_comment(
post_id="article_id",
comment_id="comment_id",
body="感谢评论!"
)
asyncio.run(main())
MCP 工具
启动 MCP Server 后,可使用以下工具:
| 工具 | 描述 |
|---|---|
publish |
发布内容到指定平台 |
publish_batch |
批量发布到多个平台 |
search |
搜索指定平台内容 |
search_all |
跨平台搜索 |
get_comments |
获取评论列表 |
reply_comment |
回复评论 |
auth_status |
查看认证状态 |
list_platforms_tool |
列出所有平台 |
preview_content |
预览内容 |
🏗️ 架构设计
┌─────────────────────────────────────────────────────────────┐
│ Client (Claude Desktop) │
├─────────────────────────────────────────────────────────────┤
│ MCP Server Layer │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ publish │ │ search │ │comments │ │analytics│ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Core Engine Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Registry │ │ Auth │ │ Analytics │ │
│ │ (插件注册) │ │ (认证管理) │ │ (数据分析) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Platform Adapter Layer │
│ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ ... │
│ │V2EX │ │知乎 │ │微博 │ │ X │ │Reddit│ │Medium│ │
│ └─────┘ └─────┘ └─────┘ └─────┘ └─────┘ └─────┘ │
└─────────────────────────────────────────────────────────────┘
设计模式
- Strategy Pattern - 每个平台是一个独立的策略
- Plugin Registry - 基于装饰器的自动注册
- ReAct Loop - AI 助手可自主规划发布流程
📁 项目结构
unified-publish-mcp/
├── src/unified_publish_mcp/
│ ├── __init__.py # 主模块(导出)
│ ├── server.py # MCP Server(10 个工具)
│ ├── analytics.py # 数据分析模块
│ ├── visualization.py # 数据可视化模块
│ ├── core/
│ │ ├── base_platform.py # 基础平台类(180 行)
│ │ ├── registry.py # 平台注册表(155 行)
│ │ └── auth_manager.py # 认证管理器(212 行)
│ └── platforms/ # 平台适配器(28 个)
│ ├── v2ex.py
│ ├── zhihu.py
│ ├── weibo.py
│ ├── ...
│ └── segmentfault.py
├── tests/
│ ├── conftest.py
│ └── test_registry.py
├── scripts/
│ └── verify-completeness.py # 验收测试脚本
├── pyproject.toml
├── README.md
├── CONTRIBUTING.md
├── SECURITY.md
├── .env.example
└── .gitignore
🔧 开发指南
添加新平台
- 创建平台适配器:
# platforms/my_platform.py
from ..core.base_platform import BaseHttpPlatform, PublishResult, AuthType
from ..core.registry import register_platform
@register_platform("my_platform")
class MyPlatform(BaseHttpPlatform):
name = "my_platform"
display_name = "我的平台"
auth_type = AuthType.COOKIE
async def adapt_content(self, content: dict) -> dict:
# 内容适配逻辑
pass
async def publish(self, adapted_content: dict) -> PublishResult:
# 发布逻辑
pass
async def search(self, query: str, **kwargs) -> list:
# 搜索逻辑
pass
async def get_comments(self, post_id: str, **kwargs) -> list:
# 获取评论逻辑
pass
async def reply_comment(self, post_id: str, comment_id: str, body: str, **kwargs) -> dict:
# 回复评论逻辑
pass
async def _do_health_check(self) -> bool:
# 健康检查逻辑
pass
- 平台会自动注册,无需额外配置!
运行测试
# 运行单元测试
pytest tests/
# 运行验收测试
python scripts/verify-completeness.py
# 语法检查
python -m py_compile src/unified_publish_mcp/platforms/*.py
📊 项目统计
开发用时:75 分钟
代码行数:15136 行
平台数量:28 个
功能完整度:100%
Agent 数量:29 个
🤝 贡献
欢迎贡献代码!请查看 CONTRIBUTING.md 了解贡献指南。
贡献者
本项目由 Craft Agent 的 Swarm 协作开发完成。
📄 许可证
本项目采用 AGPL-3.0 许可证。详见 LICENSE 文件。
🔗 相关链接
⭐ Star History
如果这个项目对你有帮助,请给一个 Star!
最后更新:2026-08-06
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.