Makes it simple to use the Telegram bridge MCP server in multiple Claude projects with minimal configuration. New Features: - Auto-generate MCP config: `pnpm config` - List available tools: `pnpm tools` - Multi-project setup guide (SETUP-FOR-OTHER-PROJECTS.md) - MCP config template (.claude-mcp-template.json) - Helper scripts for config generation Changes: - Added scripts/get-mcp-config.sh - Auto-generates MCP config with correct paths - Added scripts/list-tools.js - Lists all 5 MCP tools with descriptions - Added SETUP-FOR-OTHER-PROJECTS.md - Guide for using in multiple projects - Updated README with easier setup options - Added npm scripts: `tools` and `config` Now you can: 1. Install bridge once 2. Run `pnpm config` to get MCP config 3. Copy to any project's .claude/mcp.json 4. Use Telegram tools in that project! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
11 KiB
Claude Telegram Bridge
MCP Server for Two-Way Communication with Telegram
This is a proper Model Context Protocol (MCP) server that enables any Claude instance to communicate with you via Telegram. Just grant Claude access to this MCP server, and it can send notifications, ask questions, and receive messages from you in real-time!
Free to use, share, and modify! See LICENSE for details.
Why This Exists
After trying email, SMS, and Google Chat integrations, Telegram emerged as the best solution for:
- ✅ Standardized MCP Integration - Works with any Claude instance automatically
- ✅ Instant two-way communication
- ✅ Free and reliable
- ✅ Works on all devices
- ✅ Simple setup
- ✅ No carrier dependencies
Features
- 💬 Two-Way Communication - Send messages to Claude, get responses back
- ❓ Question/Answer Flow - Claude can ask you questions and wait for answers
- 📬 Message Queue - Messages queue up when Claude is busy, get answered ASAP
- 🔔 Priority Notifications - Different icons for info, success, warning, error, question
- 🌐 HTTP API - Easy integration from any app/project
- 🚀 Background Service - Runs independently, always available
- 🔧 MCP Protocol - Works as a standard MCP server in any Claude project
Using in Other Projects
Already have the bridge installed? Just add this to your project's .claude/mcp.json:
# Quick command to get your config
cd /path/to/claude-telegram-bridge
./scripts/get-mcp-config.sh > ../your-project/.claude/mcp.json
Or manually copy the MCP config - see SETUP-FOR-OTHER-PROJECTS.md
Quick Start
1. Create Your Telegram Bot
- Open Telegram and search for
@BotFather - Send
/newbot - Follow the prompts:
- Choose a name for your bot (e.g., "My Claude Bridge")
- Choose a username (e.g., "my_claude_bridge_bot")
- Save your bot token - BotFather will give you a token like:
1234567890:ABCdefGHIjklMNOpqrsTUVwxyz - Find your bot in Telegram using the username you created
2. Install and Configure
# Clone or download this repo
cd claude-telegram-bridge
# Install dependencies
pnpm install
# Copy environment template
cp .env.example .env
# Edit .env and add your bot token
# TELEGRAM_BOT_TOKEN=your_token_here
Edit .env:
TELEGRAM_BOT_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_CHAT_ID= # Leave empty - auto-set on first use
PORT=3456
HOST=localhost
ENABLED=true
3. Build and Start
# Build the project
pnpm build
# Start the bridge service
pnpm dev
# Or run as background daemon
pnpm daemon
4. Initialize Your Bot
- Open Telegram and find your bot
- Send
/startto your bot - The bot will reply and save your chat ID automatically
- Test with
/statusto verify it's working
5. Add MCP Server to Claude
Option A: Auto-Generate Config (Easiest)
cd claude-telegram-bridge
./scripts/get-mcp-config.sh
Copy the output to your MCP config file.
Option B: Manual Setup
Add to your Claude Code MCP settings (~/.config/claude-code/settings/mcp.json):
{
"mcpServers": {
"telegram": {
"command": "node",
"args": [
"/ABSOLUTE/PATH/TO/claude-telegram-bridge/dist/mcp-server.js"
],
"env": {
"TELEGRAM_BRIDGE_URL": "http://localhost:3456"
}
}
}
}
Find your path:
cd claude-telegram-bridge && pwd
# Use output: <result>/dist/mcp-server.js
MCP Config Locations
- Global (all projects):
~/.config/claude-code/settings/mcp.json - Per-project:
your-project/.claude/mcp.json - VS Code:
your-project/.vscode/mcp.json
6. Available Tools
Once configured, Claude can automatically use:
telegram_notify- Send notificationstelegram_ask- Ask questions and wait for answerstelegram_get_messages- Check for messages from youtelegram_reply- Reply to your messagestelegram_check_health- Check bridge status
View detailed tool info:
pnpm tools
# or
node scripts/list-tools.js
7. Test It
Restart Claude Code, then tell Claude:
"Send me a test notification via Telegram"
Claude will automatically discover and use the telegram_notify tool!
MCP Tools Reference
Once configured, Claude can automatically use these tools:
telegram_notify
Send a notification to you via Telegram.
Parameters:
message(required): The notification text (supports Markdown)priority(optional):info|success|warning|error|question
Example Claude Usage:
"I've completed the database migration. Let me notify you." Claude uses:
telegram_notify({ message: "Database migration complete!", priority: "success" })
telegram_ask
Ask you a question and wait for your answer (blocking).
Parameters:
question(required): The question to ask (supports Markdown)timeout(optional): Milliseconds to wait (default: 300000 = 5 min)
Example Claude Usage:
"Should I deploy to production? Let me ask you." Claude uses:
telegram_ask({ question: "Deploy to production now?" })Waits for your response via Telegram
telegram_get_messages
Check for unread messages from you.
Example Claude Usage:
"Let me check if you've sent any messages." Claude uses:
telegram_get_messages({})
telegram_reply
Reply to your message via Telegram.
Parameters:
message(required): Your reply (supports Markdown)
Example Claude Usage:
"I'll respond to your question via Telegram." Claude uses:
telegram_reply({ message: "The build succeeded!" })
telegram_check_health
Check if the Telegram bridge is running and healthy.
Example Claude Usage:
"Let me verify the Telegram bridge is working." Claude uses:
telegram_check_health({})
Git Setup (For Sharing)
If you want to push this to your own Git repository:
# Initialize git (if not already done)
git init
# Add all files (gitignore protects secrets)
git add .
# Commit
git commit -m "Initial commit: Telegram MCP server"
# Add your remote
git remote add origin https://github.com/yourusername/claude-telegram-bridge.git
# Push
git push -u origin main
What's Safe to Share:
- ✅ All source code
- ✅
.env.example(template) - ✅ Documentation
- ✅ Configuration templates
What's Protected (in .gitignore):
- 🔒
.env(your bot token and secrets) - 🔒
node_modules/ - 🔒
dist/
For Others Cloning Your Repository
When someone clones your repo, they need to:
- Create their own Telegram bot with @BotFather
- Copy the template:
cp .env.example .env - Add their bot token to
.env - Install and build:
pnpm install && pnpm build - Follow the Quick Start guide above
Legacy HTTP API (For Direct Integration)
If you want to use the HTTP API directly (without MCP), you can:
// Simple notification
await fetch('http://localhost:3456/notify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
message: 'Scraping complete! Found 500 skills.',
priority: 'success'
})
});
// Question with markdown
await fetch('http://localhost:3456/notify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
message: '*Question:*\nContinue scraping sets?\n\nReply: yes/no',
priority: 'question',
parseMode: 'Markdown'
})
});
Priority Levels
info- ℹ️ General informationsuccess- ✅ Task completedwarning- ⚠️ Warning messageerror- ❌ Error occurredquestion- ❓ Needs your input
Bot Commands
Type these in Telegram to control the bridge:
/start- Initialize connection and save your chat ID/help- Show all available commands and how to use the bridge/status- Check bridge status (enabled, unread messages, pending questions)/test- Send a test notification to verify it's working
How Two-Way Communication Works
You → Claude
- Send any message to the bot in Telegram
- Bot acknowledges with "💬 Message received - responding..."
- Claude checks messages and responds when available
- You get the response in Telegram
Claude → You (Notifications)
Claude sends you updates via the /notify API endpoint with different priorities
Claude → You (Questions)
- Claude sends a question via
/askAPI - You see "❓ [question]" in Telegram
- Your next message is automatically treated as the answer
- Claude receives your answer and continues
Running as Background Service
# Build production version
pnpm build
# Start as daemon (requires pm2)
npm install -g pm2
pnpm daemon
# Check logs
pnpm logs
# Stop daemon
pnpm stop
API Endpoints
POST /notify
Send a notification to user
Request:
{
"message": "Your notification text",
"priority": "info|success|warning|error|question",
"parseMode": "Markdown|HTML"
}
Response:
{
"success": true,
"chatId": "7684777367"
}
GET /messages
Get unread messages from user
Response:
{
"messages": [
{
"from": "Richard",
"message": "What's the status?",
"timestamp": "2025-11-23T04:00:52.395Z",
"read": false
}
],
"count": 1
}
POST /messages/read
Mark messages as read
Request:
{
"count": 2 // optional, marks all if not provided
}
Response:
{
"markedAsRead": 2
}
POST /reply
Send a reply to user's message
Request:
{
"message": "Here's my response to your question"
}
Response:
{
"success": true
}
POST /ask
Ask user a question and wait for answer (blocking)
Request:
{
"question": "Should I continue scraping?",
"timeout": 300000 // optional, 5 min default
}
Response:
{
"answer": "yes"
}
GET /health
Check service health
Response:
{
"status": "running",
"enabled": true,
"chatId": "set",
"unreadMessages": 0,
"pendingQuestions": 0
}
Integration with ESO-MCP
Add this helper to your ESO-MCP project:
// src/utils/notify.ts
export async function notify(message: string, priority = 'info') {
try {
await fetch('http://localhost:3456/notify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message, priority })
});
} catch (error) {
console.log('Telegram bridge not available');
}
}
Then use anywhere:
await notify('✅ Skills scraping complete!', 'success');
await notify('❌ Failed to scrape sets page', 'error');
Environment Variables
TELEGRAM_BOT_TOKEN=your_token_here
TELEGRAM_CHAT_ID=auto_detected
PORT=3456
HOST=localhost
ENABLED=true