Cover image
Try Now
2025-04-10

Eine Python -Server -Implementierung für Wecom (WeChat Work) Bot, die dem Modellkontextprotokoll (MCP) folgt. Dieser Server bietet eine standardisierte Schnittstelle zum Umgang mit automatisierten Messaging und kontextbezogenen Interaktionen in Enterprise Wechat-Umgebungen.

3 years

Works with Finder

1

Github Watches

5

Github Forks

24

Github Stars

WeCom Bot MCP Server

WeCom Bot Logo

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

PyPI version Python Version codecov Code style: ruff smithery badge

English | 中文

WeCom Bot Server MCP server

Features

  • Support for multiple message types:
    • Text messages
    • Markdown messages
    • Image messages (base64)
    • File messages
  • @mention support (via user ID or phone number)
  • Message history tracking
  • Configurable logging system
  • Full type annotations
  • Pydantic-based data validation

Requirements

  • Python 3.10+
  • WeCom Bot Webhook URL (obtained from WeCom group settings)

Installation

There are several ways to install WeCom Bot MCP Server:

1. Automated Installation (Recommended)

Using Smithery (For Claude Desktop):

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

Using VSCode with Cline Extension:

  1. Install Cline Extension from VSCode marketplace
  2. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
  3. Search for "Cline: Install Package"
  4. Type "wecom-bot-mcp-server" and press Enter

2. Manual Installation

Install from PyPI:

pip install wecom-bot-mcp-server

Configure MCP manually:

Create or update your MCP configuration file:

// For Windsurf: ~/.windsurf/config.json
{
  "mcpServers": {
    "wecom": {
      "command": "uvx",
      "args": [
        "wecom-bot-mcp-server"
      ],
      "env": {
        "WECOM_WEBHOOK_URL": "your-webhook-url"
      }
    }
  }
}

Configuration

Setting Environment Variables

# Windows PowerShell
$env:WECOM_WEBHOOK_URL = "your-webhook-url"

# Optional configurations
$env:MCP_LOG_LEVEL = "DEBUG"  # Log levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
$env:MCP_LOG_FILE = "path/to/custom/log/file.log"  # Custom log file path

Log Management

The logging system uses platformdirs.user_log_dir() for cross-platform log file management:

  • Windows: C:\Users\<username>\AppData\Local\hal\wecom-bot-mcp-server
  • Linux: ~/.local/share/hal/wecom-bot-mcp-server
  • macOS: ~/Library/Application Support/hal/wecom-bot-mcp-server

The log file is named mcp_wecom.log and is stored in the above directory.

Usage

Starting the Server

wecom-bot-mcp-server

Usage Examples (With MCP)

# Scenario 1: Send weather information to WeCom
USER: "How's the weather in Shenzhen today? Send it to WeCom"
ASSISTANT: "I'll check Shenzhen's weather and send it to WeCom"

await mcp.send_message(
    content="Shenzhen Weather:\n- Temperature: 25°C\n- Weather: Sunny\n- Air Quality: Good",
    msg_type="markdown"
)

# Scenario 2: Send meeting reminder and @mention relevant people
USER: "Send a reminder for the 3 PM project review meeting, remind Zhang San and Li Si to attend"
ASSISTANT: "I'll send the meeting reminder"

await mcp.send_message(
    content="## Project Review Meeting Reminder\n\nTime: Today 3:00 PM\nLocation: Meeting Room A\n\nPlease be on time!",
    msg_type="markdown",
    mentioned_list=["zhangsan", "lisi"]
)

# Scenario 3: Send a file
USER: "Send this weekly report to the WeCom group"
ASSISTANT: "I'll send the weekly report"

await mcp.send_message(
    content=Path("weekly_report.docx"),
    msg_type="file"
)

Direct API Usage

Send Messages

from wecom_bot_mcp_server import mcp

# Send markdown message
await mcp.send_message(
    content="**Hello World!**", 
    msg_type="markdown"
)

# Send text message and mention users
await mcp.send_message(
    content="Hello @user1 @user2",
    msg_type="text",
    mentioned_list=["user1", "user2"]
)

Send Files

from wecom_bot_mcp_server import send_wecom_file

# Send file
await send_wecom_file("/path/to/file.txt")

Send Images

from wecom_bot_mcp_server import send_wecom_image

# Send local image
await send_wecom_image("/path/to/image.png")

# Send URL image
await send_wecom_image("https://example.com/image.png")

Development

Setup Development Environment

  1. Clone the repository:
git clone https://github.com/loonghao/wecom-bot-mcp-server.git
cd wecom-bot-mcp-server
  1. Create a virtual environment and install dependencies:
# 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

# Using uv (recommended)
uvx nox -s pytest

# Or using traditional method
nox -s pytest

Code Style

# Check code
uvx nox -s lint

# Automatically fix code style issues
uvx nox -s lint_fix

Building and Publishing

# Build the package
uv build

# Build and publish to PyPI
uv build && twine upload dist/*

Project Structure

wecom-bot-mcp-server/
├── src/
│   └── wecom_bot_mcp_server/
│       ├── __init__.py
│       ├── server.py
│       ├── message.py
│       ├── file.py
│       ├── image.py
│       ├── utils.py
│       └── errors.py
├── tests/
│   ├── test_server.py
│   ├── test_message.py
│   ├── test_file.py
│   └── test_image.py
├── docs/
├── pyproject.toml
├── noxfile.py
└── README.md

License

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

Contact

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Khalid kalib
  • Write professional emails

  • https://tovuti.be
  • Oede knorrepot die vasthoudt an de goeie ouwe tied van 't boerenleven

  • ANGEL LEON
  • A world class elite tech co-founder entrepreneur, expert in software development, entrepreneurship, marketing, coaching style leadership and aligned with ambition for excellence, global market penetration and worldy perspectives.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Gil kaminski
  • Make sure you are post-ready before you post on social media

  • INFOLAB OPERATIONS 2
  • A medical specialist offering assistance grounded in clinical guidelines. Disclaimer: This is intended for research and is NOT safe for clinical use!

  • apappascs
  • Entdecken Sie die umfassendste und aktuellste Sammlung von MCP-Servern auf dem Markt. Dieses Repository dient als zentraler Hub und bietet einen umfangreichen Katalog von Open-Source- und Proprietary MCP-Servern mit Funktionen, Dokumentationslinks und Mitwirkenden.

  • OffchainLabs
  • GO -Umsetzung des Ethereum -Beweises des Anteils

  • huahuayu
  • Ein einheitliches API-Gateway zur Integration mehrerer Ethercan-ähnlicher Blockchain-Explorer-APIs mit Modellkontextprotokoll (MCP) für AI-Assistenten.

  • deemkeen
  • Steuern Sie Ihren MBOT2 mit einer Power Combo: MQTT+MCP+LLM

  • zhaoyunxing92
  • 本项目是一个钉钉 MCP (Message Connector Protocol )服务 , 提供了与钉钉企业应用交互的 api 接口。项目基于 Go 语言开发 , 支持员工信息查询和消息发送等功能。

  • pontusab
  • Die Cursor & Windsurf -Community finden Regeln und MCPs

    Reviews

    1 (1)
    Avatar
    user_MiYDlrql
    2025-04-16

    I've been using the wecom-bot-mcp-server by loonghao and it's been fantastic! The setup was seamless, and the integration with our existing systems was smooth. The documentation on GitHub is clear and comprehensive, making it easy to get started. It's incredibly versatile and has significantly improved our workflow. Highly recommend checking it out!