DEV Community
Follow
Giving Claude access to your Telegram: the two setups, and why the difference matters
You can connect AI agents to Telegram using an MCP server, but there are two distinct setups with significant security implications. The first type uses a Bot API token, authenticating as a bot. This bot can only access chats it's explicitly added to, and its access is limited and easily revoked. It cannot see private messages or chats where it hasn't been invited.The second type uses an MTProto server, which authenticates with your phone number and logs in as you. This grants the agent access to all your Telegram data, including private messages, groups, saved messages, and contacts. This is achieved by creating a session file that represents a live login.Setting up the Bot API or notifier involves providing a bot token and potentially a chat ID. The MTProto setup requires installation and an interactive login using your API ID and API hash. The location of the configuration file varies significantly depending on the AI client being used, and some clients, like Codex CLI, use a different configuration format (TOML).The primary concern with MTProto servers is that the session file provides full access to your account. This session file should never be stored in synced folders or committed to code repositories. Furthermore, because AI agents treat both data and instructions as text, a malicious message could be crafted to exploit the agent's ability to send messages, posing a security risk.The blast radius of a Bot API token is limited to the chats the bot is in, while an MTProto session file compromises your entire account. MTProto servers are not inherently unusable but require deliberate consideration and should ideally be used with a secondary account to mitigate risks. It is crucial to review the code of these community-developed MCP servers before connecting them to important accounts.