Skip to main content
Glama

send_photo

Send a photo to a Telegram chat using a URL, with optional caption and formatting. Control notification settings.

Instructions

Send a photo to a Telegram chat.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chat_idYes
photo_urlYes
captionNo
parse_modeNoHTML
disable_notificationNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYes
errorNo
message_idNo
chat_idNo

Implementation Reference

  • The 'send_photo' MCP tool handler. Defined as an async function registered via @mcp.tool decorator. Accepts chat_id, photo_url, caption, parse_mode, disable_notification. Checks chat permission, acquires rate limiter token, calls ctx.bot.send_photo(), audits on completion, returns SendPhotoResult.
    @mcp.tool
    async def send_photo(
        chat_id: int,
        photo_url: str,
        caption: str | None = None,
        parse_mode: str | None = "HTML",
        disable_notification: bool = False,
    ) -> SendPhotoResult:
        """Send a photo to a Telegram chat."""
        if not ctx.is_chat_allowed(chat_id):
            result = SendPhotoResult(ok=False, error=f"Chat {chat_id} is not allowed.")
            if ctx.audit_logger:
                ctx.audit_logger.log(
                    "send_photo",
                    {"chat_id": chat_id, "photo_url": photo_url},
                    result.ok,
                    result.error,
                )
            return result
    
        try:
            if ctx.rate_limiter:
                await ctx.rate_limiter.acquire()
            msg = await ctx.bot.send_photo(
                chat_id=chat_id,
                photo=photo_url,
                caption=caption,
                parse_mode=normalize_parse_mode(parse_mode),
                disable_notification=disable_notification,
            )
            result = SendPhotoResult(ok=True, message_id=msg.message_id, chat_id=msg.chat.id)
        except ValueError as exc:
            result = SendPhotoResult(ok=False, error=str(exc))
        except (TelegramBadRequest, TelegramForbiddenError) as exc:
            result = SendPhotoResult(ok=False, error=str(exc))
    
        if ctx.audit_logger:
            ctx.audit_logger.log(
                "send_photo",
                {"chat_id": chat_id, "photo_url": photo_url},
                result.ok,
                result.error,
            )
        return result
  • SendPhotoResult model: the Pydantic response schema for send_photo, containing message_id and chat_id fields.
    class SendPhotoResult(ToolResponse):
        message_id: int | None = None
        chat_id: int | None = None
  • register_messaging_tools function: registers the send_photo tool (alongside send_message, forward_message, etc.) on the FastMCP instance, conditioned on allowed_tools containing 'send_photo'.
    def register_messaging_tools(
        mcp: FastMCP, ctx: BotContext, allowed_tools: set[str] | None = None
    ) -> None:
  • AiogramMCP._register_tools calls register_messaging_tools with the permission-filtered allowed_tools set, which gates whether send_photo is registered.
    def _register_tools(self) -> None:
        at = self._allowed_tools
        register_messaging_tools(self._mcp, self._ctx, allowed_tools=at)
  • send_photo is mapped to PermissionLevel.MESSAGING in TOOL_PERMISSIONS dict, controlling which permission level can access it.
    "send_message": PermissionLevel.MESSAGING,
    "send_photo": PermissionLevel.MESSAGING,
    "forward_message": PermissionLevel.MESSAGING,
    "send_interactive_message": PermissionLevel.MESSAGING,
    "edit_message": PermissionLevel.MESSAGING,
    "answer_callback_query": PermissionLevel.MESSAGING,
    "send_document": PermissionLevel.MESSAGING,
    "send_voice": PermissionLevel.MESSAGING,
    "send_video": PermissionLevel.MESSAGING,
    "send_animation": PermissionLevel.MESSAGING,
    "send_audio": PermissionLevel.MESSAGING,
    "send_sticker": PermissionLevel.MESSAGING,
    "send_video_note": PermissionLevel.MESSAGING,
    "send_contact": PermissionLevel.MESSAGING,
    "send_location": PermissionLevel.MESSAGING,
    "send_poll": PermissionLevel.MESSAGING,
    # moderation (6 tools)
    "delete_message": PermissionLevel.MODERATION,
    "pin_message": PermissionLevel.MODERATION,
    "ban_user": PermissionLevel.MODERATION,
    "unban_user": PermissionLevel.MODERATION,
    "set_chat_title": PermissionLevel.MODERATION,
    "set_chat_description": PermissionLevel.MODERATION,
    # admin (3 tools)
    "broadcast": PermissionLevel.ADMIN,
    "subscribe_events": PermissionLevel.ADMIN,
    "unsubscribe_events": PermissionLevel.ADMIN,
Behavior2/5

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

No annotations provided, so description must cover behavioral traits. It does not mention file size limits, authentication, error handling, or consequences of invalid parameters.

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

Conciseness3/5

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

The description is very short (one sentence) but lacks essential details. It is concise but not sufficiently informative.

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 the tool complexity (5 params, no annotations, output schema exists but not detailed), the description is too sparse to guide correct usage. It omits crucial context about when and how to use.

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

Parameters1/5

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

Schema description coverage is 0%, and the description provides no information about any of the 5 parameters (chat_id, photo_url, caption, parse_mode, disable_notification).

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 clearly states the verb and resource: 'Send a photo to a Telegram chat.' It distinguishes from sibling tools like 'send_document' or 'send_video'.

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 on when to use this tool vs alternatives such as send_document, send_photo vs send_sticker, or any prerequisites. The description is too brief to provide usage context.

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/Py2755/aiogram-mcp'

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