微信消息发送MCP服务
这是一个基于 MCP (Model Context Protocol) 的微信消息自动化发送服务,通过命令行参数可以灵活配置服务器运行模式和日志级别。
快速开始 - 使用UVX配置MCP服务(推荐)
UVX提供跨平台的服务管理能力,支持Windows、macOS和Linux。
配置文件示例
{
"mcpServers": {
"wechat": {
"command": "uvx",
"args": [
"xmcp-server-wxauto"
],
"env": {}
}
}
}
本地测试运行MCP服务
本步骤主要用于在Windows系统上本地测试微信自动化MCP服务。
环境准备
# 安装服务包
pip install xmcp-server-wxauto
启动服务
# 方式1:以默认配置启动服务(stdio模式)
xmcp-server-wxauto
# 方式2:指定日志级别和网络传输方式
xmcp-server-wxauto --log-level=INFO --transport=sse --port=8000
配置MCP客户端
将以下配置添加到你的AI智能体配置文件中:
{
"mcpServers": {
"wechat": {
"url": "http://localhost:8000/sse"
}
}
}
使用示例
向智能体发送指令:
将"会议通知"发送到"技术部群聊"
服务将模拟人工操作微信客户端完成消息发送。
重要说明: 本服务通过模拟人工操作微信客户端实现功能,不依赖微信官方API,需要预先登录微信PC客户端。
命令行参数
日志级别 (--log-level)
设置服务器的日志输出级别:
| 级别 | 描述 |
|---|---|
DEBUG |
详细的调试信息,用于开发和问题排查 |
INFO |
正常运行的关键信息 |
WARNING |
潜在问题的警告信息 |
ERROR |
功能异常的错误信息 |
CRITICAL |
导致服务崩溃的严重错误 |
默认值:ERROR
示例:
xmcp-server-wxauto --log-level=DEBUG
传输方式 (--transport)
设置服务器与客户端之间的通信协议:
| 模式 | 适用场景 | 特点 |
|---|---|---|
stdio |
进程间本地通信 | 无日志输出,性能最优 |
sse |
跨网络远程通信 | 支持实时双向通信,需指定端口 |
默认值:stdio
示例:
# 启用网络通信模式
xmcp-server-wxauto --transport=sse --port=8080
服务器端口 (--port)
当使用 sse 传输模式时,指定服务器监听的端口号。
默认值:8000
示例:
xmcp-server-wxauto --transport=sse --port=8000
完整示例
1. 开发调试模式
# 启用详细日志和网络访问
xmcp-server-wxauto --log-level=DEBUG --transport=sse --port=8000
2. 生产环境模式
# 静默运行,通过UVX管理
uvx run xmcp-server-wxauto --transport=stdio
常见问题解答
1. 为什么 stdio 模式下看不到日志?
stdio 模式使用标准输入输出流进行通信,日志输出会干扰通信协议,因此默认禁用控制台日志。如需查看日志,请使用 sse 模式并设置 --log-level 参数。
2. 如何在后台运行服务器?
Windows
# 使用PowerShell后台作业
Start-Job -ScriptBlock { xmcp-server-wxauto --transport=sse --port=8000 }
Linux/macOS
- 注意:由于Mac系统不支持用wxauto操作微信,所以本功能仅支持Windows系统。
3. 端口被占用怎么办?
# 查找占用端口的进程
lsof -i:8000
# 终止进程(替换<PID>为实际进程ID)
kill -9 <PID>
# 或使用其他端口
xmcp-server-wxauto --transport=sse --port=8081
4. 服务无法连接微信客户端?
- 确保微信PC客户端已登录且处于前台可见状态
- 检查服务日志中是否有权限错误提示
- 暂时关闭安全软件或防火墙
# 以管理员权限运行PowerShell(Windows)
Start-Process powershell -Verb RunAs
# 或调整防火墙规则(Linux)
sudo ufw allow 8000/tcp
5. 如何查看服务状态?
# 查看服务版本
xmcp-server-wxauto --version
# 查看实时运行状态(sse模式)
curl http://localhost:8000/status
技术支持
- 提交问题:项目GitHub Issues
- 联系邮箱:samt007@qq.com
- 工作时间:周一至周日 8:00-22:00 (GMT+8)
Metadata
Release files for xmcp-server-wxauto 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xmcp_server_wxauto-0.1.4.tar.gz | 29.4 kB | Without provenance | Details for xmcp_server_wxauto-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xmcp_server_wxauto-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for xmcp_server_wxauto-0.1.4-py3-none-any.whl |
Total release size: 34.6 kB
Release files / xmcp_server_wxauto-0.1.4.tar.gz
| Download URL | xmcp_server_wxauto-0.1.4.tar.gz |
|---|---|
| Size | 29.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dcb308d57b0d51f47acc79d8a74919ed1606d9313d1fa4242cba7472a70dc068
|
|
BLAKE2b-256 checksum How to use checksums |
33164369f8e668d9c806a8eb4a35d2b2857ac1cb5b7c9d914938a27814663ef0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.12
|
Release files / xmcp_server_wxauto-0.1.4-py3-none-any.whl
| Download URL | xmcp_server_wxauto-0.1.4-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
feee8d6ce1dc3fd0cb7111f2d45c135e88250f718d765471bd8a4d6014c6c77f
|
|
BLAKE2b-256 checksum How to use checksums |
990e5fe934ae8403ab27949eaeb26ce7308fc5098d4937188534a4e14b071025
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.12
|
Security for xmcp-server-wxauto 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.