wework_send_text
Send text or Markdown messages to WeCom group chats using bot integration for team notifications and alerts.
Instructions
通过企业微信群机器人发送文本或Markdown消息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bot_key | No | 企业微信群机器人key,uuid格式,默认从环境变量获取 | |
| msgtype | No | 内容类型,仅支持: text/markdown_v2 | text |
| text | Yes | 消息内容,长度限制: (text: 2048个字节, markdown_v2: 4096个字节) |
Implementation Reference
- mcp_notify/wework.py:30-41 (handler)The handler function that implements the logic to send text or markdown_v2 messages to WeWork group robot via webhook.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:31-34 (schema)Pydantic Field definitions for the tool's input parameters: text, msgtype, bot_key.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:26-29 (registration)The @mcp.tool decorator that registers wework_send_text as an MCP tool with title and description.@mcp.tool( title="企业微信群机器人-发送文本消息", description="通过企业微信群机器人发送文本或Markdown消息", )
- mcp_notify/__init__.py:18-23 (registration)Creation of FastMCP server instance and invocation of add_tools from wework (and other modules) to register the tools.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)
- mcp_notify/wework.py:13-18 (helper)Environment variable constants used by the wework_send_text tool and other WeWork functions.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"