tg2codexMCP
Provides tools for reading and searching messages received by a Telegram bot, retrieving message context with neighboring messages, and optionally sending allowlisted messages with idempotency controls.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@tg2codexMCPshow me the last 20 messages from my Telegram bot chat"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
tg2codexMCP
A standalone Telegram MCP server for Codex, Cursor, Gemini CLI, Claude Code and Claude Desktop. It reads bot-received updates directly from the Telegram Bot API, retains a bounded local copy, and exposes tools for message retrieval, context, search and optional controlled sends. No n8n, workflow platform, LLM API or dot is required. The connected client performs analysis using its own model.
Status: locally tested implementation, not a live integration certification. The official MCP SDK client passes stdio and Streamable HTTP integration tests. Client-specific setup is based on official documentation; the five applications have not been configured or exercised against a live bot. See the verification matrix.
Quick start
Requires Node.js 24.x and npm. Build and test without credentials:
npm ci
npm run checkAfter approving use of a dedicated bot, copy .env.example to ignored .env, supply the bot token and allowed chat IDs, and set an absolute private DB_PATH. Keep sending disabled initially. Configure one client using an example and the client instructions. Each example launches Node directly; do not use npm start as the client's stdio command because npm can write non-protocol output to stdout.
The default is MCP_TRANSPORT=stdio and INGESTION_MODE=polling. The client starts/stops the process. INGESTION_MODE=offline reads retained data with no polling; an offline template needs no secrets. Polling starts on process launch and acknowledges Telegram updates, so do not enable it casually for a bot used elsewhere.
For multiple clients at once, run one HTTP connector with the HTTP template, then connect clients to http://127.0.0.1:8787/mcp with the configured bearer token. npm start is suitable for that foreground HTTP process. Never run several polling processes for the same bot, even with different databases. A database lock prevents accidental concurrent use of the same database.
Related MCP server: telegram-mcp-bridge
Tools
Tool | Behavior |
| Newest retained messages in one allowed chat; keyset pagination |
| Literal substring search within one allowed chat |
| One retained message and bounded neighboring messages |
| Optional, explicitly enabled, allowlisted send with durable idempotency |
Read tools work independently of event subscriptions. Text is marked as untrusted data. Sends require ENABLE_SEND=true, a bot token, SEND_CHAT_IDS, confirmed=true and an idempotency key. HTTP also requires a separate send bearer credential. For stdio, access is granted by explicitly enabling writes for the locally launched process. Keep the host client's approval prompts enabled.
Ingestion and transports
Direct long polling checks
getMeandgetWebhookInfo, then callsgetUpdates. It never sets/deletes a webhook. An active webhook, authentication failure or polling conflict stops the service with a sanitized error.SQLite persists messages, edits, the polling checkpoint, optional event subscriptions/outbox and send results. Message storage and checkpoint advancement commit together. Disallowed-chat contents are discarded before retention.
Standard MCP tools support legacy 2025 initialization and MCP 2 (
2026-07-28) over stdio and Streamable HTTP through the official SDK. Legacy SSE-only endpoints are not implemented.Dot-specific webhook Events are an optional, disabled-by-default HTTP extension. They are not advertised to legacy clients. Ordinary clients discover tools without Events, callbacks or signing secrets.
Scope and limits
One configured owner and one bot per database; no personal-account login or complete historical archive. This receives only updates Telegram delivers to the bot. Text/captions and edits are retained; media download, deleted-message synchronization and topic filtering are not implemented. Retention defaults to seven days. Search has SQLite's ASCII case folding, not full Unicode normalization.
A standalone client gets tools, not an automatic background task in its conversation. Generic cross-client wake-ups are not implemented. Optional Events require a compatible client and separate live verification. HTTP is loopback-only with static bearer auth; public OAuth/multi-user deployment remains future work.
Read architecture, direct Telegram setup, security, operations and roadmap. Existing signed adapter ingress remains opt-in for advanced integrations; it is not used by the standalone setup.
License
Apache License 2.0, preserved from the original repository. Package publication is disabled by private: true; this does not change the source license.
This server cannot be deployed
Maintenance
Related MCP Connectors
Unofficial Telegram MCP server — read, search, reply and react in your own Telegram account.
Search, read and reply to your Telegram Business chats, transcribed voice included.
Hosted MCP messaging across owners, tools, and machines, with readable transcripts.
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables users to read, search, and manage Telegram messages in channels, groups, and private chats through MCP tools.8MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients like Codex or ChatGPT to securely receive, acknowledge, and send Telegram messages with durable delivery guarantees and idempotency.MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to read allowlisted Telegram chats and send messages as a bot, with access control, local secrets, and duplicate send protection.1MIT
- AlicenseAqualityAmaintenanceControlled Telegram Bot API bridge for any MCP host (stdio). Deny-by-default chat allowlist, outbound scrubbing, token redaction in logs, rate limits and untrusted-input labeling. Also usable as a plain Python library (TelegramBridge). The agent owns the logic; the bridge handles Telegram I/O.6320 PyPIMIT