wework_send_text
Send text or Markdown messages to WeWork group chats using a bot webhook. Configure bot keys and message types to deliver notifications through the enterprise messaging platform.
Instructions
通过企业微信群机器人发送文本或Markdown消息
Input Schema
TableJSON 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:26-41 (handler)The main handler function 'wework_send_text' decorated with @mcp.tool(), which sends text or markdown_v2 messages to WeWork group robot via webhook API.@mcp.tool( title="企业微信群机器人-发送文本消息", description="通过企业微信群机器人发送文本或Markdown消息", ) 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/__init__.py:19-19 (registration)The registration call 'wework.add_tools(mcp)' which registers the wework_send_text tool (and others from wework.py) to the FastMCP instance.wework.add_tools(mcp)
- mcp_notify/wework.py:31-34 (schema)Pydantic Field definitions for the input parameters of the wework_send_text tool, defining schema and validation.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/__init__.py:18-18 (registration)Creation of the FastMCP server instance where tools are registered.mcp = FastMCP(name="mcp-notify", version="0.1.8")
- mcp_notify/wework.py:20-22 (helper)Reusable Pydantic Field definitions used in tool parameters for bot_key and to_user.FIELD_BOT_KEY = Field("", description="企业微信群机器人key,uuid格式,默认从环境变量获取") FIELD_TO_USER = Field("", description="接收消息的成员ID,多个用`|`分隔,为`@all`时向该企业应用全部成员发送,默认从环境变量获取")