telegram-mcp
Minimal MCP server that enables sending Telegram messages via a bot, with HTML formatting and shared-secret authentication.
README
Telegram MCP Server for Claude Cowork
Minimal MCP server with a single tool: send_telegram_message.
No third-party intermediaries (Composio, etc.) — just your code, your bot, your server.
Step 1. Create a Bot in Telegram
- Open a chat with @BotFather in Telegram.
- Send
/newbot. - Provide a name (anything) and a username ending in
bot(for example, ``reminders_my_bot`). - BotFather will send a token like
123456789:AAHfiqksKZ8...— save it, this is yourTELEGRAM_BOT_TOKEN.
Step 2. Find Your chat_id
- Find your bot in Telegram by its username and send it any message (for example, "hello").
- Open in your browser (substitute your token):
https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/getUpdates - In the response, find
"chat":{"id": NUMBER, ...}— this is yourTELEGRAM_CHAT_ID.
Step 3. Create a Secret
Set any long random string — this is your MCP_SHARED_SECRET.
It secures the server: without it, no one (even if they find the URL) can send messages through your bot. You can generate one with:
openssl rand -hex 32
Step 4. Deploy the Server
The easiest options are Render.com (free tier available) or Railway.app. General steps for any of these platforms:
- Push this directory (
telegram-mcp/) to a GitHub repository (can be private). - On Render: New → Web Service → connect the repository.
- Build command:
npm install - Start command:
npm start
- Build command:
- In the Environment section, add three environment variables:
TELEGRAM_BOT_TOKEN= token from Step 1TELEGRAM_CHAT_ID= id from Step 2MCP_SHARED_SECRET= secret from Step 3
- Deploy. Render will give you a public URL like
https://telegram-mcp-xxxx.onrender.com. - Your MCP endpoint is
https://telegram-mcp-xxxx.onrender.com/mcp.
Note: Render's free tier "sleeps" after a period of inactivity and takes ~30 seconds to wake up on the first request. For a "once a week" task, this is not an issue.
Step 5. Connect to Claude
Customize→Connectors→+→Add custom connector.- Name:
Telegram Notify(or whatever you like). - Remote MCP server URL: put the secret straight into the path —
https://your-domain/mcp/<your MCP_SHARED_SECRET> - Leave the OAuth Client ID / Secret fields under Advanced settings empty — this server doesn't use OAuth.
- Click Add.
The server also accepts the secret as a header (Authorization: Bearer <MCP_SHARED_SECRET>
against https://your-domain/mcp), which is the cleaner option if your client can send
custom request headers. The connector dialog currently offers only OAuth fields, so the
URL-path form above is the one that works there.
The secret in the URL is as sensitive as a password: don't paste that URL into screenshots, issues, or chats. If it leaks, change
MCP_SHARED_SECRETin Render's Environment section and update the connector URL.
Step 6. Use in a Scheduled Task
In Cowork:
/schedule
and describe the task, for example:
Every Friday at 9:00 AM check [event source] and send me a short digest via send_telegram_message.
Before scheduling, test it manually with a one-off task to make sure the message actually arrives.
Topics (routing each automation to its own tab)
Each automation can post into its own topic. Two places can host those topics, and
the server code is identical for both — only TELEGRAM_CHAT_ID differs.
Option A — private chat with the bot ("Threaded Mode"). Added in Bot API 9.3
(2025-12-31): enable it via @BotFather → your bot → Threaded Mode, then create the
topics in the chat itself. TELEGRAM_CHAT_ID stays your personal chat id.
Between the Bot API 10.0 rollout (2026-05-08) and some point before 2026-08-07, sending with
message_thread_idto a private chat returned400: message thread not found— see tdlib/telegram-bot-api#847. Verified working again on 2026-08-07. If that error comes back, option B is unaffected by it.
Option B — forum supergroup. Unaffected by the above.
- Create a group, add your bot, promote it to admin.
- Group settings → Topics → on. Create one topic per automation.
- Set
TELEGRAM_CHAT_IDto the group id (looks like-1001234567890).
Getting the ids (either option): post a message in each topic, then open
https://api.telegram.org/bot<TOKEN>/getUpdates and read "chat":{"id": ...} and
"message_thread_id". In Telegram Desktop/Web you can instead copy a message link
from the topic — t.me/c/<chat>/<thread>/<message>.
Then add the map on Render:
TELEGRAM_TOPICS = {"events":2,"news":8,"jobs":14}
The tool exposes a topic parameter restricted to those names, so each scheduled
task states where its output belongs. Omitting it posts to General.
Invalid JSON or a non-integer id fails at startup rather than silently misrouting messages days later.
Message Formatting
Messages are parsed as Telegram HTML. The supported tags are:
<b>bold</b> <i>italic</i> <u>underline</u> <s>strikethrough</s>
<code>inline code</code> <pre>code block</pre>
<a href="https://example.com">link</a>
<blockquote>quote</blockquote> <tg-spoiler>hidden</tg-spoiler>
That's the whole list. There is no <br>, no headings, no <ul>/<li>, no tables —
use real newlines for line breaks and emoji or • for bullets. Literal <, >, &
in prose must be escaped as < > &.
HTML is used instead of MarkdownV2 because MarkdownV2 requires escaping over a dozen
characters (., -, !, (, ), …) and a single missed one rejects the message.
If the markup is invalid anyway, the server retries once without parsing so the text
still arrives — unformatted, with a note in the tool result. Pass plain: true to skip
parsing deliberately (useful when the body contains raw angle brackets).
Link previews are disabled, so a message with a URL stays a one-liner.
Local Launch (for testing)
npm install
TELEGRAM_BOT_TOKEN=xxx TELEGRAM_CHAT_ID=xxx MCP_SHARED_SECRET=xxx npm start
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.