Skip to main content
Glama

delete_message

Remove a specific message from a chat by providing its chat ID and message ID.

Instructions

Delete a message from a chat.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chat_idYes
message_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYes
errorNo

Implementation Reference

  • Registration guard and handler function for the 'delete_message' tool. Checks if tool is allowed, validates chat permission, calls ctx.bot.delete_message(), and logs via audit logger.
    if allowed_tools is None or "delete_message" in allowed_tools:
    
        @mcp.tool
        async def delete_message(chat_id: int, message_id: int) -> OkResult:
            """Delete a message from a chat."""
            if not ctx.is_chat_allowed(chat_id):
                result = OkResult(ok=False, error=f"Chat {chat_id} is not allowed.")
                if ctx.audit_logger:
                    ctx.audit_logger.log(
                        "delete_message",
                        {"chat_id": chat_id, "message_id": message_id},
                        result.ok,
                        result.error,
                    )
                return result
    
            try:
                if ctx.rate_limiter:
                    await ctx.rate_limiter.acquire()
                await ctx.bot.delete_message(chat_id=chat_id, message_id=message_id)
                result = OkResult(ok=True)
            except (TelegramBadRequest, TelegramForbiddenError) as exc:
                result = OkResult(ok=False, error=str(exc))
    
            if ctx.audit_logger:
                ctx.audit_logger.log(
                    "delete_message",
                    {"chat_id": chat_id, "message_id": message_id},
                    result.ok,
                    result.error,
                )
            return result
  • OkResult is the return type used by delete_message (imported from ..models)
    from ..models import OkResult, ToolResponse
    from ..utils import normalize_parse_mode
    
    
    class SendMessageResult(ToolResponse):
  • The delete_message tool is registered via the @mcp.tool decorator inside register_messaging_tools(), conditional on the allowed_tools filter.
    if allowed_tools is None or "delete_message" in allowed_tools:
    
        @mcp.tool
        async def delete_message(chat_id: int, message_id: int) -> OkResult:
            """Delete a message from a chat."""
            if not ctx.is_chat_allowed(chat_id):
                result = OkResult(ok=False, error=f"Chat {chat_id} is not allowed.")
                if ctx.audit_logger:
                    ctx.audit_logger.log(
                        "delete_message",
                        {"chat_id": chat_id, "message_id": message_id},
                        result.ok,
                        result.error,
                    )
                return result
    
            try:
                if ctx.rate_limiter:
                    await ctx.rate_limiter.acquire()
                await ctx.bot.delete_message(chat_id=chat_id, message_id=message_id)
                result = OkResult(ok=True)
            except (TelegramBadRequest, TelegramForbiddenError) as exc:
                result = OkResult(ok=False, error=str(exc))
    
            if ctx.audit_logger:
                ctx.audit_logger.log(
                    "delete_message",
                    {"chat_id": chat_id, "message_id": message_id},
                    result.ok,
                    result.error,
                )
            return result
  • Permission level assignment for delete_message: MODERATION level.
    "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,
Behavior2/5

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

The description implies a destructive action but provides no details such as permissions required, irreversibility, or side effects. Since no annotations are provided, the description bears full responsibility for transparency and fails to disclose key behavioral traits.

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

Conciseness2/5

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

The description is a single sentence, which is concise but overly terse. It omits necessary detail and does not earn its place by adding value beyond the tool name.

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?

While an output schema exists, the description fails to provide adequate context for a mutation tool. With no parameter descriptions and no behavioral transparency, the description is incomplete for safe and correct usage.

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?

The input schema has two parameters with zero description coverage. The description does not explain or add meaning to 'chat_id' or 'message_id', leaving the agent with only parameter names which may be ambiguous.

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 states the verb 'delete' and the resource 'message from a chat', making the purpose clear. However, it does not differentiate from sibling tools like 'edit_message' or 'pin_message', which could cause confusion.

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?

There is no guidance on when to use this tool versus alternatives. No exclusions or prerequisites are mentioned, leaving the agent without context for appropriate usage.

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