wework_app_send_text
Send text or Markdown messages through WeCom application accounts for team communication and notifications. Supports sending to specific users or all members with content up to 2048 bytes.
Instructions
通过企业微信应用号发送文本或Markdown消息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| msgtype | No | 内容类型,仅支持: text/markdown | text |
| text | Yes | 消息内容,最长不超过2048个字节 | |
| touser | No | 接收消息的成员ID,多个用`|`分隔,为`@all`时向该企业应用全部成员发送,默认从环境变量获取 |
Implementation Reference
- mcp_notify/wework.py:105-125 (handler)The handler function decorated with @mcp.tool, including input schema via Pydantic Fields and title/description. Executes the tool logic by posting a message to the WeWork API endpoint using a cached access token.@mcp.tool( title="企业微信应用号-发送文本消息", description="通过企业微信应用号发送文本或Markdown消息", ) 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:96-102 (helper)Cached helper function to retrieve the access token needed for authenticated API calls to send messages.def get_access_token(): res = requests.get( f"{WEWORK_BASE_URL}/cgi-bin/gettoken", params={"corpid": WEWORK_APP_CORPID, "corpsecret": WEWORK_APP_SECRET}, timeout=60, ) return res.json().get("access_token")
- mcp_notify/__init__.py:18-23 (registration)Creates the FastMCP server and registers all tools by calling add_tools from each module, including wework which contains the wework_app_send_text tool.mcp = FastMCP(name="mcp-notify", version="0.1.7") wework.add_tools(mcp) tgbot.add_tools(mcp) other.add_tools(mcp) hass.add_tools(mcp) util.add_tools(mcp)