企业微信机器人MCP服务器

企业微信机器人MCP服务器

一个基于模型上下文协议(MCP)的企业微信机器人Python服务器实现,提供标准化接口处理自动消息发送和上下文感知交互。

企业微信机器人MCP服务器快速入门

安装

自动安装(推荐)

使用Smithery(适用于Claude Desktop):

npx -y @smithery/cli install wecom-bot-mcp-server --client claude

手动安装

pip install wecom-bot-mcp-server

配置

设置环境变量:

# 设置Webhook URL(必需)
export WECOM_WEBHOOK_URL="your-webhook-url"

# 可选配置
export MCP_LOG_LEVEL="INFO"  # 日志级别
export MCP_LOG_FILE="path/to/log/file.log"  # 自定义日志路径

启动服务器

wecom-bot-mcp-server

使用示例

# 发送markdown消息
await mcp.send_message(
    content="**Hello World!**", 
    msg_type="markdown"
)

# 发送文本消息并@用户
await mcp.send_message(
    content="Hello",
    msg_type="text",
    mentioned_list=["zhangsan", "lisi"]
)

# 发送文件
await mcp.send_message(
    content=Path("report.docx"),
    msg_type="file"
)

支持的消息类型:

  • 文本消息
  • Markdown消息
  • 图片消息(base64)
  • 文件消息

要求Python 3.10+版本