企业微信群机器人-发送图文消息
wework_send_newsSend a news link message to a WeWork group via bot. Supports title, URL, optional image and description.
Instructions
通过企业微信群机器人发送图文链接消息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | 标题,不超过128个字节 | |
| url | Yes | 跳转链接,必填 | |
| picurl | No | 图片URL | |
| description | No | 描述,不超过512个字节 | |
| bot_key | No | 企业微信群机器人key,uuid格式,默认从环境变量获取 |
Implementation Reference
- mcp_notify/wework.py:65-88 (handler)The handler function for the 'wework_send_news' tool. It sends a news (图文) message via a WeWork group bot webhook. Parameters: title, url, picurl (optional), description (optional), bot_key (optional, defaults to env).
def wework_send_news( title: str = Field(description="标题,不超过128个字节"), url: str = Field(description="跳转链接,必填"), picurl: str = Field("", description="图片URL"), description: str = Field("", description="描述,不超过512个字节"), bot_key: str = FIELD_BOT_KEY, ): res = requests.post( f"{WEWORK_BASE_URL}/cgi-bin/webhook/send?key={bot_key or WEWORK_BOT_KEY}", json={ "msgtype": "news", "news": { "articles": [ { "title": title, "description": description, "url": url, "picurl": picurl, }, ], }, }, ) return res.json() - mcp_notify/wework.py:61-64 (registration)The @mcp.tool decorator that registers 'wework_send_news' as an MCP tool. The decorator provides the tool's title and description.
@mcp.tool( title="企业微信群机器人-发送图文消息", description="通过企业微信群机器人发送图文链接消息", ) - mcp_notify/wework.py:65-70 (schema)Input parameters/schema for wework_send_news using Pydantic Field descriptors. Parameters: title (required), url (required), picurl (optional, default ''), description (optional, default ''), bot_key (optional, defaults to FIELD_BOT_KEY which reads from env).
def wework_send_news( title: str = Field(description="标题,不超过128个字节"), url: str = Field(description="跳转链接,必填"), picurl: str = Field("", description="图片URL"), description: str = Field("", description="描述,不超过512个字节"), bot_key: str = FIELD_BOT_KEY, - mcp_notify/wework.py:17-18 (helper)The FIELD_BOT_KEY helper constant used as the default for bot_key parameter. Reads from environment or defaults to empty string.
FIELD_BOT_KEY = Field("", description="企业微信群机器人key,uuid格式,默认从环境变量获取") FIELD_TO_USER = Field("", description="接收消息的成员ID,多个用`|`分隔,为`@all`时向该企业应用全部成员发送,默认从环境变量获取") - mcp_notify/wework.py:21-23 (registration)The 'add_tools' function is called from __init__.py to register all WeWork tools including wework_send_news onto the FastMCP instance.
def add_tools(mcp: FastMCP, logger=None): @mcp.tool(