mcp-telegram-claudecode
Enables interaction with Telegram, allowing Claude Code to send messages and photos, retrieve messages, and approve sensitive operations remotely.
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., "@mcp-telegram-claudecode Send a Telegram notification when the task completes."
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.
MCP-Telegram-ClaudeCode
An MCP (Model Context Protocol) server that enables Claude Code to send and receive messages via Telegram. This allows you to interact with Claude Code remotely through your Telegram app.
Features
Send text messages from Claude Code to Telegram
Receive messages from Telegram in Claude Code
Send photos/screenshots to Telegram
Proxy support for regions where Telegram is blocked
NEW: Remote permission approval via hooks - Approve/deny sensitive operations from your phone
NEW: Lock file mechanism - Prevents multiple instance conflicts
Related MCP server: telegram-ask-mcp
Prerequisites
Node.js 18.0.0 or higher
Claude Code installed
A Telegram account
Quick Start
Step 1: Create a Telegram Bot
Open Telegram and search for @BotFather
Send
/newbotcommandFollow the prompts to name your bot
Save the bot token - it looks like:
1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
Step 2: Get Your Chat ID
Open Telegram and search for @userinfobot
Send any message to this bot
Save the
Idvalue from the response - it looks like:123456789
Step 3: Start Your Bot
Important: Before Claude Code can receive your messages, you must start a conversation with your bot:
Search for your bot by its username in Telegram
Click "Start" or send any message to it
Step 4: Configure Claude Code
Add the MCP server to your Claude Code configuration.
Option A: Using Claude Code settings command
claude /settingsThen add the MCP server configuration.
Option B: Edit configuration file directly
The configuration file is located at:
Windows:
%USERPROFILE%\.claude.jsonmacOS/Linux:
~/.claude.json
Configuration Examples
Without Proxy
If you can access Telegram directly:
{
"mcpServers": {
"telegram": {
"command": "npx",
"args": ["-y", "mcp-telegram-claudecode"],
"env": {
"TELEGRAM_BOT_TOKEN": "1234567890:ABCdefGHIjklMNOpqrsTUVwxyz",
"TELEGRAM_CHAT_ID": "123456789"
}
}
}
}With Proxy
If you need a proxy to access Telegram:
{
"mcpServers": {
"telegram": {
"command": "npx",
"args": ["-y", "mcp-telegram-claudecode"],
"env": {
"TELEGRAM_BOT_TOKEN": "1234567890:ABCdefGHIjklMNOpqrsTUVwxyz",
"TELEGRAM_CHAT_ID": "123456789",
"HTTP_PROXY": "http://127.0.0.1:7890"
}
}
}
}Common proxy ports:
Clash:
http://127.0.0.1:7890V2Ray:
http://127.0.0.1:10808Shadowsocks:
http://127.0.0.1:1080
Replace with your actual proxy address and port.
Environment Variables
Variable | Required | Description |
| Yes | Bot token from @BotFather |
| Yes | Your chat ID from @userinfobot |
| No | HTTP proxy URL (e.g., |
| No | HTTPS proxy URL (alternative to HTTP_PROXY) |
Available Tools
Once configured, Claude Code will have access to these tools:
telegram_send_message
Send a text message to your Telegram.
Parameters:
- message (required): The text message to sendtelegram_get_messages
Retrieve recent messages from Telegram.
Parameters:
- limit (optional): Maximum number of messages to retrieve (default: 10)telegram_check_new
Quick check if there are new messages.
No parameters requiredtelegram_send_photo
Send an image file to Telegram.
Parameters:
- photo_path (required): Absolute path to the image file
- caption (optional): Caption for the photoUsage Examples
After configuration, you can ask Claude Code to:
"Send me a message on Telegram saying the task is complete"
"Check if I sent any new messages on Telegram"
"Send a screenshot of the current code to my Telegram"
Troubleshooting
"TELEGRAM_BOT_TOKEN must be configured"
Make sure you've added the bot token to your .claude.json configuration.
"No new messages" but you sent messages
Make sure you started a conversation with your bot first
Check that your
TELEGRAM_CHAT_IDis correctIf using a proxy, verify the proxy is working
Connection timeout or network error
If you're in a region where Telegram is blocked:
Make sure your proxy software is running
Add the
HTTP_PROXYenvironment variable to your configurationVerify the proxy port is correct
Bot not responding
Check that the bot token is correct (no extra spaces)
Make sure you've started a conversation with your bot
Try sending a message to your bot first, then check for messages
Remote Permission Approval (Recommended)
Instead of using --dangerously-skip-permissions, you can use Claude Code hooks to approve sensitive operations remotely via Telegram.
How It Works
┌─────────────┐ PreToolUse Hook ┌─────────────────┐ Telegram API ┌──────────┐
│ Claude Code │ ──────────────────────► │ Hook Script │ ◄─────────────────► │ Telegram │
│ (sensitive │ │ (asks approval) │ │ (you) │
│ operation) │ ◄────────────────────── │ │ │ │
└─────────────┘ approve/deny └─────────────────┘ └──────────┘Claude Code attempts a sensitive operation (Edit, Write, Bash)
PreToolUse hook sends details to your Telegram
You reply Y to approve or N to deny
Hook returns the decision to Claude Code
Setup
Copy the hooks to your system (included in
hooks/directory)Configure Claude Code hooks via
/hookscommand or edit settings:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash|Edit|Write",
"hooks": [
"node /path/to/telegram-claude-mcp/hooks/pretool-approval.js"
]
}
]
}
}Set environment variables (same as MCP server config)
See hooks/README.md for detailed setup instructions.
Approval Responses
Approve | Deny |
Y, yes, 1, approve | N, no, 0, deny |
是, 好, 可以 | 否, 不, 拒绝 |
How It Works
Architecture
This MCP server acts as a bridge between Claude Code and Telegram:
┌─────────────┐ MCP Protocol ┌─────────────────┐ Telegram API ┌──────────┐
│ Claude Code │ ◄──────────────────► │ MCP Server │ ◄─────────────────► │ Telegram │
│ │ │ (this project) │ │ │
└─────────────┘ └─────────────────┘ └──────────┘Auto-Polling & Terminal Injection (Experimental)
When the MCP server starts, it automatically begins polling for new Telegram messages. When a message is received, it attempts to inject the text into the active terminal window using:
Clipboard: Message is copied to system clipboard
SendKeys (Windows): PowerShell script simulates Ctrl+V and Enter keystrokes
Window Activation: Attempts to find and activate terminal windows (Windows Terminal, cmd, PowerShell, VS Code)
This is an experimental feature - it enables "remote control" of Claude Code via Telegram, but has reliability limitations.
Tools Available
Tool | Description |
| Send text to Telegram |
| Retrieve recent messages |
| Quick check for new messages |
| Send images to Telegram |
| Manually start auto-polling |
| Stop auto-polling |
Known Issues & Limitations
✅ Multiple Claude Code Instances (Fixed in v1.4.0)
Problem: If you run multiple Claude Code windows, each will start its own MCP server instance.
Solution: Lock file mechanism now prevents multiple instances from polling simultaneously. Only the first instance will poll; others will skip polling automatically.
✅ Injection Failure Notification (Fixed in v1.4.0)
Problem: When SendKeys injection fails, you wouldn't know about it.
Solution: Failed injections now send a notification to Telegram, so you know when to check manually.
✅ Permission Prompts (Solved with Hooks)
Problem: Cannot approve sensitive operations remotely.
Solution: Use the included PreToolUse hooks for remote approval via Telegram. See Remote Permission Approval section.
⚠️ SendKeys Reliability (Windows)
The terminal injection feature uses WriteConsoleInput API for no-focus injection:
How it works:
Uses Windows Console API to write directly to the console input buffer
Does not require window focus
Does not use clipboard
Works when other applications are active
Limitation - Single Terminal Only:
Works correctly when only one terminal window is open
If multiple terminals are open, messages may go to the wrong terminal
This is due to Windows Terminal's ConPTY architecture
When it may fail:
Multiple terminal windows open simultaneously
Remote desktop or virtual machine environments
Screen is locked
Workaround: Use hooks instead of SendKeys for more reliable operation, or ensure only one terminal is open.
⚠️ Platform Support
Platform | MCP Tools | Auto-Injection | Hooks |
Windows | ✅ Full | ✅ SendKeys | ✅ Full |
macOS | ✅ Full | ❌ Not implemented | ✅ Full |
Linux | ✅ Full | ❌ Not implemented | ✅ Full |
Recommendation: Use hooks for cross-platform remote control.
Changelog
v1.4.0
✅ Added lock file mechanism to prevent multiple instance conflicts
✅ Added injection failure notifications via Telegram
✅ Added PreToolUse hook for remote permission approval
✅ Added PostToolUse hook for error notifications
✅ Improved terminal injection with WriteConsoleInput API (no focus required)
✅ Improved exit cleanup (SIGINT/SIGTERM handling)
⚠️ Known limitation: Single terminal mode only (multiple terminals may cause injection to wrong window)
v1.3.0
Added photo sending support
Added proxy support
v1.2.0
Added auto-polling and terminal injection
v1.1.0
Added telegram_check_new tool
v1.0.0
Initial release
License
MIT License - see LICENSE file for details.
Author
EthanSky
Repository
Available Tools
8 toolstelegram_check_newA
Quick check if there are new messages from Telegram without retrieving all of them.
Inputs: no named parameters.
telegram_get_messagesA
Get recent messages from Telegram. Use this to check for new messages from the user.
Inputs: limit.
telegram_send_documentA
Send any file/document to the configured Telegram chat. Use this for files that are not photos or videos (e.g., zip, pdf, txt, etc.). Max file size: 50MB.
Inputs: document_path (required), caption.
telegram_send_messageA
Send a text message to the configured Telegram chat. IMPORTANT: You MUST use this tool to reply to the user regardless of whether they sent their message via terminal or Telegram. Always respond through Telegram so the user can see your replies on their phone.
Inputs: message (required).
telegram_send_photoB
Send a photo/image to the configured Telegram chat.
Inputs: photo_path (required), caption.
telegram_send_videoA
Send a video file to the configured Telegram chat. Supports mp4, mov, avi and other video formats. Max file size: 50MB.
Inputs: video_path (required), caption.
telegram_start_pollingA
Manually start auto-polling for Telegram messages (polling starts automatically on MCP load, so this is usually not needed). When enabled, new messages will be automatically injected into the terminal as user input.
Inputs: interval.
telegram_stop_pollingA
Stop auto-polling for Telegram messages.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
The tools are mostly distinct: send_message, send_photo, send_video, and send_document are clearly separated by content type, and start/stop_polling are unique. However, get_messages and check_new could cause slight confusion, as both relate to retrieving new messages, though their descriptions differentiate by urgency and scope.
All tools follow a consistent telegram_ + verb_noun pattern (send_message, get_messages, send_photo, start_polling). The only slight deviation is telegram_check_new, where 'new' is an adjective rather than a noun, but it remains understandable and consistent with the overall style.
With 8 tools, the server is well-scoped for its purpose: messaging, media sending, message retrieval, and polling control. Each tool serves a distinct function without redundancy.
The tool set covers the core Telegram operations needed for a Claude Code integration: sending text, photos, videos, documents, retrieving messages, and managing polling. Missing features like editing or deleting messages are not critical for this use case.
Maintenance
Related MCP Connectors
Your Telegram, WhatsApp, Instagram, mail and calendar in Claude or ChatGPT. Never sends messages.
Let AI assistants post to your Telegram chats, groups and channels. Not affiliated with Telegram.
Send AI results to Telegram as private notifications or channel posts. No copy-pasting - connect your Telegram account and publish directly from AI assistants.
Run a Telegram channel from your AI agent. Posts go out through your own bot, not your account.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables Claude Code to send messages to and receive instructions from Telegram, with task tracking and persistent storage.-
- AlicenseAqualityDmaintenanceEnables Claude to send questions via Telegram and receive answers from your phone, bypassing terminal popups.3MIT
- FlicenseAqualityDmaintenanceEnables Claude to send and manage Telegram messages through a bot, supporting remote deployment for scheduled automations.10-
- AlicenseAqualityCmaintenanceEnables Claude to send Telegram messages through your own bot for notifications, such as routine summaries, long-running task completions, and issue alerts.11MIT