Skip to main content
Glama
telegram-mcp

telegram-mcp

by EyalWerber

telegram-mcp

Claude에게 한 Telegram 그룹의 최신 이미지를 전달합니다.

스크린샷은 봇이 게시하며, Telegram Bot API는 봇 자신의 메시지를 절대 반환하지 않습니다. 그래서 이 도구는 MTProto(Telethon)를 통해 사용자 계정으로 그룹을 읽습니다. 그 사진들을 보는 유일한 방법입니다.

설정 (1회)

  1. https://my.telegram.org → API development tools에서 api id와 hash를 받습니다.

  2. cp .env.example .env를 실행하고 TELEGRAM_API_ID, TELEGRAM_API_HASH, TELEGRAM_CHAT_ID(그룹의 숫자 ID, 음수)를 입력합니다.

  3. 환경을 생성합니다:

python -m venv .venv
.venv\Scripts\pip install -e .[dev]
  1. 로그인합니다 — Claude가 아닌 터미널에서:

.venv\Scripts\telegram-mcp-login

전화번호, Telegram이 보낸 코드, 그리고 2단계 인증 비밀번호가 있다면 그것을 묻고, session/telegram.session을 작성합니다.

또한 대화 목록을 한 번 나열하고 그룹 이름을 다시 출력합니다. 이 목록 덕분에 세션이 나중에 슈퍼그룹을 해석할 수 있습니다 -- 봇이 그룹에 합류하는 즉시 Telegram이 그룹을 슈퍼그룹으로 전환합니다 -- 그리고 그 이름은 TELEGRAM_CHAT_ID가 생각한 대상을 가리키는지 확인해 줍니다. 그룹을 찾을 수 없으면 그렇게 알리고 0이 아닌 코드로 종료합니다.

Related MCP server: image-relay-mcp

Claude에 설치

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

사용자 범위이므로 모든 프로젝트에서 사용할 수 있습니다.

도구

  • get_latest_image() — 그룹에서 가장 최근 사진, 200개 메시지를 거슬러 올라가 확인합니다.

  • wait_for_next_image(timeout_seconds=120) — 호출 시점보다 새로운 사진이 도착할 때까지 차단합니다. 대기에는 토큰이 들지 않습니다. 프로세스는 소켓에서 대기 상태로 있습니다. MCP 클라이언트의 도구 타임아웃 안에 머물도록 1~240초로 제한됩니다.

둘 다 이미지(JPEG, 긴 변 ≤1568px)와 텍스트 한 줄을 반환합니다: 먼저 수정되지 않은 원본의 경로, 그다음 메시지 ID, 타임스탬프, 보낸 사람, 그리고 인용된 캡션입니다. 축소 시 작은 글씨가 사라지면 원본을 잘라내세요.

한 번에 하나의 프로세스만 세션을 보유할 수 있습니다. 첫 번째 세션이 호출 중일 때 두 번째 Claude Code 세션이 도구를 호출하면 SQLite 오류를 받는 대신 잠시 후 다시 시도하라는 안내를 받습니다.

테스트

.venv\Scripts\python -m pytest

네트워크도 Telegram 계정도 필요 없습니다 — Telethon은 전체가 페이크 처리됩니다.

보안

session/telegram.session은 Telegram 계정에 대한 전체 로그인입니다. gitignore 처리되어 있으며 이 머신을 벗어나지 않습니다. 이 파일을 가진 사람은 누구나 메시지를 읽을 수 있습니다. 복사된 것으로 의심되면 삭제하고 로그인을 다시 실행하세요. 자격 증명은 .env에만 존재합니다 — 문서, 프롬프트, 티켓에는 절대 넣지 마세요.

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.

Maintenance

ActivityStale
ResponsivenessNo recent community issues

Related MCP Connectors

Related MCP Servers