Sponsored by Deepsite.site

MCP Server WeChat

Created By
panxingfeng8 months ago
基于MCP技术,操作微信发送消息和获取历史记录
Content

MCP Server WeChat

基于MCP技术的微信聊天记录获取和消息发送功能的服务器,使用pywechat工具实现微信自动化操作。

功能特点

此服务器提供以下主要功能:

  • 获取微信聊天记录(指定日期)
  • 发送单条消息给单个好友
  • 发送多条消息给单个好友
  • 发送消息给多个好友

可用工具

  • wechat_get_chat_history - 获取特定日期的微信聊天记录

    • 必需参数:
      • to_user (string): 好友或群聊备注或昵称
      • target_date (string): 目标日期,格式为YY/M/D,如25/3/22 -> 暂时不要跨度过长,初始目的就是为了当日的聊天记录
  • wechat_send_message - 向单个微信好友发送单条消息

    • 必需参数:
      • to_user (string): 好友或群聊备注或昵称
      • message (string): 要发送的消息
  • wechat_send_multiple_messages - 向单个微信好友发送多条消息

    • 必需参数:
      • to_user (string): 好友或群聊备注或昵称
      • messages (array): 要发送的消息列表 (用英文逗号分隔的字符串输入)
  • wechat_send_to_multiple_friends - 向多个微信好友发送单条或者多条消息

    • 必需参数:
      • to_user (array): 好友或群聊备注或昵称列表 (用英文逗号分隔的字符串输入)
      • message (string/array): 要发送的消息 (单条消息会发给所有好友;多条消息用英文逗号分隔且数量与好友数相同时,将分别发送给对应好友)

安装方法

使用 pip 安装

pip install mcp_server_wechat

获取最新
pip install --upgrade mcp_server_wechat

使用示例

配置为 MCP 服务

在您的 MCP 配置中添加:

"mcpServers": {
  "wechat": {
    "command": "python",
    "args": ["-m", "mcp_server_wechat","--folder-path=存放历史记录的目录"]
  }
}

调用示例

  1. 获取聊天记录:
{
  "name": "wechat_get_chat_history",
  "arguments": {
    "to_user": "张三",
    "target_date": "25/3/22"
  }
}
  1. 发送单条消息:
{
  "name": "wechat_send_message",
  "arguments": {
    "to_user": "张三",
    "message": "你好,这是一条测试消息"
  }
}
  1. 发送多条消息:
{
  "name": "wechat_send_multiple_messages",
  "arguments": {
    "to_user": "张三",
    "messages": "你好","这是第一条消息","这是第二条消息"
  }
}
  1. 发送给多个好友(单条消息):
{
  "name": "wechat_send_to_multiple_friends",
  "arguments": {
    "to_user": ["张三", "李四", "王五"],
    "message": "大家好,这是一条群发消息"或者"你好,张三","你好,李四","你好,王五"
  }
}

调试

您可以使用 MCP inspector 来调试服务器:

npx @modelcontextprotocol/inspector python -m mcp_server_wechat

实际效果展示


inspector的测试

基于我自己chat_mcp的测试

注意事项

  • 使用本工具需要保持微信桌面版处于登录状态
  • 获取聊天记录和发送消息需要确保微信窗口能够被正常操作
  • 在使用过程中,请勿手动操作微信窗口,以免干扰自动化操作
  • 请勿使用此工具进行任何违反微信服务协议的行为

许可证

mcp_server_wechat 使用 MIT 许可证。这意味着您可以自由使用、修改和分发此软件,但需遵守 MIT 许可证的条款和条件。详情请参阅项目仓库中的 LICENSE 文件。

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Serper MCP ServerA Serper MCP Server
Amap Maps高德地图官方 MCP Server
Tavily Mcp
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
WindsurfThe new purpose-built IDE to harness magic
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Playwright McpPlaywright MCP server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
DeepChatYour AI Partner on Desktop
CursorThe AI Code Editor
ChatWiseThe second fastest AI chatbot™