tc6-01/weixin-mcp
If you are the rightful owner of weixin-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This is a Go-based reimplementation of the WeChat Official Account Model Context Protocol (MCP) server, developed using the mark3labs/mcp-go framework.
WeChat_get_access_token
Retrieve the WeChat official account access token.
WeChat_create_draft
Create a draft for a WeChat article.
WeChat_publish_draft
Publish a draft to the WeChat official account.
WeChat_del_draft
Delete an unpublished draft.
WeChat_del_material
Delete permanent materials.
微信公众号 MCP 服务器 (Go 版本)
这是基于 Go 语言重新实现的微信公众号 Model Context Protocol (MCP) 服务器,使用 mark3labs/mcp-go 框架开发。
✨ 特性
- 🚀 高性能: Go 语言实现,启动速度快,内存占用低
- 📦 容器化: 完整的 Docker 支持,一键部署
- 🔧 简单部署: 单二进制文件,无依赖
- 🛡️ 类型安全: 编译时错误检查
- 🔄 完全兼容: 与 Python 版本 API 完全兼容
- 📊 结构化日志: 便于调试和监控
📋 功能列表
支持5个核心的微信公众号管理工具:
- WeChat_get_access_token - 获取微信公众号 access_token
- WeChat_create_draft - 创建图文消息草稿
- WeChat_publish_draft - 发布草稿到公众号
- WeChat_del_draft - 删除未发布的草稿
- WeChat_del_material - 删除永久素材
🚀 快速开始
方式一:使用 Docker (推荐)
# 1. 构建并运行
make docker-run
# 2. 查看日志
docker logs wechat-oa-mcp-server
方式二:本地构建
# 1. 安装依赖
make deps
# 2. 构建
make build
# 3. 运行
make run
🐳 Docker 使用
构建镜像
docker build -t wechat-oa-mcp-go:latest .
运行容器
docker run -it --name wechat-oa-mcp-server wechat-oa-mcp-go:latest
使用 docker-compose
# 启动服务
docker-compose up -d
# 查看日志
docker-compose logs -f
# 停止服务
docker-compose down
🎛️ 在 Cursor 中配置
将以下配置添加到 Cursor 的 MCP 设置中:
{
"mcpServers": {
"wechat-oa-mcp-go": {
"command": "/path/to/wechat-oa-mcp-go/bin/wechat-oa-mcp",
"env": {
"LOG_LEVEL": "info"
}
}
}
}
或者使用 Docker 方式:
{
"mcpServers": {
"wechat-oa-mcp-go": {
"command": "docker",
"args": ["run", "-i", "--rm", "wechat-oa-mcp-go:latest"]
}
}
}
🔧 开发说明
项目结构
wechat-oa-mcp-go/
├── cmd/main.go # 主程序入口
├── internal/handlers/ # MCP 工具处理器
├── pkg/wechat/ # 微信 API 客户端
├── Dockerfile # 容器构建文件
├── Makefile # 构建脚本
├── go.mod # Go 模块依赖
└── README.md # 本文档
添加新工具
- 在
pkg/wechat/
中添加 API 客户端函数 - 在
internal/handlers/
中实现 MCP 工具处理器 - 在
cmd/main.go
中注册新工具
构建命令
# 查看所有可用命令
make help
# 构建二进制文件
make build
# 运行测试
make test
# 清理构建文件
make clean
# 下载依赖
make deps
# Docker 相关
make docker-build # 构建镜像
make docker-run # 运行容器
make docker-clean # 清理容器和镜像
🌟 性能优势
相比 Python 版本:
- 启动速度: 快 20-30 倍
- 内存占用: 减少 60-70%
- 响应时间: 快 2-4 倍
- 部署简单: 单文件二进制,无运行时依赖
�� API 兼容性
Go 版本完全兼容 Python 版本的 API:
- 相同的工具名称和参数
- 相同的响应格式
- 相同的错误处理方式
可以无缝替换现有的 Python 实现。
🔍 调试和日志
服务器启动时会在 stderr 输出详细的日志信息,包括:
- 工具注册状态
- 请求处理过程
- 错误信息和调用堆栈
设置环境变量 LOG_LEVEL=debug
可以获得更详细的调试信息。
📄 许可证
本项目基于与原 Python 版本相同的许可证。
�� 贡献
欢迎提交 Issue 和 Pull Request!
📞 支持
如有问题,请查看:
IMPLEMENTATION.md
- 详细的实现说明README-GO.md
- Go 版本专用文档