企业微信群机器人-发送文本消息
wework_send_textSend text or Markdown notifications to WeChat Work groups using a bot key. Message length limits: 2048 bytes for text, 4096 for Markdown.
Instructions
通过企业微信群机器人发送文本或Markdown消息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 消息内容,长度限制: (text: 2048个字节, markdown_v2: 4096个字节) | |
| msgtype | No | 内容类型,仅支持: text/markdown_v2 | text |
| bot_key | No | 企业微信群机器人key,uuid格式,默认从环境变量获取 |
Implementation Reference
- mcp_notify/wework.py:27-38 (handler)The handler function for the 'wework_send_text' tool. Sends a text or Markdown message via the WeWork (WeCom) group robot webhook API.
def wework_send_text( text: str = Field(description="消息内容,长度限制: (text: 2048个字节, markdown_v2: 4096个字节)"), msgtype: str = Field("text", description="内容类型,仅支持: text/markdown_v2"), bot_key: str = FIELD_BOT_KEY, ): if msgtype == "markdown": msgtype = "markdown_v2" res = requests.post( f"{WEWORK_BASE_URL}/cgi-bin/webhook/send?key={bot_key or WEWORK_BOT_KEY}", json={"msgtype": msgtype, msgtype: {"content": text}}, ) return res.json() - mcp_notify/wework.py:23-26 (registration)Registration of wework_send_text as an MCP tool via the @mcp.tool decorator, with title and description.
@mcp.tool( title="企业微信群机器人-发送文本消息", description="通过企业微信群机器人发送文本或Markdown消息", ) - mcp_notify/wework.py:27-31 (schema)Input schema/parameters for wework_send_text: text (message content), msgtype (text or markdown_v2), bot_key (bot webhook key).
def wework_send_text( text: str = Field(description="消息内容,长度限制: (text: 2048个字节, markdown_v2: 4096个字节)"), msgtype: str = Field("text", description="内容类型,仅支持: text/markdown_v2"), bot_key: str = FIELD_BOT_KEY, ): - mcp_notify/wework.py:10-20 (helper)Configuration constants and shared Field definitions used by wework_send_text and other tools.
WEWORK_BOT_KEY = os.getenv("WEWORK_BOT_KEY", "") WEWORK_APP_AGENTID = int(os.getenv("WEWORK_APP_AGENTID", 1000002)) WEWORK_APP_CORPID = os.getenv("WEWORK_APP_CORPID", "") WEWORK_APP_SECRET = os.getenv("WEWORK_APP_SECRET", "") WEWORK_APP_TOUSER = os.getenv("WEWORK_APP_TOUSER", "@all") WEWORK_BASE_URL = os.getenv("WEWORK_BASE_URL") or "https://qyapi.weixin.qq.com" FIELD_BOT_KEY = Field("", description="企业微信群机器人key,uuid格式,默认从环境变量获取") FIELD_TO_USER = Field("", description="接收消息的成员ID,多个用`|`分隔,为`@all`时向该企业应用全部成员发送,默认从环境变量获取")