Skip to main content
Glama
telegram-mcp

telegram-mcp

by EyalWerber

telegram-mcp

Reicht Claude das neueste Bild aus einer Telegram-Gruppe.

Die Screenshots werden von einem Bot gepostet, und die Telegram Bot API gibt niemals die eigenen Nachrichten eines Bots zurück – daher liest dieses Tool die Gruppe mit einem BenutzerKonto über MTProto (Telethon). Das ist der einzige Weg, diese Fotos zu sehen.

Einrichtung (einmalig)

  1. Holen Sie sich eine API-ID und einen Hash von https://my.telegram.org → API-Entwicklungstools.

  2. cp .env.example .env und füllen Sie TELEGRAM_API_ID, TELEGRAM_API_HASH und TELEGRAM_CHAT_ID aus (die numerische ID der Gruppe, negativ).

  3. Erstellen Sie die Umgebung:

python -m venv .venv
.venv\Scripts\pip install -e .[dev]
  1. Melden Sie sich an – in einem Terminal, nicht über Claude:

.venv\Scripts\telegram-mcp-login

Es fragt nach Ihrer Telefonnummer, dem Code, den Telegram sendet, und Ihrem Zwei-Faktor-Passwort, falls Sie eines haben, und schreibt dann session/telegram.session.

Es listet auch einmal Ihre Dialoge auf und gibt Ihnen den Namen der Gruppe aus. Die Auflistung ermöglicht es der Sitzung, später eine Supergruppe aufzulösen – Telegram verwandelt eine Gruppe in eine solche, sobald ein Bot beitritt – und der Name ist Ihre Bestätigung, dass TELEGRAM_CHAT_ID dorthin zeigt, wo Sie es vermuten. Wenn es die Gruppe nicht finden kann, sagt es das und beendet sich mit einem Exit-Code ungleich Null.

Related MCP server: image-relay-mcp

Installation in Claude

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

Benutzerbereich, sodass jedes Projekt es erhält.

Werkzeuge

  • get_latest_image() – das neueste Foto in der Gruppe, das die letzten 200 Nachrichten durchsucht.

  • wait_for_next_image(timeout_seconds=120) – blockiert, bis ein Foto ankommt, das neuer ist als der Zeitpunkt des Aufrufs. Warten kostet keine Tokens; der Prozess wartet auf einem Socket. Auf 1–240 s begrenzt, um innerhalb des Tool-Timeout des MCP-Clients zu bleiben.

Beide geben das Bild (JPEG, lange Kante ≤1568 px) plus eine Textzeile zurück: zuerst den Pfad zum unveränderten Original, dann die Nachrichten-ID, den Zeitstempel, den Absender und die Bildunterschrift, in Anführungszeichen. Beschneiden Sie das Original, wenn die Verkleinerung feine Details verliert.

Nur ein Prozess kann die Sitzung gleichzeitig halten. Eine zweite Claude Code-Sitzung, die ein Tool aufruft, während die erste mitten im Aufruf ist, wird gebeten, es in einem Moment erneut zu versuchen, anstatt einen SQLite-Fehler zu erhalten.

Tests

.venv\Scripts\python -m pytest

Kein Netzwerk, kein Telegram-Konto erforderlich – Telethon wird durchgehend simuliert.

Sicherheit

session/telegram.session ist ein vollständiger Login zu Ihrem Telegram-Konto. Es ist gitignored und verlässt diesen Rechner nie. Jeder, der diese Datei besitzt, kann Ihre Nachrichten lesen; löschen Sie sie und führen Sie den Login erneut aus, wenn Sie vermuten, dass sie kopiert wurde. Anmeldedaten befinden sich nur in .env – niemals in Dokumenten, Prompts oder 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.

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.

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.

Related MCP Connectors

Related MCP Servers