Skip to main content

mcp-server-telegram-bot

MCP server that lets AI agents send Telegram messages and files through your own bot. The token is read from the environment and never reaches the agent.

Setup

  1. Create a bot with @BotFather and copy its token.
  2. Send /start to your bot from the chat that should receive messages.
  3. Install and register (replace the placeholders):
claude mcp add telegram \
  -e TELEGRAM_BOT_TOKEN=<token> \
  -e ALLOWED_CHAT_IDS=<chat_id> \
  -- uvx mcp-server-telegram-bot

Use --scope user so it works in every folder. When running from a checkout use uv run --project <dir> (not --directory), otherwise the server cannot see the session directory.

Don't know your chat id? Register with a temporary ALLOWED_CHAT_IDS=0, ask the agent to run get_updates, then re-register with the real id.

Environment

Variable Meaning
TELEGRAM_BOT_TOKEN Bot token (required)
ALLOWED_CHAT_IDS Comma-separated chats, each id or name=id (e.g. me=111,ali=222); first is default (required)
ALLOWED_DIRS Extra directories whose files are sent without asking (optional)
ACCESS_MODE ask (default): files outside the allowed roots need your confirmation. strict: they are refused
DENY_PATHS Extra files/dirs that are never sent (optional)

Typical use

  • "Send report.pdf to me when you finish" -> send_document(path) to the default chat.
  • "Send the result to Ali" -> send_message(text, chat_id="ali").
  • A person can only receive messages after they open the bot and press Start. Telegram blocks the bot otherwise.

Tools

send_message(text, chat_id?), send_document(path, caption?, chat_id?), send_photo(path, caption?, chat_id?), send_generated(name, content, format, caption?, chat_id?), get_updates(limit?) Access management: list_access(), add_chat(chat_id, name?), add_dir(path), remove_chat(chat), remove_dir(path)

File access

  1. Never sent, whatever env or the agent says: .ssh, .gnupg, .aws, .kube, .docker, ~/.claude*, browser profiles, keyrings, /etc, /proc, /sys; .env*, .netrc, .pgpass, .git-credentials, .git/config, id_* keys, *.pem, *.key, *.p12, *.kdbx, shell history. Paths are resolved with realpath, so symlinks and .. do not help. Add your own with DENY_PATHS.
  2. Sent directly: files inside the directory the session was started in (not if that is / or your home), and inside ALLOWED_DIRS.
  3. Everything else: you are asked to confirm each time (ACCESS_MODE=ask), or it is refused (strict).

send_generated builds the file from text the agent provides (pdf, md, txt, csv, json) and reads nothing from disk, so it needs no folder access: "send me a PDF of everything you did".

Every send is logged (time, chat, path or file name, never contents) to ~/.local/state/telegram-mcp/sent.log.

Limits: the deny list cannot know every secret. A password inside an ordinary file in the session directory will be sent if the agent is told to send it. Files go to Telegram's servers. Max 50 MB. Use one bot per user.

Changing access from the agent

  • add_chat / add_dir ask the user to confirm (MCP elicitation). If the client cannot ask, the call is refused.
  • / and the home directory cannot be added. Protected dirs stay blocked.
  • Additions are saved in ~/.config/mcp-server-telegram-bot/state.json (override with TELEGRAM_MCP_STATE).
  • remove_* only removes runtime additions. Env entries are changed in the environment.

Development

uv sync && uv run pytest

Metadata

Release files for mcp-server-telegram-bot 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-server-telegram-bot 0.2.0
File Size Uploaded Provenance Actions
mcp_server_telegram_bot-0.2.0.tar.gz 749.8 kB Without provenance Details for mcp_server_telegram_bot-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-server-telegram-bot 0.2.0
File Interpreter ABI Platform Actions
mcp_server_telegram_bot-0.2.0-py3-none-any.whl Python 3 none any Details for mcp_server_telegram_bot-0.2.0-py3-none-any.whl

Total release size: 1.5 MB

Release files / mcp_server_telegram_bot-0.2.0.tar.gz

Download URL mcp_server_telegram_bot-0.2.0.tar.gz
Size 749.8 kB
Tags Source
SHA-256 checksum
How to use checksums
06e3269759d75da7700de0a6c960fa3db248d47c6145fcad6c758641b193f818
BLAKE2b-256 checksum
How to use checksums
6420b91112fae86727807e0f2905c1fa4bbba4f2cfeb10833dd5589227976730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mcp_server_telegram_bot-0.2.0-py3-none-any.whl

Download URL mcp_server_telegram_bot-0.2.0-py3-none-any.whl
Size 748.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01307221832311a55401390a2089121a1e145ac77207f353252dd7fd38e85c93
BLAKE2b-256 checksum
How to use checksums
aaace9c75b8a438878fe6b2c3903d61262ee334ed81b0d59f22261b4c91e4966
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for mcp-server-telegram-bot 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page