Skip to content
Back to search

mcp_server_wechat

基于MCP技术,操作微信发送消息和获取历史记录

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/panxingfeng--mcp-server-wechat/badge.svg)](/listings/panxingfeng--mcp-server-wechat)

HTML

<a href="/listings/panxingfeng--mcp-server-wechat"><img src="/api/listings/panxingfeng--mcp-server-wechat/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 179 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # MCP Server WeChat
  2. 基于MCP技术的微信聊天记录获取和消息发送功能的服务器,使用[pywechat](https://github.com/Hello-Mr-Crab/pywechat)工具实现微信自动化操作。
  3. ## 功能特点
  4. 此服务器提供以下主要功能:
  5. - 获取微信聊天记录(指定日期)
  6. - 发送单条消息给单个好友
  7. - 发送多条消息给单个好友
  8. - 发送消息给多个好友
  9. ## 可用工具
  10. - `wechat_get_chat_history` - 获取特定日期的微信聊天记录
  11. - 必需参数:
  12. - `to_user` (string): 好友或群聊备注或昵称
  13. - `target_date` (string): 目标日期,格式为YY/M/D,如25/3/22
  14. - `wechat_send_message` - 向单个微信好友发送单条消息
  15. - 必需参数:
  16. - `to_user` (string): 好友或群聊备注或昵称
  17. - `message` (string): 要发送的消息
  18. - `wechat_send_multiple_messages` - 向单个微信好友发送多条消息
  19. - 必需参数:
  20. - `to_user` (string): 好友或群聊备注或昵称
  21. - `messages` (array): 要发送的消息列表 (用英文逗号分隔的字符串输入)
  22. - `wechat_send_to_multiple_friends` - 向多个微信好友发送单条或者多条消息
  23. - 必需参数:
  24. - `to_user` (array): 好友或群聊备注或昵称列表 (用英文逗号分隔的字符串输入)
  25. - `message` (string/array): 要发送的消息 (单条消息会发给所有好友;多条消息用英文逗号分隔且数量与好友数相同时,将分别发送给对应好友)
  26. ## 安装方法
  27. ### stdio版
  28. ```bash
  29. pip install mcp_server_wechat
  30. 获取最新
  31. pip install --upgrade mcp_server_wechat
  32. ```
  33. ### sse版/Streamable_HTTP版
  34. ```bash
  35. python -m venv venv # 创建虚拟环境
  36. venv/scripts/activate # 激活环境
  37. pip install -r requirements.txt
  38. ```
  39. ## 使用示例
  40. ### 配置为 MCP 服务
  41. 在您的 MCP 配置中添加:
  42. stdio版
  43. ```json
  44. {
  45. "mcpServers": {
  46. "wechat": {
  47. "command": "python",
  48. "args": ["-m", "mcp_server_wechat","--folder-path=存放历史记录的目录"]
  49. }
  50. }
  51. }
  52. ```
  53. sse版
  54. 启动命令
  55. ```bash
  56. python -m mcp_server_wechat_sse --folder-path=x:\xxxxx #默认文件夹可以在代码中修改
  57. ```
  58. ```json
  59. {
  60. "mcpServers": {
  61. "wechat": {
  62. "url": "http://localhost:3000/sse"
  63. }
  64. }
  65. }
  66. ```
  67. Streamable_HTTP版
  68. 启动命令
  69. ```bash
  70. python -m mcp_server_wechat_Streamable_HTTP --folder-path=x:\xxxxx #默认文件夹可以在代码中修改
  71. ```
  72. ```json
  73. {
  74. "mcpServers": {
  75. "wechat": {
  76. "url": "http://localhost:3000/mcp"
  77. }
  78. }
  79. }
  80. ```
  81. ### 调用示例
  82. 1. 获取聊天记录:
  83. ```json
  84. {
  85. "name": "wechat_get_chat_history",
  86. "arguments": {
  87. "to_user": "张三",
  88. "target_date": "25/3/22"
  89. }
  90. }
  91. ```
  92. 2. 发送单条消息:
  93. ```json
  94. {
  95. "name": "wechat_send_message",
  96. "arguments": {
  97. "to_user": "张三",
  98. "message": "你好,这是一条测试消息"
  99. }
  100. }
  101. ```
  102. 3. 发送多条消息:
  103. ```json
  104. {
  105. "name": "wechat_send_multiple_messages",
  106. "arguments": {
  107. "to_user": "张三",
  108. "messages": "你好","这是第一条消息","这是第二条消息"
  109. }
  110. }
  111. ```
  112. 4. 发送给多个好友(单条消息):
  113. ```json
  114. {
  115. "name": "wechat_send_to_multiple_friends",
  116. "arguments": {
  117. "to_user": ["张三", "李四", "王五"],
  118. "message": "大家好,这是一条群发消息"或者"你好,张三","你好,李四","你好,王五"
  119. }
  120. }
  121. ```
  122. ## 调试
  123. 您可以使用 MCP inspector 来调试服务器:
  124. ```bash
  125. npx @modelcontextprotocol/inspector python -m mcp_server_wechat
  126. ```
  127. ## 实际效果展示
  128. <table>
  129. <tr>
  130. <td align="center" width="33%">
  131. <img src="https://raw.githubusercontent.com/panxingfeng/mcp_server_wechat/main/测试.png" width="330" /><br>
  132. <em>inspector的测试</em>
  133. </td>
  134. <td align="center" width="33%">
  135. <img src="https://raw.githubusercontent.com/panxingfeng/mcp_server_wechat/main/多工具测试.gif" width="330" /><br>
  136. <em>基于我自己UI(仿Cherry Studio)</a>的测试</em>
  137. </td>
  138. <td align="center" width="34%">
  139. <img src="https://raw.githubusercontent.com/panxingfeng/mcp_server_wechat/main/Streamable_HTTP_测试.png" width="330" /><br>
  140. <em>基于 Cherry Studio 的Streamable_HTTP</a>的测试</em>
  141. </td>
  142. </tr>
  143. </table>
  144. ## 注意事项
  145. - 使用本工具需要保持微信桌面版处于登录状态
  146. - 获取聊天记录和发送消息需要确保微信窗口能够被正常操作
  147. - 在使用过程中,请勿手动操作微信窗口,以免干扰自动化操作
  148. - 请勿使用此工具进行任何违反微信服务协议的行为
  149. ## 许可证
  150. mcp_server_wechat 使用 MIT 许可证。这意味着您可以自由使用、修改和分发此软件,但需遵守 MIT 许可证的条款和条件。详情请参阅项目仓库中的 LICENSE 文件。

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.