iflow-mcp_wecom-bot-mcp-server 0.6.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- iflow_mcp_wecom_bot_mcp_server-0.6.16/LICENSE +21 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/PKG-INFO +313 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/README.md +282 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/pyproject.toml +168 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/__init__.py +22 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/__main__.py +7 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/__version__.py +6 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/app.py +14 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/errors.py +30 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/file.py +221 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/image.py +286 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/log_config.py +135 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/message.py +306 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/server.py +33 -0
- iflow_mcp_wecom_bot_mcp_server-0.6.16/src/wecom_bot_mcp_server/utils.py +84 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Hal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: iflow-mcp_wecom-bot-mcp-server
|
|
3
|
+
Version: 0.6.16
|
|
4
|
+
Summary: WeCom Bot MCP Server - A Python server for WeCom (WeChat Work) bot following the Model Context Protocol (MCP)
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Author: longhao
|
|
7
|
+
Author-email: hal.long@outlook.com
|
|
8
|
+
Requires-Python: >=3.10,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Dist: aiohttp (>=3.11.13)
|
|
18
|
+
Requires-Dist: ftfy (>=6.3.1)
|
|
19
|
+
Requires-Dist: httpx (>=0.28.1)
|
|
20
|
+
Requires-Dist: loguru (>=0.7.3)
|
|
21
|
+
Requires-Dist: mcp (>=1.3.0)
|
|
22
|
+
Requires-Dist: notify-bridge (>=0.3.0)
|
|
23
|
+
Requires-Dist: pillow (>=10.2.0)
|
|
24
|
+
Requires-Dist: platformdirs (>=4.2.0)
|
|
25
|
+
Requires-Dist: pydantic (>=2.6.1)
|
|
26
|
+
Requires-Dist: tenacity (>=9.0.0)
|
|
27
|
+
Project-URL: Homepage, https://github.com/loonghao/wecom-bot-mcp-server
|
|
28
|
+
Project-URL: Issues, https://github.com/loonghao/wecom-bot-mcp-server/issues
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
[](https://mseep.ai/app/loonghao-wecom-bot-mcp-server)
|
|
32
|
+
|
|
33
|
+
# WeCom Bot MCP Server
|
|
34
|
+
|
|
35
|
+
<div align="center">
|
|
36
|
+
<img src="wecom.png" alt="WeCom Bot Logo" width="200"/>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
A Model Context Protocol (MCP) compliant server implementation for WeCom (WeChat Work) bot.
|
|
40
|
+
|
|
41
|
+
[](https://badge.fury.io/py/wecom-bot-mcp-server)
|
|
42
|
+
[](https://pypi.org/project/wecom-bot-mcp-server/)
|
|
43
|
+
[](https://app.codecov.io/gh/loonghao/wecom-bot-mcp-server)
|
|
44
|
+
[](https://github.com/astral-sh/ruff)
|
|
45
|
+
[](https://smithery.ai/server/wecom-bot-mcp-server)
|
|
46
|
+
|
|
47
|
+
[English](README.md) | [中文](README_zh.md)
|
|
48
|
+
|
|
49
|
+
<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>
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- Support for multiple message types:
|
|
54
|
+
- Text messages
|
|
55
|
+
- Markdown messages
|
|
56
|
+
- Image messages (base64)
|
|
57
|
+
- File messages
|
|
58
|
+
- @mention support (via user ID or phone number)
|
|
59
|
+
- Message history tracking
|
|
60
|
+
- Configurable logging system
|
|
61
|
+
- Full type annotations
|
|
62
|
+
- Pydantic-based data validation
|
|
63
|
+
|
|
64
|
+
## Requirements
|
|
65
|
+
|
|
66
|
+
- Python 3.10+
|
|
67
|
+
- WeCom Bot Webhook URL (obtained from WeCom group settings)
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
There are several ways to install WeCom Bot MCP Server:
|
|
72
|
+
|
|
73
|
+
### 1. Automated Installation (Recommended)
|
|
74
|
+
|
|
75
|
+
#### Using Smithery (For Claude Desktop):
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npx -y @smithery/cli install wecom-bot-mcp-server --client claude
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Using VSCode with Cline Extension:
|
|
82
|
+
|
|
83
|
+
1. Install [Cline Extension](https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev) from VSCode marketplace
|
|
84
|
+
2. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
|
|
85
|
+
3. Search for "Cline: Install Package"
|
|
86
|
+
4. Type "wecom-bot-mcp-server" and press Enter
|
|
87
|
+
|
|
88
|
+
### 2. Manual Configuration
|
|
89
|
+
|
|
90
|
+
Add the server to your MCP client configuration file:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
// For Claude Desktop on macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
|
|
94
|
+
// For Claude Desktop on Windows: %APPDATA%\Claude\claude_desktop_config.json
|
|
95
|
+
// For Windsurf: ~/.windsurf/config.json
|
|
96
|
+
// For Cline in VSCode: VSCode Settings > Cline > MCP Settings
|
|
97
|
+
{
|
|
98
|
+
"mcpServers": {
|
|
99
|
+
"wecom": {
|
|
100
|
+
"command": "uvx",
|
|
101
|
+
"args": [
|
|
102
|
+
"wecom-bot-mcp-server"
|
|
103
|
+
],
|
|
104
|
+
"env": {
|
|
105
|
+
"WECOM_WEBHOOK_URL": "your-webhook-url"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Configuration
|
|
113
|
+
|
|
114
|
+
### Setting Environment Variables
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Windows PowerShell
|
|
118
|
+
$env:WECOM_WEBHOOK_URL = "your-webhook-url"
|
|
119
|
+
|
|
120
|
+
# Optional configurations
|
|
121
|
+
$env:MCP_LOG_LEVEL = "DEBUG" # Log levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
122
|
+
$env:MCP_LOG_FILE = "path/to/custom/log/file.log" # Custom log file path
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Log Management
|
|
126
|
+
|
|
127
|
+
The logging system uses `platformdirs.user_log_dir()` for cross-platform log file management:
|
|
128
|
+
|
|
129
|
+
- Windows: `C:\Users\<username>\AppData\Local\hal\wecom-bot-mcp-server\Logs`
|
|
130
|
+
- Linux: `~/.local/state/hal/wecom-bot-mcp-server/log`
|
|
131
|
+
- macOS: `~/Library/Logs/hal/wecom-bot-mcp-server`
|
|
132
|
+
|
|
133
|
+
The log file is named `mcp_wecom.log` and is stored in the above directory.
|
|
134
|
+
|
|
135
|
+
You can customize the log level and file path using environment variables:
|
|
136
|
+
- `MCP_LOG_LEVEL`: Set to DEBUG, INFO, WARNING, ERROR, or CRITICAL
|
|
137
|
+
- `MCP_LOG_FILE`: Set to a custom log file path
|
|
138
|
+
|
|
139
|
+
## Usage
|
|
140
|
+
|
|
141
|
+
Once configured, the MCP server runs automatically when your MCP client starts. You can interact with it through natural language in your AI assistant.
|
|
142
|
+
|
|
143
|
+
### Usage Examples
|
|
144
|
+
|
|
145
|
+
**Scenario 1: Send weather information to WeCom**
|
|
146
|
+
```
|
|
147
|
+
USER: "How's the weather in Shenzhen today? Send it to WeCom"
|
|
148
|
+
ASSISTANT: "I'll check Shenzhen's weather and send it to WeCom"
|
|
149
|
+
[The assistant will use the send_message tool to send the weather information]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Scenario 2: Send meeting reminder and @mention relevant people**
|
|
153
|
+
```
|
|
154
|
+
USER: "Send a reminder for the 3 PM project review meeting, remind Zhang San and Li Si to attend"
|
|
155
|
+
ASSISTANT: "I'll send the meeting reminder"
|
|
156
|
+
[The assistant will use the send_message tool with mentioned_list parameter]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Scenario 3: Send a file**
|
|
160
|
+
```
|
|
161
|
+
USER: "Send this weekly report to the WeCom group"
|
|
162
|
+
ASSISTANT: "I'll send the weekly report"
|
|
163
|
+
[The assistant will use the send_file tool]
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Scenario 4: Send an image**
|
|
167
|
+
```
|
|
168
|
+
USER: "Send this chart image to WeCom"
|
|
169
|
+
ASSISTANT: "I'll send the image"
|
|
170
|
+
[The assistant will use the send_image tool]
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Available MCP Tools
|
|
174
|
+
|
|
175
|
+
The server provides the following tools that your AI assistant can use:
|
|
176
|
+
|
|
177
|
+
1. **send_message** - Send text or markdown messages
|
|
178
|
+
- Parameters: `content`, `msg_type` (text/markdown), `mentioned_list`, `mentioned_mobile_list`
|
|
179
|
+
|
|
180
|
+
2. **send_file** - Send files to WeCom
|
|
181
|
+
- Parameters: `file_path`
|
|
182
|
+
|
|
183
|
+
3. **send_image** - Send images to WeCom
|
|
184
|
+
- Parameters: `image_path` (local path or URL)
|
|
185
|
+
|
|
186
|
+
### For Developers: Direct API Usage
|
|
187
|
+
|
|
188
|
+
If you want to use this package directly in your Python code (not as an MCP server):
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
from wecom_bot_mcp_server import send_message, send_wecom_file, send_wecom_image
|
|
192
|
+
|
|
193
|
+
# Send markdown message
|
|
194
|
+
await send_message(
|
|
195
|
+
content="**Hello World!**",
|
|
196
|
+
msg_type="markdown"
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
# Send text message and mention users
|
|
200
|
+
await send_message(
|
|
201
|
+
content="Hello @user1 @user2",
|
|
202
|
+
msg_type="text",
|
|
203
|
+
mentioned_list=["user1", "user2"]
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
# Send file
|
|
207
|
+
await send_wecom_file("/path/to/file.txt")
|
|
208
|
+
|
|
209
|
+
# Send image
|
|
210
|
+
await send_wecom_image("/path/to/image.png")
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Development
|
|
214
|
+
|
|
215
|
+
### Setup Development Environment
|
|
216
|
+
|
|
217
|
+
1. Clone the repository:
|
|
218
|
+
```bash
|
|
219
|
+
git clone https://github.com/loonghao/wecom-bot-mcp-server.git
|
|
220
|
+
cd wecom-bot-mcp-server
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
2. Create a virtual environment and install dependencies:
|
|
224
|
+
```bash
|
|
225
|
+
# Using uv (recommended)
|
|
226
|
+
pip install uv
|
|
227
|
+
uv venv
|
|
228
|
+
uv pip install -e ".[dev]"
|
|
229
|
+
|
|
230
|
+
# Or using traditional method
|
|
231
|
+
python -m venv venv
|
|
232
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
233
|
+
pip install -e ".[dev]"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Testing
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# Run all tests with coverage
|
|
240
|
+
uvx nox -s pytest
|
|
241
|
+
|
|
242
|
+
# Run import tests only
|
|
243
|
+
uvx nox -s test_imports
|
|
244
|
+
|
|
245
|
+
# Run specific test file
|
|
246
|
+
uvx nox -s pytest -- tests/test_message.py
|
|
247
|
+
|
|
248
|
+
# Run tests with verbose output
|
|
249
|
+
uvx nox -s pytest -- -v
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Code Style
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Check code
|
|
256
|
+
uvx nox -s lint
|
|
257
|
+
|
|
258
|
+
# Automatically fix code style issues
|
|
259
|
+
uvx nox -s lint_fix
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Building and Publishing
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# Build the package
|
|
266
|
+
uvx nox -s build
|
|
267
|
+
|
|
268
|
+
# Publish to PyPI (requires authentication)
|
|
269
|
+
uvx nox -s publish
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Continuous Integration
|
|
273
|
+
|
|
274
|
+
The project uses GitHub Actions for CI/CD:
|
|
275
|
+
- **MR Checks**: Runs on all pull requests, tests on Ubuntu, Windows, and macOS with Python 3.10, 3.11, and 3.12
|
|
276
|
+
- **Code Coverage**: Uploads coverage reports to Codecov
|
|
277
|
+
- **Import Tests**: Ensures the package can be imported correctly after installation
|
|
278
|
+
|
|
279
|
+
All dependencies are automatically tested during CI to catch issues early.
|
|
280
|
+
|
|
281
|
+
## Project Structure
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
wecom-bot-mcp-server/
|
|
285
|
+
├── src/
|
|
286
|
+
│ └── wecom_bot_mcp_server/
|
|
287
|
+
│ ├── __init__.py
|
|
288
|
+
│ ├── server.py
|
|
289
|
+
│ ├── message.py
|
|
290
|
+
│ ├── file.py
|
|
291
|
+
│ ├── image.py
|
|
292
|
+
│ ├── utils.py
|
|
293
|
+
│ └── errors.py
|
|
294
|
+
├── tests/
|
|
295
|
+
│ ├── test_server.py
|
|
296
|
+
│ ├── test_message.py
|
|
297
|
+
│ ├── test_file.py
|
|
298
|
+
│ └── test_image.py
|
|
299
|
+
├── docs/
|
|
300
|
+
├── pyproject.toml
|
|
301
|
+
├── noxfile.py
|
|
302
|
+
└── README.md
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## License
|
|
306
|
+
|
|
307
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
308
|
+
|
|
309
|
+
## Contact
|
|
310
|
+
|
|
311
|
+
- Author: longhao
|
|
312
|
+
- Email: hal.long@outlook.com
|
|
313
|
+
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
[](https://mseep.ai/app/loonghao-wecom-bot-mcp-server)
|
|
2
|
+
|
|
3
|
+
# WeCom Bot MCP Server
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
<img src="wecom.png" alt="WeCom Bot Logo" width="200"/>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
A Model Context Protocol (MCP) compliant server implementation for WeCom (WeChat Work) bot.
|
|
10
|
+
|
|
11
|
+
[](https://badge.fury.io/py/wecom-bot-mcp-server)
|
|
12
|
+
[](https://pypi.org/project/wecom-bot-mcp-server/)
|
|
13
|
+
[](https://app.codecov.io/gh/loonghao/wecom-bot-mcp-server)
|
|
14
|
+
[](https://github.com/astral-sh/ruff)
|
|
15
|
+
[](https://smithery.ai/server/wecom-bot-mcp-server)
|
|
16
|
+
|
|
17
|
+
[English](README.md) | [中文](README_zh.md)
|
|
18
|
+
|
|
19
|
+
<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>
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Support for multiple message types:
|
|
24
|
+
- Text messages
|
|
25
|
+
- Markdown messages
|
|
26
|
+
- Image messages (base64)
|
|
27
|
+
- File messages
|
|
28
|
+
- @mention support (via user ID or phone number)
|
|
29
|
+
- Message history tracking
|
|
30
|
+
- Configurable logging system
|
|
31
|
+
- Full type annotations
|
|
32
|
+
- Pydantic-based data validation
|
|
33
|
+
|
|
34
|
+
## Requirements
|
|
35
|
+
|
|
36
|
+
- Python 3.10+
|
|
37
|
+
- WeCom Bot Webhook URL (obtained from WeCom group settings)
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
There are several ways to install WeCom Bot MCP Server:
|
|
42
|
+
|
|
43
|
+
### 1. Automated Installation (Recommended)
|
|
44
|
+
|
|
45
|
+
#### Using Smithery (For Claude Desktop):
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx -y @smithery/cli install wecom-bot-mcp-server --client claude
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
#### Using VSCode with Cline Extension:
|
|
52
|
+
|
|
53
|
+
1. Install [Cline Extension](https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev) from VSCode marketplace
|
|
54
|
+
2. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
|
|
55
|
+
3. Search for "Cline: Install Package"
|
|
56
|
+
4. Type "wecom-bot-mcp-server" and press Enter
|
|
57
|
+
|
|
58
|
+
### 2. Manual Configuration
|
|
59
|
+
|
|
60
|
+
Add the server to your MCP client configuration file:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
// For Claude Desktop on macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
|
|
64
|
+
// For Claude Desktop on Windows: %APPDATA%\Claude\claude_desktop_config.json
|
|
65
|
+
// For Windsurf: ~/.windsurf/config.json
|
|
66
|
+
// For Cline in VSCode: VSCode Settings > Cline > MCP Settings
|
|
67
|
+
{
|
|
68
|
+
"mcpServers": {
|
|
69
|
+
"wecom": {
|
|
70
|
+
"command": "uvx",
|
|
71
|
+
"args": [
|
|
72
|
+
"wecom-bot-mcp-server"
|
|
73
|
+
],
|
|
74
|
+
"env": {
|
|
75
|
+
"WECOM_WEBHOOK_URL": "your-webhook-url"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Configuration
|
|
83
|
+
|
|
84
|
+
### Setting Environment Variables
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Windows PowerShell
|
|
88
|
+
$env:WECOM_WEBHOOK_URL = "your-webhook-url"
|
|
89
|
+
|
|
90
|
+
# Optional configurations
|
|
91
|
+
$env:MCP_LOG_LEVEL = "DEBUG" # Log levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
92
|
+
$env:MCP_LOG_FILE = "path/to/custom/log/file.log" # Custom log file path
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Log Management
|
|
96
|
+
|
|
97
|
+
The logging system uses `platformdirs.user_log_dir()` for cross-platform log file management:
|
|
98
|
+
|
|
99
|
+
- Windows: `C:\Users\<username>\AppData\Local\hal\wecom-bot-mcp-server\Logs`
|
|
100
|
+
- Linux: `~/.local/state/hal/wecom-bot-mcp-server/log`
|
|
101
|
+
- macOS: `~/Library/Logs/hal/wecom-bot-mcp-server`
|
|
102
|
+
|
|
103
|
+
The log file is named `mcp_wecom.log` and is stored in the above directory.
|
|
104
|
+
|
|
105
|
+
You can customize the log level and file path using environment variables:
|
|
106
|
+
- `MCP_LOG_LEVEL`: Set to DEBUG, INFO, WARNING, ERROR, or CRITICAL
|
|
107
|
+
- `MCP_LOG_FILE`: Set to a custom log file path
|
|
108
|
+
|
|
109
|
+
## Usage
|
|
110
|
+
|
|
111
|
+
Once configured, the MCP server runs automatically when your MCP client starts. You can interact with it through natural language in your AI assistant.
|
|
112
|
+
|
|
113
|
+
### Usage Examples
|
|
114
|
+
|
|
115
|
+
**Scenario 1: Send weather information to WeCom**
|
|
116
|
+
```
|
|
117
|
+
USER: "How's the weather in Shenzhen today? Send it to WeCom"
|
|
118
|
+
ASSISTANT: "I'll check Shenzhen's weather and send it to WeCom"
|
|
119
|
+
[The assistant will use the send_message tool to send the weather information]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Scenario 2: Send meeting reminder and @mention relevant people**
|
|
123
|
+
```
|
|
124
|
+
USER: "Send a reminder for the 3 PM project review meeting, remind Zhang San and Li Si to attend"
|
|
125
|
+
ASSISTANT: "I'll send the meeting reminder"
|
|
126
|
+
[The assistant will use the send_message tool with mentioned_list parameter]
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Scenario 3: Send a file**
|
|
130
|
+
```
|
|
131
|
+
USER: "Send this weekly report to the WeCom group"
|
|
132
|
+
ASSISTANT: "I'll send the weekly report"
|
|
133
|
+
[The assistant will use the send_file tool]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Scenario 4: Send an image**
|
|
137
|
+
```
|
|
138
|
+
USER: "Send this chart image to WeCom"
|
|
139
|
+
ASSISTANT: "I'll send the image"
|
|
140
|
+
[The assistant will use the send_image tool]
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Available MCP Tools
|
|
144
|
+
|
|
145
|
+
The server provides the following tools that your AI assistant can use:
|
|
146
|
+
|
|
147
|
+
1. **send_message** - Send text or markdown messages
|
|
148
|
+
- Parameters: `content`, `msg_type` (text/markdown), `mentioned_list`, `mentioned_mobile_list`
|
|
149
|
+
|
|
150
|
+
2. **send_file** - Send files to WeCom
|
|
151
|
+
- Parameters: `file_path`
|
|
152
|
+
|
|
153
|
+
3. **send_image** - Send images to WeCom
|
|
154
|
+
- Parameters: `image_path` (local path or URL)
|
|
155
|
+
|
|
156
|
+
### For Developers: Direct API Usage
|
|
157
|
+
|
|
158
|
+
If you want to use this package directly in your Python code (not as an MCP server):
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from wecom_bot_mcp_server import send_message, send_wecom_file, send_wecom_image
|
|
162
|
+
|
|
163
|
+
# Send markdown message
|
|
164
|
+
await send_message(
|
|
165
|
+
content="**Hello World!**",
|
|
166
|
+
msg_type="markdown"
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
# Send text message and mention users
|
|
170
|
+
await send_message(
|
|
171
|
+
content="Hello @user1 @user2",
|
|
172
|
+
msg_type="text",
|
|
173
|
+
mentioned_list=["user1", "user2"]
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
# Send file
|
|
177
|
+
await send_wecom_file("/path/to/file.txt")
|
|
178
|
+
|
|
179
|
+
# Send image
|
|
180
|
+
await send_wecom_image("/path/to/image.png")
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Development
|
|
184
|
+
|
|
185
|
+
### Setup Development Environment
|
|
186
|
+
|
|
187
|
+
1. Clone the repository:
|
|
188
|
+
```bash
|
|
189
|
+
git clone https://github.com/loonghao/wecom-bot-mcp-server.git
|
|
190
|
+
cd wecom-bot-mcp-server
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
2. Create a virtual environment and install dependencies:
|
|
194
|
+
```bash
|
|
195
|
+
# Using uv (recommended)
|
|
196
|
+
pip install uv
|
|
197
|
+
uv venv
|
|
198
|
+
uv pip install -e ".[dev]"
|
|
199
|
+
|
|
200
|
+
# Or using traditional method
|
|
201
|
+
python -m venv venv
|
|
202
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
203
|
+
pip install -e ".[dev]"
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Testing
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# Run all tests with coverage
|
|
210
|
+
uvx nox -s pytest
|
|
211
|
+
|
|
212
|
+
# Run import tests only
|
|
213
|
+
uvx nox -s test_imports
|
|
214
|
+
|
|
215
|
+
# Run specific test file
|
|
216
|
+
uvx nox -s pytest -- tests/test_message.py
|
|
217
|
+
|
|
218
|
+
# Run tests with verbose output
|
|
219
|
+
uvx nox -s pytest -- -v
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Code Style
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Check code
|
|
226
|
+
uvx nox -s lint
|
|
227
|
+
|
|
228
|
+
# Automatically fix code style issues
|
|
229
|
+
uvx nox -s lint_fix
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Building and Publishing
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# Build the package
|
|
236
|
+
uvx nox -s build
|
|
237
|
+
|
|
238
|
+
# Publish to PyPI (requires authentication)
|
|
239
|
+
uvx nox -s publish
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Continuous Integration
|
|
243
|
+
|
|
244
|
+
The project uses GitHub Actions for CI/CD:
|
|
245
|
+
- **MR Checks**: Runs on all pull requests, tests on Ubuntu, Windows, and macOS with Python 3.10, 3.11, and 3.12
|
|
246
|
+
- **Code Coverage**: Uploads coverage reports to Codecov
|
|
247
|
+
- **Import Tests**: Ensures the package can be imported correctly after installation
|
|
248
|
+
|
|
249
|
+
All dependencies are automatically tested during CI to catch issues early.
|
|
250
|
+
|
|
251
|
+
## Project Structure
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
wecom-bot-mcp-server/
|
|
255
|
+
├── src/
|
|
256
|
+
│ └── wecom_bot_mcp_server/
|
|
257
|
+
│ ├── __init__.py
|
|
258
|
+
│ ├── server.py
|
|
259
|
+
│ ├── message.py
|
|
260
|
+
│ ├── file.py
|
|
261
|
+
│ ├── image.py
|
|
262
|
+
│ ├── utils.py
|
|
263
|
+
│ └── errors.py
|
|
264
|
+
├── tests/
|
|
265
|
+
│ ├── test_server.py
|
|
266
|
+
│ ├── test_message.py
|
|
267
|
+
│ ├── test_file.py
|
|
268
|
+
│ └── test_image.py
|
|
269
|
+
├── docs/
|
|
270
|
+
├── pyproject.toml
|
|
271
|
+
├── noxfile.py
|
|
272
|
+
└── README.md
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## License
|
|
276
|
+
|
|
277
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
278
|
+
|
|
279
|
+
## Contact
|
|
280
|
+
|
|
281
|
+
- Author: longhao
|
|
282
|
+
- Email: hal.long@outlook.com
|