telegram-mcp
Health Warn
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 5 GitHub stars
Code Fail
- network request — Outbound network request in src/agents/openai.ts
- exec() — Shell command execution in src/agents/types.ts
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
Сonnect your Claude/ChatGPT with Telegram
telegram-mcp
Connect Claude, ChatGPT or Codex to Telegram. Your assistant can send you updates and files, ask
questions with buttons, and find messages in chats you connect. You can also start an assistant
from Telegram itself.
Setup · Try it · Connect more chats ·
Start an assistant from Telegram · Scenes and memory
Setup
If you already have a bot and its connector URL, go to Connect your assistant.
Create and deploy your bot
Send
/newbotto @BotFather. Save the token and your bot's username.Deploy to Cloudflare. Enter the bot token as
BOT_TOKEN.Open your deployed Worker in a browser and follow the instructions on the page. In BotFather,
send/setdomain, choose your bot, and enter the Worker's hostname, for exampletelegram-mcp.<your-subdomain>.workers.dev. Telegram sign-in uses this hostname.Send
/startto your bot in Telegram. To restrict who can connect, copy the Telegram ID shown
there and add it asALLOWED_USER_IDSunder the Worker's Settings → Variables and Secrets
in Cloudflare. Separate multiple IDs with commas. An empty list lets anyone connect their own
account.
In the repository, create a local .env.deploy file containing BOT_TOKEN=your-token with the
token from BotFather. Run these commands, then continue with step 3 above.
bun install
bunx wrangler login
bun run deploy --secrets-file .env.deploy
Connect your assistant
Use your deployment's URL with the trailing slash, for examplehttps://telegram-mcp.<your-subdomain>.workers.dev/. When the assistant opens Telegram sign-in,
confirm your account and allow the bot to message you.
Claude and Cowork — go to Customize → Connectors → Add → Add custom connector. On
Team and Enterprise, ask an authorized admin to use Organization settings → Connectors →
Add → Custom → Web. Enter the URL, choose sign-in, and select Register automatically
if asked how to register the OAuth client. Find the connector under Customize →
Connectors, click Connect, and enable it in your conversation. See
Claude's connector guide.ChatGPT on the web — go to Plugins → + → Add custom MCP server. Enter the URL, choose
OAuth with automatic registration (DCR), and select Create as a plugin. Install it
and select it in your chat by typing@. If the option to add a server is missing, ask your
workspace admin about custom MCP permissions. See
ChatGPT's custom MCP guide.Claude Code — register the connector, then run
/mcpinside Claude Code to sign in.claude mcp add --transport http telegram "https://telegram-mcp.<your-subdomain>.workers.dev/"Codex — add the connector and sign in from your terminal.
codex mcp add telegram --url "https://telegram-mcp.<your-subdomain>.workers.dev/" codex mcp login telegram
After signing in, send /start to the bot again to open the full menu. You can now connect groups,
manage sign-ins, or choose which assistant answers in Telegram.
Try it
Ask your assistant to use Telegram in an ordinary prompt.
| What you want | Try asking |
|---|---|
| A message when you're away | “Ping me in Telegram when the build finishes.” |
| A decision from your phone | “Ask me in Telegram before deploying. Give me Deploy and Wait buttons.” |
| A file from the assistant | “Send the report to my Telegram.” |
| Help with something you sent | Send the bot a file, then ask “Summarize the PDF I just sent you in Telegram.” |
| A recap from a group | “Find the messages that tagged the bot in Design this week and summarize what needs my reply.” |
| A post for a group | “Make a Telegram poll in the Design group for Tuesday or Thursday.” |
You can also send photo albums, locations, formatted messages and, in your private chat with the
bot, live drafts and interactive widgets. Ask for a link to jump straight to a message.
Assistants with shell access can send files up to 50 MB (photos up to 10 MB) and open attachments
up to 20 MB. Other clients can send text and small files.
Use files in Claude
Claude reads attachments through the connector, but downloads them with curl from its own
sandbox, and that sandbox has its own network settings. If the download fails with403 CONNECT tunnel failed, the session is not allowed to reach your Worker. Allow all domains,
or add your Worker's hostname (telegram-mcp.<your-subdomain>.workers.dev) to the allowlist, then
ask Claude to fetch the attachment again: the old link may have expired (links last 15 minutes).
- claude.ai or Cowork — Settings → Capabilities → Code execution (Create and edit
files in the newer layout), then Allow network egress → All domains, or list your
hostname under Additional allowed domains. On Team and Enterprise an admin sets this in
Organization settings → Capabilities. Cowork picks the change up in a new session. See
code execution settings
and Cowork network access. - Claude Code on the web — in your environment at
claude.ai/code, set Network access
to Full, or to Limited with your hostname under Allowed domains (keep Allow
package managers on to keep the default list). See
cloud environment settings.
Some Team users report that Cowork still blocks domains they added
(report,
tracking issue).
Connect more chats
Groups
- In the bot's private chat, open /start → Connect a group and pick a group. If the bot
is already there, send/connect@YourBotUsernamein the group. - Ask your assistant to read or post in that group by name. You can also name a forum topic.
- Manage access from /start → Groups or
/groups. Each member connects or revokes
access for their own assistant.
If you want the bot to see regular group messages, disable privacy mode with/setprivacy in BotFather and re-add it to existing groups, or make it a group admin.
With privacy mode on, a non-admin bot sees commands, mentions and replies to it. The
Groups screen tells you how far back your assistant can read.
Personal chats
- In BotFather, open your bot's Bot Settings and enable Secretary Mode (formerly
Business Mode). - In Telegram, go to Settings → Telegram Business → Chatbots, add the bot, and select
the conversations to share. Connect your assistant before using them. - Give the bot the permissions you want it to have, such as replying, marking messages read or
deleting messages it sent. Replies go out in your name. Telegram allows replies within 24
hours of the other person's last message.
The assistant can read selected personal chats from the time you connect them. Removing the
bot from Chatbots deletes the personal chat history it stored.
Start an assistant from Telegram
You can also write directly to the bot and get an answer back in Telegram. Open /start →
Assistant, set up a provider, then select it to answer new messages.
- Claude — open Assistant → Claude and follow the instructions to create a
Claude Code routine. The bot gives you the prompt to
paste and asks for your routine's trigger ID and token in the private chat. Attach the
Telegram connector to the routine. - Codex — install the relay on your own Linux or macOS machine and sign in with your
ChatGPT account. Follow the Codex setup below. - OpenAI — open Assistant → OpenAI and send a project API key when the bot asks for it
in the private chat. The same screen picks the models, and Webhook reports failed sessions
to Telegram. Both the chat and its task sessions run in OpenAI's hosted container, so they
can run code there, billed to your API account. That includes sessions others start in your
groups. With Transcribe with OpenAI API on (the default), the assistant understands
your voice notes. It transcribes someone else's recording only when it reached it from you —
you forwarded it to the bot, or replied to it — and you asked. Recordings up to 20 MB go to
OpenAI's Audio API and are billed to your API account.
Choose where the assistant can reply.
- Private chat — write to the bot or forward a message with what you'd like it to do.
Use Here in the Assistant menu to turn replies on or off for this chat. - Group — open the group in the bot's Groups menu and turn on answering. Tag the bot
or reply to an assistant message. Others too allows other group members to start the
assistant. You can set their hourly limit and see starts in the group's menu. - Guest chat — turn on Guest Mode for your bot in BotFather. Tag the bot in a chat
it hasn't joined. It can see your mention and the message you replied to. Manage guest
chats and access for other members under Assistant → Guest chats.
Set up the relay
The relay runs as a systemd service on Linux, or as a LaunchAgent on macOS (it needs Homebrew
there; run the installer as the user logged in to the desktop). You have one relay per Telegram
account: installing a new one replaces the old one.
Keep a Claude conversation going
With the relay, a reply in Telegram goes into the same Claude Code cloud session instead of
starting a new one. Put it on a machine that is always on: open Assistant → Claude → Relay →
Install command, run the command there, sign in with claude and /login, and
restart the relay.
Codex on your machine
- In Telegram, open Assistant → Codex → Install command and run the command on your Linux
or macOS machine. - Sign in with
codex login. For sandboxed runs the login has to be in a file:codex -c 'cli_auth_credentials_store="file"' login. - Restart the relay. Once the bot shows Relay: online, select Use
Codex and send the bot a test message. The Codex screen sets the working directory and the
sandbox policy.
The Codex sandbox
Codex runs on your machine with your account, so the sandbox policy decides who gets a sandboxed
run: Others (the default) sandboxes whatever someone else stands behind, All sandboxes
everything, None nothing. A sandboxed run gets a directory of its own and can still reach the
network; it cannot read your files, keys or the relay's token. Linux uses
bubblewrap, macOS uses Seatbelt (sandbox-exec).
Before taking sandboxed jobs the relay checks that the sandbox actually holds, and refuses them if
it does not.
[!WARNING]
On macOS a sandboxed run can leave a process behind. When a job ends or times out, the relay
stops every process in the job's session. A program that detaches into a session of its own
(setsid, a double fork) is not found and keeps running after the job. It stays inside
Seatbelt — it still cannot read your files — but it keeps the network and the job's directory,
and for up to an hour the job's token, so it can still use the bot's tools as that session.
Someone who can start a sandboxed run, by default anyone you let call the assistant, could
leave such a process on purpose. Seatbelt also lets a run see file and folder names (not
contents) outside its directory. Linux has neither problem: the run's PID namespace ends with
it. If that matters for you, run the relay on Linux (a Linux VM on the Mac works), or do not let
other people start the assistant. Rebooting the Mac clears whatever was left.
Restart the relay
| Platform | Restart | Check logs |
|---|---|---|
| Linux | sudo systemctl restart tg-relay |
journalctl -u tg-relay -f |
| macOS | launchctl kill SIGTERM "gui/$(id -u)/dev.tg-relay" |
tail -F ~/.tg-relay/relay.log |
On macOS the relay keeps its own log: past 5 MB it moves to relay.log.1, replacing the one before.
Scenes and memory
Scenes
A scene is an interactive Telegram message that keeps working after the assistant leaves.
Ask the assistant to make a sign-up list, checklist, quiz, game or a panel with buttons. Try
“Make a sign-up in the Design group for Friday lunch, with Join and Leave buttons.”
Open /start → Scenes to see or stop running scenes. Saved scenes lets you start
one again in your private chat. Ready-made has tic-tac-toe and checkers. You can also
ask the assistant to start a game in a group. To stop them all, use Stop all scenes.
Memory
Ask your assistant to remember preferences or facts for a chat. For example, “Remember
that Design posts should be in English and keep our release checklist in this chat's
memory.” Your connected assistants share those notes. You get a private notice with
Undo when memory changes. Manage saved notes in /start → Memory. Use the chat's Trust
section to tell assistants who may use your resources or ask them to act for you.
Manage access and history
- Sign one assistant out in /start → Sign-ins, or all of them with
/disconnect. Running
scenes stop separately, with Stop all scenes. - The bot keeps what it receives for 30 days. Whoever deploys it can change that with
RETENTION_DAYS; a Wrangler deploy needs the value again each time, for examplebunx wrangler deploy --var RETENTION_DAYS:60. Run the Codex relay's installer again afterwards,
so it keeps sandbox sessions for as long. Saved scenes and memory are not part of it: they have
their own controls. - Whoever runs the deployment can read the messages and attachment details it stores. For chats
you want to keep to yourself, deploy your own.
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found