企业微信应用号-发送文本消息
wework_app_send_textSend text or Markdown messages to WeWork users via the enterprise app, targeting specific members or broadcasting to all.
Instructions
通过企业微信应用号发送文本或Markdown消息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 消息内容,最长不超过2048个字节 | |
| msgtype | No | 内容类型,仅支持: text/markdown | text |
| touser | No | 接收消息的成员ID,多个用`|`分隔,为`@all`时向该企业应用全部成员发送,默认从环境变量获取 |
Implementation Reference
- mcp_notify/wework.py:106-122 (handler)The function `wework_app_send_text` that executes the tool logic for sending a text message via the WeWork app. It sends an HTTP POST request to the WeWork API with the text content, message type, recipient, and agent ID, including duplicate check settings.
def wework_app_send_text( text: str = Field(description="消息内容,最长不超过2048个字节"), msgtype: str = Field("text", description="内容类型,仅支持: text/markdown"), touser: str = FIELD_TO_USER, ): res = requests.post( f"{WEWORK_BASE_URL}/cgi-bin/message/send?access_token={get_access_token()}", json={ "touser": touser or WEWORK_APP_TOUSER, "agentid": WEWORK_APP_AGENTID, "msgtype": msgtype, msgtype: {"content": text}, "enable_duplicate_check": 1, "duplicate_check_interval": 60, }, ) return res.json() or {} - mcp_notify/wework.py:102-105 (registration)The `@mcp.tool` decorator that registers `wework_app_send_text` as an MCP tool with title '企业微信应用号-发送文本消息' and description '通过企业微信应用号发送文本或Markdown消息'.
@mcp.tool( title="企业微信应用号-发送文本消息", description="通过企业微信应用号发送文本或Markdown消息", ) - mcp_notify/wework.py:107-109 (schema)The parameters/schema for `wework_app_send_text`: `text` (message content, max 2048 bytes), `msgtype` (content type, supports text/markdown), and `touser` (recipient member IDs).
text: str = Field(description="消息内容,最长不超过2048个字节"), msgtype: str = Field("text", description="内容类型,仅支持: text/markdown"), touser: str = FIELD_TO_USER, - mcp_notify/wework.py:10-18 (helper)Environment variable configuration and default field definitions used by `wework_app_send_text`, including WEWORK_APP_AGENTID, WEWORK_APP_CORPID, WEWORK_APP_SECRET, WEWORK_APP_TOUSER, and the FIELD_TO_USER default value.
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`时向该企业应用全部成员发送,默认从环境变量获取") - mcp_notify/__init__.py:19-19 (registration)The top-level registration call `wework.add_tools(mcp)` which invokes `add_tools` in wework.py where `wework_app_send_text` is conditionally registered (only if WEWORK_APP_CORPID and WEWORK_APP_SECRET are set).
wework.add_tools(mcp)