Skip to main content
Glama
prem-research

Telegram MCP Server

get_unread_messages

Retrieve all unread messages from a specific Telegram entity to monitor conversations without manual checking.

Instructions

get all unread messages from a given entity id

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNo

Implementation Reference

  • Registration of the MCP tool 'get_unread_messages' using @mcp.tool decorator
    @mcp.tool(
        name="get_unread_messages",
        description="get all unread messages from a given entity id",
    )
  • Handler function for the 'get_unread_messages' MCP tool, which proxies the request to the HTTP API endpoint to fetch unread messages.
    async def get_unread_messages(id: int = None) -> list[dict]:
        return get(f"{api_endpoint}get_unread_messages/{id}").json()
  • HTTP API endpoint handler that implements the logic for retrieving unread messages by getting the unread count from chats and fetching that many messages, marking them as read.
    @app.get("/get_unread_messages/{chat_id}")
    async def get_unread_messages(chat_id: int):
        dialogs = await get_chats()
        if chat_id not in dialogs:
            raise HTTPException(status_code=404, detail=f"Entity {chat_id} not found")
    
        dialog = dialogs[chat_id]
        unread_count = dialog["unread_count"]
    
        return await get_messages(chat_id=chat_id, count=unread_count)
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool retrieves unread messages but doesn't describe what 'unread' means in this context, whether there are pagination limits, authentication requirements, rate limits, or what format the messages are returned in. For a read operation with zero annotation coverage, this leaves significant behavioral gaps.

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, efficient sentence that directly states the tool's purpose without any wasted words. It's appropriately sized for a simple retrieval tool and front-loads the core functionality.

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?

For a tool with 1 parameter, 0% schema description coverage, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain the return format, error conditions, what 'unread' means operationally, or how this differs from similar sibling tools. The context demands more explanation than provided.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It mentions 'from a given entity id' which maps to the 'id' parameter, but doesn't explain what an 'entity' represents in this system, whether the ID refers to a user, group, or other entity type, or what happens if no ID is provided (since required parameters is 0). This adds minimal semantic value beyond the bare schema.

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 action ('get all unread messages') and target resource ('from a given entity id'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from sibling tools like 'get_messages' or 'get_unread_entities', which would require more differentiation to earn a 5.

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?

The description provides no guidance on when to use this tool versus alternatives like 'get_messages' or 'get_unread_entities'. It mentions the parameter ('from a given entity id') but doesn't explain when this specific unread-message retrieval is appropriate versus other message-related tools in the sibling list.

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/prem-research/telegram-mcp'

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