Skip to main content
Glama
al-one

MCP Server for notify to weixin / telegram / bark / lark

wework_app_send_file

Send file messages through WeChat Work application to specified users or all members using file URLs for team communication and document sharing.

Instructions

通过企业微信应用号发送发送文件消息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
touserNo接收消息的成员ID,多个用`|`分隔,为`@all`时向该企业应用全部成员发送,默认从环境变量获取
urlYes文件URL

Implementation Reference

  • The handler function implementing the 'wework_app_send_file' tool logic. It takes a file URL and optional target user, then calls the shared wework_send_media helper with msgtype='file' to handle the upload and send.
    def wework_app_send_file( url: str = Field(description="文件URL"), touser: str = FIELD_TO_USER, ): return wework_send_media(touser, url, "file")
  • Core helper function that implements the media sending logic for images, videos, voice, and files. Downloads the file, uploads to WeWork media endpoint to get media_id, then sends the message.
    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()
  • Cached helper to fetch WeWork application access token using corp ID and secret, used in 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")
  • The @mcp.tool decorator that registers the wework_app_send_file tool with FastMCP, providing title and description.
    @mcp.tool( title="企业微信应用号-发送文件消息", description="通过企业微信应用号发送发送文件消息", )
  • Call to add_tools from wework.py, which defines and registers all WeWork tools including wework_app_send_file to the main MCP instance.
    wework.add_tools(mcp)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/al-one/mcp-notify'

If you have feedback or need assistance with the MCP directory API, please join our Discord server