Telegram MCP Server using Telethon and MTProto protocol for interacting with Telegram
Telegram-mcp has 4 tools with explicit schemas and descriptions, but significant quality gaps limit production readiness. Tool naming is verb-based (telegram_*), which is good, but descriptions lack actionable context for LLM selection. telegram_execute_code is particularly risky, it accepts arbitrary Python with no input validation, timeout enforcement, or sandbox isolation. Parameters are typed but many lack constraints (enums, ranges). Error handling is minimal; most tools return raw exceptions rather than recovery guidance. No tool annotations (readOnlyHint/destructiveHint) despite clear risk profiles. Output schemas are undocumented, LLMs cannot predict response structure for chaining. The server provides no pagination, rate-limit guidance, or idempotency guarantees.
Executes arbitrary custom asynchronous Python code with direct access to the live Telethon client and MTProto API. Available pre-injected variables: - `client`: Authenticated Telethon TelegramClient instance (e.g. `await client.get_dialogs()`, `await client(...)`) - `service` / `telegram_service`: The TelegramService instance - `events`: telethon.events - `functions`: telethon.tl.functions (raw MTProto functions) - `types`: telethon.tl.types (raw MTProto types) - `asyncio`, `json`, `os`, `time` Stdout/stderr and return values are captured and returned in the JSON result.
Sends a bot command (e.g. /start, /help, /settings) to the target bot and optionally waits for response.
Sends a text message or payload to the target bot or chat. Supports Markdown ('md') or HTML ('html') formatting. Use topic_id to route directly into a supergroup forum topic.
Checks the current Telegram connection state, session validity, and environment configuration. Call this first to diagnose auth issues before using other tools.
telegram_execute_code accepts arbitrary Python code with no input validation, sandboxing, or injection protection. LLMs can be tricked into executing malicious payloads. No dry-run or confirmation step for irreversible operations.
No tool annotations (readOnlyHint, destructiveHint, idempotentHint) despite clear risk profiles. telegram_execute_code and telegram_send_* are destructive; telegram_status is read-only. LLMs cannot infer safety without explicit hints.
Output schemas are not documented. LLMs cannot predict response structure (e.g., does telegram_send_message return message_id, timestamp, status?). Breaks tool chaining and forces guessing.
| Scored | Grade | Overall | Spec posture | Rubric |
|---|---|---|---|---|
| 2026-09-23 | D | 57 | 2026-07-28+ | v2 |
Parameters lack constraints. bot_username accepts any string (should validate Telegram username format). parse_mode has no enum (should be ['md', 'html']). timeout_seconds unbounded (should be 1-300). LLMs will pass invalid values.
Error handling returns raw exceptions without recovery guidance. E.g., 'AuthKeyDuplicated' error in telegram_status includes a recovery hint, but telegram_send_* tools do not. Inconsistent error classification (retryable vs fatal) across tools.