企业微信群机器人-发送图片消息
wework_send_imageSend an image message to a WeChat Work group using a robot. Provide the image URL and optionally a bot key to notify group members.
Instructions
通过企业微信群机器人发送图片消息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | 图片url | |
| bot_key | No | 企业微信群机器人key,uuid格式,默认从环境变量获取 |
Implementation Reference
- mcp_notify/wework.py:45-58 (handler)The `wework_send_image` function is the handler for the 'wework_send_image' MCP tool. It downloads an image from a URL, base64-encodes it, computes its MD5 hash, and sends it as an image message via the WeChat Work (企业微信) group bot webhook API.
def wework_send_image( url: str = Field(description="图片url"), bot_key: str = FIELD_BOT_KEY, ): res = requests.get(url, timeout=120) res.raise_for_status() b64str = base64.b64encode(res.content).decode() md5str = hashlib.md5(res.content).hexdigest() res = requests.post( f"{WEWORK_BASE_URL}/cgi-bin/webhook/send?key={bot_key or WEWORK_BOT_KEY}", json={"msgtype": "image", "image": {"base64": b64str, "md5": md5str}}, timeout=120, ) return res.json() - mcp_notify/wework.py:45-47 (schema)The function signature uses Pydantic Field for schema definitions: `url` (str, required, description '图片url') and `bot_key` (str, defaults from global FIELD_BOT_KEY env variable).
def wework_send_image( url: str = Field(description="图片url"), bot_key: str = FIELD_BOT_KEY, - mcp_notify/wework.py:41-44 (registration)The tool is registered via the `@mcp.tool()` decorator with title '企业微信群机器人-发送图片消息' and description '通过企业微信群机器人发送图片消息', inside the `add_tools(mcp)` function.
@mcp.tool( title="企业微信群机器人-发送图片消息", description="通过企业微信群机器人发送图片消息", )