A Model Context Protocol (MCP) server that enables AI assistants to send messages, images, and files to WeCom (Enterprise WeChat) through webhook URLs.
- Send Messages: Send text or markdown formatted messages to WeCom groups
- Send Images: Upload and send images from local files or URLs
- Send Files: Upload and send various file types to WeCom
- Mention Users: Support for mentioning specific users by ID or mobile number
- Error Handling: Comprehensive error handling with detailed error codes
- Environment-based Configuration: Secure webhook URL management through environment variables
- Node.js 18+
- A WeCom webhook URL (obtain from your WeCom group settings)
- Open WeCom (Enterprise WeChat)
- Go to the group where you want to receive messages
- Click on group settings (⚙️)
- Select "Group Bots" or "群机器人"
- Add a new bot and copy the webhook URL
The webhook URL format: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY
Add this server to your MCP settings configuration file with your webhook URL:
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"wecom": {
"command": "npx",
"args": ["wecom-mcp"],
"env": {
"WECOM_WEBHOOK_URL": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY"
}
}
}
}Edit %APPDATA%/Claude/claude_desktop_config.json:
{
"mcpServers": {
"wecom": {
"command": "npx",
"args": ["wecom-mcp"],
"env": {
"WECOM_WEBHOOK_URL": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY"
}
}
}
}Use the following configuration:
{
"command": "npx",
"args": ["wecom-mcp"],
"env": {
"WECOM_WEBHOOK_URL": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY"
}
}The server requires the following environment variable:
WECOM_WEBHOOK_URL(required): Your WeCom webhook URL
Send text or markdown messages to WeCom.
Parameters:
content(required): Message contentmsg_type(optional): Message type - "text" or "markdown" (default: "markdown")mentioned_list(optional): Array of user IDs to mentionmentioned_mobile_list(optional): Array of mobile numbers to mention
Example:
{
"name": "send_message",
"arguments": {
"content": "🚀 Deployment completed successfully!",
"msg_type": "markdown"
}
}Send images to WeCom.
Parameters:
image_path(required): Local file path or URL to the image
Example:
{
"name": "send_wecom_image",
"arguments": {
"image_path": "/path/to/image.png"
}
}Send files to WeCom.
Parameters:
file_path(required): Local file path
Example:
{
"name": "send_wecom_file",
"arguments": {
"file_path": "/path/to/document.pdf"
}
}Once configured, you can ask your AI assistant to:
- "Send a message to my WeCom group saying 'Hello team!'"
- "Upload this image to WeCom" (with image attached)
- "Send this document to my WeCom group"
- "Send a markdown message with status update"
The webhook URL is automatically used from the environment variable, so you don't need to specify it in each request.
The server provides detailed error messages for common issues:
VALIDATION_ERROR: Invalid input parameters or missing environment variablesNETWORK_ERROR: Network connectivity issuesAPI_FAILURE: WeCom API errorsFILE_ERROR: File access or format issues
To run locally for development:
# Clone the repository
git clone <repository-url>
cd wecom-mcp
# Install dependencies
npm install
# Set your webhook URL
export WECOM_WEBHOOK_URL="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY"
# Build the project
npm run build
# Run the server
npm start
# Run tests
node dist/test-client.jsThe project includes a comprehensive test client that validates all functionality:
# Set environment variable and run tests
export WECOM_WEBHOOK_URL="YOUR_WEBHOOK_URL"
npm run build
node dist/test-client.jsThe test client will:
- List available tools
- Send a test message
- Send a test image
- Send a test file
- JPG/JPEG
- PNG
- Size limit: 5 bytes - 2MB
- Any file type supported by WeCom
- Size limit: Up to 20MB
- Store your webhook URL securely as an environment variable
- Never commit webhook URLs to version control
- The webhook URL contains sensitive access keys
ISC
Issues and pull requests are welcome! Please feel free to contribute to improve this MCP server.