wework_app_send_news
Send rich media card notifications through WeWork enterprise applications to communicate updates, announcements, or alerts with titles, descriptions, images, and links to team members.
Instructions
通过企业微信应用号发送图文卡片消息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | 标题,不超过128个字符 | |
| url | Yes | 跳转链接,最长2048字节,必须包含协议头(http/https) | |
| picurl | No | 图片URL | |
| description | No | 描述,不超过512个字符 | |
| touser | No | 接收消息的成员ID,多个用`|`分隔,为`@all`时向该企业应用全部成员发送,默认从环境变量获取 |
Implementation Reference
- mcp_notify/wework.py:203-232 (handler)The handler function implementing the wework_app_send_news tool. It sends a news message (graphical article) to WeWork enterprise app users using the obtained access token. Includes input schema via Pydantic Fields and @mcp.tool decorator for registration.@mcp.tool( title="企业微信应用号-发送图文卡片消息", description="通过企业微信应用号发送图文卡片消息", ) def wework_app_send_news( title: str = Field(description="标题,不超过128个字符"), url: str = Field(description="跳转链接,最长2048字节,必须包含协议头(http/https)"), picurl: str = Field("", description="图片URL"), description: str = Field("", description="描述,不超过512个字符"), 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": "news", "news": { "articles": [ { "title": title, "description": description, "url": url, "picurl": picurl, }, ], }, }, ) return res.json() or {}
- mcp_notify/__init__.py:19-19 (registration)Registration of the WeWork tools, including wework_app_send_news, by calling the add_tools function on the FastMCP instance.wework.add_tools(mcp)
- mcp_notify/wework.py:95-102 (helper)Helper function to retrieve and cache the WeWork access token required by the send_news handler.@cached(TTLCache(maxsize=1, ttl=3600)) 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")