Skip to main content
Glama
aahl

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

by aahl

企业微信应用号-发送语音消息

wework_app_send_voice

Send a voice message to WeCom users by providing a voice URL. Optionally specify recipients by member IDs or send to all.

Instructions

通过企业微信应用号发送发送语音消息

Input Schema

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

Implementation Reference

  • The tool handler function that sends a voice message via WeChat Work app. It accepts a voice URL and optional user target, then delegates to wework_send_media with msgtype='voice'.
    def wework_app_send_voice(
        url: str = Field(description="语音URL"),
        touser: str = FIELD_TO_USER,
    ):
        return wework_send_media(touser, url, "voice")
  • The shared helper function that downloads media from a URL, uploads it to WeChat Work to get a media_id, then sends it as a message to users. Used by wework_app_send_voice with msgtype='voice'.
    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()
  • Input schema for the tool: url (string, voice file URL) and touser (string, target user IDs, defaults to env variable).
    def wework_app_send_voice(
        url: str = Field(description="语音URL"),
        touser: str = FIELD_TO_USER,
    ):
        return wework_send_media(touser, url, "voice")
  • The @mcp.tool() decorator that registers wework_app_send_voice as an MCP tool with title and description.
    @mcp.tool(
        title="企业微信应用号-发送语音消息",
        description="通过企业微信应用号发送发送语音消息",
    )
  • The add_tools function is called from __init__.py to register all WeChat Work tools including wework_app_send_voice.
    def add_tools(mcp: FastMCP, logger=None):
    
        @mcp.tool(

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description must disclose behavioral traits. It only states the basic action without revealing permissions, side effects, return values, or error behavior. For a mutating tool like this, more context is needed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise and front-loaded, but it contains a duplicated word ('发送发送') which slightly reduces clarity. Nevertheless, it is efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description lacks important context such as supported voice formats, message size limits, or confirmation of sending. For a messaging tool, this is insufficient for full understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Both parameters have descriptions in the schema (100% coverage), and the tool description does not add additional semantic value beyond what is in the schema. The baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool sends a voice message via WeCom application account, distinguishing it from siblings like text, image, and file sending tools. However, it has a minor duplicate word '发送' and could be more specific about voice message types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus other related tools (e.g., wework_app_send_audio is absent but wework_app_send_file, image, etc. exist). The description does not mention prerequisites, alternatives, or conditions for use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.