telegram-call-mcp
An MCP server that lets AI agents placereal Telegram voice calls and speak a message aloud. The agent calls onetool — make_call — with the text and a repeat count; the server synthesizesspeech (any TTS model on OpenRouter, defaultfish-audio/s1), rings the owner'sTelegram, waits for them to pick up, plays the message, and hangs up.
Built for "wake me up if production is on fire" scenarios: text notificationsare easy to sleep through, a ringing phone is not.
Agent ──make_call("DB is down", repeat=2)──▶ telegram-call-mcp
│ 1. TTS via OpenRouter (mp3)
│ 2. ffmpeg → WAV 48kHz mono
│ 3. Telegram P2P call (py-tgcalls)
▼
📞 owner's phone rings,
message plays twice
The tool
make_call
| Argument | Type | Required | Description |
|---|---|---|---|
message |
string | yes | Text to speak. Markdown, URLs, emojis and long IDs are stripped; truncated to MAX_MESSAGE_LENGTH (default 500 chars). |
repeat |
int 1–10 | no (default 2) | How many times to play the message, with a 2s pause between repeats. |
Returns a structured result:
{ "status": "answered", "detail": "message played in full", "message_spoken": "DB is down" }
status is one of answered, no_answer, busy, declined, error. Anunanswered call means the message was not delivered — the agent can decideto retry or fall back to texting.
Requirements
- Python 3.10+
- ffmpeg (with ffprobe) in
PATH—brew install ffmpeg/apt install ffmpeg - A dedicated Telegram account for the server (bots can't make calls, soit signs in as a real user account; see Security notes)
- An OpenRouter API key for TTS
Setup
1. Install
pip install telegram-call-mcp # or: pipx install / uv tool install
Or from source:
git clone https://github.com/maloleg/telegram-call-mcp
cd telegram-call-mcp
pip install .
2. Get Telegram API credentials
- Sign in at my.telegram.org with the accountthat will be making the calls (a spare/dedicated account, not your own).
- Open API development tools, create an application (any name, URL can beleft empty).
- Note the
api_idandapi_hash.
3. Sign in once
export TELEGRAM_API_ID=123456
export TELEGRAM_API_HASH=abcdef...
export CALL_TARGET_USER_ID=111111111 # your own numeric Telegram user id
export OPENROUTER_API_KEY=sk-or-...
telegram-call-mcp login
The login prompts for the phone number, the code Telegram sends, and the 2FApassword if enabled, then saves a session file to~/.telegram-call-mcp/telegram.session.
Not sure about your numeric user id? Ask@userinfobot on Telegram.
The caller and the callee must be different accounts. Telegram cannotcall itself. Sign the server in with a dedicated account and point
CALL_TARGET_USER_IDat your personal one.
On the receiving account, allow calls from non-contacts (Settings → Privacy →Calls → Everybody) or add the server's account to your contacts — otherwiseTelegram rejects the call before it ever rings.
4. Add to your MCP client
Claude Code:
claude mcp add telegram-call \
--env TELEGRAM_API_ID=123456 \
--env TELEGRAM_API_HASH=abcdef... \
--env CALL_TARGET_USER_ID=111111111 \
--env OPENROUTER_API_KEY=sk-or-... \
-- telegram-call-mcp
Claude Desktop / any JSON-config client (claude_desktop_config.json):
{
"mcpServers": {
"telegram-call": {
"command": "telegram-call-mcp",
"env": {
"TELEGRAM_API_ID": "123456",
"TELEGRAM_API_HASH": "abcdef...",
"CALL_TARGET_USER_ID": "111111111",
"OPENROUTER_API_KEY": "sk-or-..."
}
}
}
}
That's it. Ask the agent to "call me and say the deploy finished" to test.
Configuration reference
| Variable | Required | Default | Description |
|---|---|---|---|
TELEGRAM_API_ID |
✅ | — | From my.telegram.org |
TELEGRAM_API_HASH |
✅ | — | From my.telegram.org |
CALL_TARGET_USER_ID |
✅ | — | Numeric Telegram user id to call |
OPENROUTER_API_KEY |
✅ | — | OpenRouter API key for TTS |
TTS_MODEL |
fish-audio/s1 |
Any TTS model on OpenRouter's /audio/speech endpoint |
|
TTS_VOICE |
— | Voice name, if the model supports it | |
TTS_BASE_URL |
https://openrouter.ai/api/v1 |
Any OpenAI-compatible audio API works | |
TELEGRAM_PROXY |
— | socks5://host:port or http://host:port for MTProto (Telethon ignores HTTP_PROXY) |
|
TELEGRAM_SESSION_PATH |
~/.telegram-call-mcp/telegram |
Session file location (without .session) |
|
CALL_ANSWER_TIMEOUT |
45 |
Seconds to wait for the callee to answer | |
CALL_REPEAT_PAUSE |
2 |
Pause between repeats, seconds | |
MAX_MESSAGE_LENGTH |
500 |
Message length cap after sanitization | |
LOG_LEVEL |
INFO |
stderr logging verbosity |
Security notes
- The session file is full access to the Telegram account. It is createdwith your user permissions in
~/.telegram-call-mcp/; treat it like aprivate key. Use a dedicated account so a leak never exposes your personalchats. - The tool can only call the one user id fixed in the server config — theagent cannot choose an arbitrary callee, dial numbers, or send messages.
- The message text passes through OpenRouter for synthesis; don't have agentsspeak secrets aloud.
- Automating a user account is subject to Telegram's terms; a dedicatedaccount keeps any risk away from your personal one.
Troubleshooting
| Symptom | Cause / fix |
|---|---|
| Tool error: session not authorized | Run telegram-call-mcp login with the same env vars the MCP client uses. |
Connection to Telegram failed at startup |
Direct MTProto is blocked in your network. Set TELEGRAM_PROXY to a local SOCKS/HTTP proxy. |
Call connects but there is silence / error (TelegramServerError) after ~10s of "REFLECTOR" log lines |
The voice media stream (UDP to Telegram relays) is blocked. A SOCKS proxy is not enough — voice traffic bypasses it. Run your VPN in TUN / system-tunnel mode so UDP is routed too. |
declined immediately, phone never rang |
The callee's privacy settings reject calls from non-contacts, or the two accounts are the same. |
| ffmpeg not found | Install ffmpeg and make sure ffmpeg/ffprobe are in the PATH visible to your MCP client. |
| TTS HTTP 401/402 | Bad or out-of-credit OPENROUTER_API_KEY. |
Development
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/mypy src
LOG_LEVEL=DEBUG .venv/bin/telegram-call-mcp # run on stdio
The call machinery lives in caller.py (Telethon + py-tgcalls, pinned to2.3.3 — private-call APIs are version-sensitive), TTS and audio prep intts.py, tool definition in server.py.
License
MIT