Read
telegram_messages“List the last five retained messages in chat <tg_channel_id>.”
Developer field guide
Give your coding assistant the thread behind the task. Search Telegram messages, read the conversation and keep the archive on your machine.
The release checklist is ready for review.
09:4101 / Installation
Start with one dedicated bot and one MCP client. The client launches the server when it connects.
With Node.js 24 active, run these commands in a terminal. The checks build the server and test it with synthetic messages.
git clone https://github.com/vladimirperepelytsia/tg2codexMCP.git
cd tg2codexMCP
npm ci
npm run check
cp -n .env.example .envCreate one dedicated bot with /newbot in @BotFather. Add that same bot to every channel you want to read. In your private .env, list their numeric chat IDs on one ALLOWED_CHAT_IDS line, separated by commas.
TELEGRAM_BOT_TOKEN=<your_bot_token>
ALLOWED_CHAT_IDS=<tg_channel_id>,<tg_channel_id>
DB_PATH=/absolute/private/path/connector.sqlite
ENABLE_SEND=falseThis example connects two channels. Replace each <tg_channel_id> with a different channel’s numeric ID, including its leading minus sign. For one channel, use just its ID. To add another later, give the bot access, append a comma and the new ID, then restart the MCP server.
Keep the example’s stdio and polling settings. Polling acknowledges updates, so use a bot without an active webhook or another poller.
For Codex, merge this into ~/.codex/config.toml. Use the Node 24 executable from command -v node and replace both project paths with the absolute path to your checkout.
[mcp_servers.telegram]
command = "/absolute/path/to/node"
args = [
"--env-file=/absolute/path/to/tg2codexMCP/.env",
"/absolute/path/to/tg2codexMCP/dist/src/main.js"
]
startup_timeout_sec = 20Open a new Codex session and inspect /mcp for the Telegram read tools. For another client, use its configuration example:
Use one shared HTTP process for the bot and database. Configure your private .env from the HTTP example, including a random read token of at least 32 characters. Launch it with npm start. Point each local client at http://127.0.0.1:8787/mcp with the same read token. Use the HTTP settings for your client.
02 / First read
With the server connected, post a new message your bot can see in the allowed chat. Use a distinctive phrase like “release checklist”, then ask your assistant to find it.
“Search chat <tg_channel_id> for ‘release checklist’. Show the matching message and its ID.”
Each search reads one channel. To verify several channels, post a test message in each and repeat the prompt with that channel’s numeric ID.
Check the chat ID and bot visibility. In a group with privacy mode enabled, try a command addressed to your bot. Search for its exact text after the server starts. Telegram provides pending or new updates, not the chat’s full history.
03 / Tool reference
Use these prompts in your client. Substitute your allowed chat ID and a message ID returned by a read.
telegram_messages“List the last five retained messages in chat <tg_channel_id>.”
telegram_search“Find messages containing ‘release’ in chat <tg_channel_id>. Include their IDs.”
telegram_context“Show the two messages on either side of that message ID in the same chat.”
The server retains allowed messages in SQLite for seven days by default. Text returned by a tool is shared with the client you choose. Sending is disabled by default. Security guide ↗
SDK tests cover stdio and HTTP. The individual client applications and live Telegram ingestion still await end-to-end verification. Claude Desktop manual configuration depends on version and policy. Verification matrix ↗