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
| Name | Required | Description | Default |
|---|---|---|---|
| id | No |
Implementation Reference
- mcp-server/mcp-server.py:20-23 (registration)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", )
- mcp-server/mcp-server.py:24-25 (handler)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-server/http-api.py:46-56 (handler)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)