Labsco
loonghao logo

WeCom Bot MCP Server

β˜… 96

from loonghao

An MCP server for sending messages to WeCom (WeChat Work) bots.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

MseeP.ai Security Assessment Badge

WeCom Bot MCP Server

<div align="center"> <img src="wecom.png" alt="WeCom Bot Logo" width="200"/> </div>

A Model Context Protocol (MCP) compliant server implementation for WeCom (WeChat Work) bot.

PyPI version Python Version codecov Code style: ruff smithery badge

English | δΈ­ζ–‡

<a href="https://glama.ai/mcp/servers/amr2j23lbk"><img width="380" height="200" src="https://glama.ai/mcp/servers/amr2j23lbk/badge" alt="WeCom Bot Server MCP server" /></a>

Features

  • Support for multiple message types:
    • Markdown messages (with @mentions and font colors)
    • Markdown V2 messages (with tables, lists, embedded images)
    • Image messages (base64/local file/URL)
    • File messages
    • Template card messages (text_notice and news_notice)
  • Multi-bot support: Configure and use multiple WeCom bots
  • @mention support (via user ID or phone number)
  • Message history tracking
  • Configurable logging system
  • Full type annotations
  • Pydantic-based data validation

Development

Setup Development Environment

  1. Clone the repository:
Copy & paste β€” that's it
git clone https://github.com/loonghao/wecom-bot-mcp-server.git
cd wecom-bot-mcp-server
  1. Create a virtual environment and install dependencies:
Copy & paste β€” that's it
# Using uv (recommended)
pip install uv
uv venv
uv pip install -e ".[dev]"

# Or using traditional method
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e ".[dev]"

Testing

Copy & paste β€” that's it
# Run all tests with coverage
uvx nox -s pytest

# Run import tests only
uvx nox -s test_imports

# Run specific test file
uvx nox -s pytest -- tests/test_message.py

# Run tests with verbose output
uvx nox -s pytest -- -v

Code Style

Copy & paste β€” that's it
# Check code
uvx nox -s lint

# Automatically fix code style issues
uvx nox -s lint_fix

Building and Publishing

Copy & paste β€” that's it
# Build the package
uvx nox -s build

# Publish to PyPI (requires authentication)
uvx nox -s publish

Continuous Integration

The project uses GitHub Actions for CI/CD:

  • MR Checks: Runs on all pull requests, tests on Ubuntu, Windows, and macOS with Python 3.10, 3.11, and 3.12
  • Code Coverage: Uploads coverage reports to Codecov
  • Import Tests: Ensures the package can be imported correctly after installation

All dependencies are automatically tested during CI to catch issues early.

Project Structure

Copy & paste β€” that's it
wecom-bot-mcp-server/
β”œβ”€β”€ src/
β”‚   └── wecom_bot_mcp_server/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ __main__.py
β”‚       β”œβ”€β”€ __version__.py
β”‚       β”œβ”€β”€ app.py           # FastMCP application setup
β”‚       β”œβ”€β”€ server.py        # Server entry point
β”‚       β”œβ”€β”€ message.py       # Message and template card handling
β”‚       β”œβ”€β”€ file.py          # File upload handling
β”‚       β”œβ”€β”€ image.py         # Image upload handling
β”‚       β”œβ”€β”€ bot_config.py    # Multi-bot configuration
β”‚       β”œβ”€β”€ utils.py         # Utility functions
β”‚       β”œβ”€β”€ log_config.py    # Logging configuration
β”‚       └── errors.py        # Error definitions
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_server.py
β”‚   β”œβ”€β”€ test_message.py
β”‚   β”œβ”€β”€ test_file.py
β”‚   β”œβ”€β”€ test_image.py
β”‚   └── test_bot_config.py
β”œβ”€β”€ docs/
β”œβ”€β”€ pyproject.toml
β”œβ”€β”€ noxfile.py
└── README.md

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact