wework_app_send_video
Send video messages through WeChat Work application to specified users or all members using video URLs for team communication and notifications.
Instructions
通过企业微信应用号发送发送视频消息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| touser | No | 接收消息的成员ID,多个用`|`分隔,为`@all`时向该企业应用全部成员发送,默认从环境变量获取 | |
| url | Yes | 视频URL |
Implementation Reference
- mcp_notify/wework.py:137-145 (handler)Handler for the 'wework_app_send_video' tool, including @mcp.tool decorator for registration and schema (url: video URL, touser: recipient), executes by calling helper wework_send_media(touser, url, 'video').@mcp.tool( title="企业微信应用号-发送视频消息", description="通过企业微信应用号发送发送视频消息", ) def wework_app_send_video( url: str = Field(description="视频URL"), touser: str = FIELD_TO_USER, ): return wework_send_media(touser, url, "video")
- mcp_notify/wework.py:167-200 (helper)Core helper function `wework_send_media` that determines media type, downloads from URL, uploads to WeWork media API, and sends the message using the media_id. Used by video, image, voice, and file tools.def wework_send_media(touser, url: str, msgtype=None): if msgtype: pass elif '.jpg' in url.lower() or '.jpeg' in url.lower() or '.png' in url.lower(): msgtype = 'image' elif '.mp4' in url.lower(): msgtype = 'video' elif '.arm' in url.lower(): msgtype = 'voice' else: msgtype = 'file' res = requests.get(url, timeout=120) res.raise_for_status() file = io.BytesIO(res.content) mine = res.headers.get("content-type") or "application/octet-stream" res = requests.post( f"{WEWORK_BASE_URL}/cgi-bin/media/upload", params={"type": msgtype, "access_token": get_access_token()}, files={"media": ("filename", file, mine)}, timeout=120, ) media = res.json() or {} if not (media_id := media.get("media_id")): return media 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: {"media_id": media_id}, }, ) return res.json()
- mcp_notify/__init__.py:18-23 (registration)Top-level registration where FastMCP instance is created and add_tools from wework (and others) is called to register the tools, including 'wework_app_send_video'.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:21-21 (schema)Shared Pydantic Field schema for the 'touser' parameter used across WeWork app notification tools.FIELD_TO_USER = Field("", description="接收消息的成员ID,多个用`|`分隔,为`@all`时向该企业应用全部成员发送,默认从环境变量获取")
- mcp_notify/wework.py:95-102 (helper)Cached helper to fetch WeWork access token required for API calls.@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")