Skip to main content
Glama
al-one

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

Telegram send audio

tg_send_audio

Send audio messages to Telegram chats using a bot. Provide an audio URL or base64 data URI, with optional caption and reply settings.

Instructions

Send audio via telegram bot

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
audioYesAudio URL or base64 data URI (e.g., data:audio/wav;base64,...
chat_idNoTelegram chat id, Default to get from environment variables
captionNoAudio caption, 0-1024 characters after entities parsing
parse_modeNoMode for parsing entities in the caption. [text/MarkdownV2]
reply_to_message_idNoIdentifier of the message that will be replied to

Implementation Reference

  • The tool 'tg_send_audio' is registered via the @mcp.tool decorator with title 'Telegram send audio' and description 'Send audio via telegram bot'. The decorator is how FastMCP registers tools.
    @mcp.tool(
        title="Telegram send audio",
        description="Send audio via telegram bot",
    )
    async def tg_send_audio(
        audio: str = Field(description="Audio URL or base64 data URI (e.g., data:audio/wav;base64,..."),
        chat_id: str = Field("", description="Telegram chat id, Default to get from environment variables"),
        caption: str = Field("", description="Audio caption, 0-1024 characters after entities parsing"),
        parse_mode: str = Field("", description=f"Mode for parsing entities in the caption. [text/MarkdownV2]"),
        reply_to_message_id: int = Field(0, description="Identifier of the message that will be replied to"),
    ):
        if parse_mode == TELEGRAM_MARKDOWN_V2:
            caption = telegramify_markdown.markdownify(caption)
    
        if audio.startswith("data:"):
            match = re.match(r"data:audio/([^;]+);base64,(.*)", audio)
            if not match:
                return {"error": "Invalid base64 data URL format"}
            try:
                datas = base64.b64decode(match.group(2))
                audio = InputFile(io.BytesIO(datas), f"audio.{match.group(1)}")
            except Exception as e:
                return {"error": f"Failed to decode base64: {str(e)}"}
    
        res = await bot.send_audio(
            chat_id=chat_id or TELEGRAM_DEFAULT_CHAT,
            audio=audio,
            caption=caption or None,
            parse_mode=parse_mode if parse_mode in [TELEGRAM_MARKDOWN_V2] else None,
            reply_to_message_id=reply_to_message_id or None,
        )
        return res.to_json()
  • The tg_send_audio async function is the handler. It accepts audio (URL or base64 data URI), chat_id, caption, parse_mode, and reply_to_message_id. It decodes base64 data URIs for audio files and calls bot.send_audio() to send the audio via Telegram.
    async def tg_send_audio(
        audio: str = Field(description="Audio URL or base64 data URI (e.g., data:audio/wav;base64,..."),
        chat_id: str = Field("", description="Telegram chat id, Default to get from environment variables"),
        caption: str = Field("", description="Audio caption, 0-1024 characters after entities parsing"),
        parse_mode: str = Field("", description=f"Mode for parsing entities in the caption. [text/MarkdownV2]"),
        reply_to_message_id: int = Field(0, description="Identifier of the message that will be replied to"),
    ):
        if parse_mode == TELEGRAM_MARKDOWN_V2:
            caption = telegramify_markdown.markdownify(caption)
    
        if audio.startswith("data:"):
            match = re.match(r"data:audio/([^;]+);base64,(.*)", audio)
            if not match:
                return {"error": "Invalid base64 data URL format"}
            try:
                datas = base64.b64decode(match.group(2))
                audio = InputFile(io.BytesIO(datas), f"audio.{match.group(1)}")
            except Exception as e:
                return {"error": f"Failed to decode base64: {str(e)}"}
    
        res = await bot.send_audio(
            chat_id=chat_id or TELEGRAM_DEFAULT_CHAT,
            audio=audio,
            caption=caption or None,
            parse_mode=parse_mode if parse_mode in [TELEGRAM_MARKDOWN_V2] else None,
            reply_to_message_id=reply_to_message_id or None,
        )
        return res.to_json()
  • The input parameters are defined via Pydantic Field descriptors: audio (str), chat_id (str), caption (str), parse_mode (str), reply_to_message_id (int). These serve as the input schema for the tool.
    async def tg_send_audio(
        audio: str = Field(description="Audio URL or base64 data URI (e.g., data:audio/wav;base64,..."),
        chat_id: str = Field("", description="Telegram chat id, Default to get from environment variables"),
        caption: str = Field("", description="Audio caption, 0-1024 characters after entities parsing"),
        parse_mode: str = Field("", description=f"Mode for parsing entities in the caption. [text/MarkdownV2]"),
        reply_to_message_id: int = Field(0, description="Identifier of the message that will be replied to"),
    ):
  • The add_tools function creates the Bot instance with TELEGRAM_BOT_TOKEN and configures the base URLs. This is the setup/registration entry point called from __init__.py (line 20: tgbot.add_tools(mcp)).
    def add_tools(mcp: FastMCP, logger=None):
        bot = Bot(
            TELEGRAM_BOT_TOKEN,
            base_url=f"{TELEGRAM_BASE_URL}/bot",
            base_file_url=f"{TELEGRAM_BASE_URL}/file/bot",
        ) if TELEGRAM_BOT_TOKEN else None
  • The registration call chain: __init__.py calls tgbot.add_tools(mcp) which registers all Telegram tools including tg_send_audio.
    tgbot.add_tools(mcp)
Behavior2/5

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

With no annotations, the bare description fails to disclose behavioral traits like file handling, size limits, required permissions, or whether the audio is sent as a direct upload or URL. The agent cannot infer important behaviors beyond the obvious.

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

Conciseness5/5

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

The description is a single sentence with no redundant words. It is maximally concise and front-loaded with the core purpose.

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?

Despite having 5 parameters and many sibling tools, the description gives no insight into return values, error handling, or the overall workflow. An agent cannot form a complete mental model of the tool's behavior from this minimal information, especially with no output schema.

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?

Since schema description coverage is 100%, the description does not need to reiterate parameter details. However, it adds no extra context beyond the schema, such as how parameters interact or typical usage patterns, so a baseline score of 3 is appropriate.

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

Purpose5/5

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

The description 'Send audio via telegram bot' clearly states the action (send) and the resource (audio via telegram bot). It is specific enough to distinguish from sibling tools like tg_send_photo, tg_send_video, etc., which serve different media 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 alternatives (e.g., tg_send_file, tg_send_photo) or prerequisites such as authentication or bot setup. The description lacks any context for the agent to decide among the many sibling tools.

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

Install Server

Other Tools

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