Skip to main content
Glama
EyalWerber

telegram-mcp

by EyalWerber

telegram-mcp

Hands Claude the newest image from one Telegram group.

The screenshots are posted by a bot, and the Telegram Bot API never returns a bot's own messages — so this reads the group with a user account over MTProto (Telethon). That is the only way to see those photos.

Setup (once)

  1. Get an api id and hash from https://my.telegram.org → API development tools.

  2. cp .env.example .env and fill in TELEGRAM_API_ID, TELEGRAM_API_HASH, and TELEGRAM_CHAT_ID (the group's numeric id, negative).

  3. Create the environment:

    python -m venv .venv
    .venv\Scripts\pip install -e .[dev]
  4. Sign in — in a terminal, not through Claude:

    .venv\Scripts\telegram-mcp-login

    It asks for your phone number, the code Telegram sends, and your two-factor password if you have one, then writes session/telegram.session.

    It also lists your dialogs once and prints the group's name back at you. The listing is what lets the session resolve a supergroup later -- Telegram turns a group into one as soon as a bot joins it -- and the name is your confirmation that TELEGRAM_CHAT_ID points where you think it does. If it cannot find the group, it says so and exits non-zero.

Related MCP server: telegram-user-mcp

Install into Claude

claude mcp add --scope user telegram -- <abs path>\.venv\Scripts\python -m telegram_mcp.server

User scope, so every project gets it.

Tools

  • get_latest_image() — the most recent photo in the group, looking back 200 messages.

  • wait_for_next_image(timeout_seconds=120) — blocks until a photo newer than the moment of the call arrives. Waiting costs no tokens; the process idles on a socket. Clamped to 1–240 s to stay inside the MCP client's tool timeout.

Both return the image (JPEG, long edge ≤1568 px) plus a line of text: the path to the untouched original first, then the message id, timestamp, sender, and the caption, quoted. Crop that original when the downscale loses fine print.

Only one process can hold the session at a time. A second Claude Code session calling a tool while the first is mid-call is told to try again in a moment, rather than being handed a SQLite error.

Tests

.venv\Scripts\python -m pytest

No network, no Telegram account needed — Telethon is faked throughout.

Security

session/telegram.session is a full login to your Telegram account. It is gitignored and never leaves this machine. Anyone holding that file can read your messages; delete it and re-run the login if you suspect it has been copied. Credentials live only in .env — never in docs, prompts, or tickets.

Available Tools

2 tools
get_latest_imageA

Return the most recent image posted in the configured Telegram group.

Use this when the user says they have just sent a screenshot. It looks back over the last 200 messages for one carrying a photo and returns it together with the path to the full-resolution original — crop that file if you need to read fine print the downscaled copy blurred.

Returns a sentence explaining what to fix if the group is unreachable, the session has expired, or no photo is in range.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses that it scans the last 200 messages, returns a downscaled photo along with the path to the full-resolution original, and provides an error sentence for unreachable group, expired session, or no photo. This gives agents a clear picture of behavior beyond the schema.

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

Conciseness4/5

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

The description is a bit long but each paragraph serves a purpose: primary action, usage guidance, and error handling. It is front-loaded with the main action and each sentence adds value, though it could be slightly more concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter tool with no output schema and no annotations, the description covers the what, when, return value, and failure modes. It doesn't specify the exact success return format, but it mentions the image and path to the original, which is sufficient for an agent to use correctly.

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

Parameters4/5

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

There are zero parameters, so the schema already covers everything. The description mentions a 'configured Telegram group' implying external context, but no parameter explanation is needed. The baseline for no parameters is 4, and the description doesn't introduce any confusion.

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 tool's action: 'Return the most recent image posted in the configured Telegram group.' It uses a specific verb and resource, and implicitly distinguishes from the sibling wait_for_next_image by focusing on 'most recent' rather than awaiting new ones.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit when-to-use guidance: 'Use this when the user says they have just sent a screenshot.' It also explains the lookback window (last 200 messages) and advises cropping for fine print. It doesn't explicitly name the alternative tool, but the context implies when not to use it (waiting for a new image).

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

wait_for_next_imageA

Blocks until a new image is posted to the group, then returns it.

Use this when the user is about to send a screenshot. It notes the group's newest message when the call starts and returns the first photo after that, so it never hands back something you have already seen in this call.

Args: timeout_seconds: how long to wait, clamped to 1-240 seconds.

Waiting costs no tokens -- the process idles on a socket. If nothing arrives it returns a sentence saying so; call it again to keep waiting.

ParametersJSON Schema
NameRequiredDescriptionDefault
timeout_secondsNo

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It does so thoroughly: it blocks, notes the newest message at call start, returns only the first photo after that, guarantees no duplicate images from prior calls, costs no tokens (idles on a socket), clamps the timeout to 1-240 seconds, and describes the no-result behavior ('returns a sentence saying so'). These are non-obvious, valuable behavioral details that an agent needs to use the tool correctly.

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 succinct yet complete, using a clear structure: purpose, usage, and behavior. It front-loads the primary function, then adds usage context, then details the parameter and behavioral notes. Every sentence adds value; there is no fluff or redundancy. It is appropriately sized for a tool with a single parameter and no output schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple (one optional param, no output schema), and the description covers all essential aspects: what it does, when to use it, how the timeout works, the blocking/token behavior, and what it returns (both success and no-result cases). No critical information is missing for an agent to call it correctly. The absence of an output schema is mitigated by the explicit description of the return value.

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

Parameters5/5

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

The schema has only one parameter, timeout_seconds, and the schema provides no description (coverage 0%). The description compensates fully by explaining 'how long to wait' and adding the constraint 'clamped to 1-240 seconds.' This goes beyond the raw schema (which only shows a default of 120) and gives the agent complete understanding of the parameter's meaning and bounds.

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 opens with a specific verb and resource: 'Blocks until a new image is posted to the group, then returns it.' It immediately clarifies the distinct semantics (waits for a new image rather than returning the latest), and explicitly states it 'never hands back something you have already seen in this call,' which distinguishes it from the sibling get_latest_image. The purpose is unambiguous and precisely scoped.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides a concrete usage context: 'Use this when the user is about to send a screenshot.' It also explains that it can be called again to keep waiting. However, it does not explicitly mention the sibling tool or state when not to use this tool versus get_latest_image. The guidance is clear for the primary scenario but lacks explicit exclusion or alternative routing.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv0.1.0
    • First observedget_latest_image
    • First observedwait_for_next_image

TDQS

A4.4/5.0

Scored across 2 tools

Disambiguation5/5

The two tools are clearly distinct: get_latest_image retrieves a previously posted photo, while wait_for_next_image blocks for a new one. The use cases do not overlap in an ambiguous way.

Naming Consistency4/5

Both names follow a verb-noun structure and clearly communicate function. The slight mix of 'get_' and 'wait_for_' is a minor deviation but still predictable.

Tool Count3/5

Two tools is at the low end of a reasonable scope for a narrow image-receiving server. They cover the core need without bloat, but the server feels rather thin.

Completeness4/5

The pair covers the two key workflows: retrieving a previous screenshot and waiting for a new one. Missing features like explicit image search or sending could be useful, but they are not essential for the server's obvious intent.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    Integrates Telegram user account with MCP, exposing operations like reading and sending messages, managing chats, and more via stdio or SSE transport.
    Apache 2.0
  • A
    license
    A
    quality
    B
    maintenance
    Enables reading chats, messages, and media and sending messages/files via a Telegram user account (MTProto/Telethon), supporting group history and media that bots cannot access.
    8
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Enables use of a personal Telegram account within MCP clients for reading and sending messages, searching chats, and managing media, all running locally.
    16
    7 npm
    MIT