Skip to main content
Glama

โœจ What is TeleMCP?

TeleMCP is a Python-based integration that exposes Telegram account operations as tools for applications that support the Model Context Protocol (MCP). It lets an MCP-compatible AI client work with Telegram chats, messages, contacts, groups, channels, media, and supported profile operations through a configured Telegram account.

TeleMCP runs as a local MCP process and communicates with Telegram over the network. Local execution does not mean that Telegram API requests or account data never leave your device.

Related MCP server: Telegram MCP Server

At a glance

Area

Capabilities

Chats

Discover conversations, inspect chats, send messages, archive and mute chats

Messages

Read history, search, reply, forward, edit, delete, and pin messages

Contacts

Search, add, remove, import, export, block, and unblock contacts

Groups & channels

Create and manage groups and channels, members, invitations, and permissions

Media

Send files, voice messages, stickers, and GIFs; inspect and download media

Profile

Read account information and manage supported profile and privacy settings

How it works

flowchart LR
    A[AI assistant / MCP host] <-->|MCP requests and results| B[TeleMCP server]
    B <-->|Telegram API requests| C[Telegram]

The MCP host launches TeleMCP as a local process. The assistant discovers the tools exposed by the server, calls the relevant tool, and receives the result from TeleMCP.

๐Ÿงฐ Tool showcase

The following tool names are documented for this project. The tools available at runtime depend on the installed code version and its configuration.

  • get_chats โ€” List chats with pagination

  • list_chats โ€” List detailed metadata for users, groups, and channels

  • get_chat โ€” Get information about a specific chat

  • get_direct_chat_by_contact โ€” Find a direct chat for a contact

  • send_message โ€” Send a text message

  • archive_chat / unarchive_chat โ€” Archive or restore a chat

  • mute_chat / unmute_chat โ€” Manage chat notifications

  • get_invite_link / export_chat_invite โ€” Retrieve or export an invite link

  • join_chat_by_link / import_chat_invite โ€” Join using an invite link

  • get_messages / list_messages โ€” Retrieve messages

  • get_message_context โ€” Get context around a message

  • get_history โ€” Retrieve chat history with filters

  • search_messages โ€” Search messages in a chat

  • reply_to_message โ€” Reply to a message

  • forward_message โ€” Forward a message

  • edit_message โ€” Edit a sent message

  • delete_message โ€” Delete messages

  • pin_message / unpin_message โ€” Manage pinned messages

  • mark_as_read โ€” Mark messages as read

  • get_pinned_messages โ€” List pinned messages

  • list_contacts โ€” List account contacts

  • search_contacts โ€” Search by name, username, or phone

  • get_contact_ids โ€” Resolve contact IDs

  • get_contact_chats โ€” Find chats for contacts

  • get_last_interaction โ€” Get the most recent interaction with a contact

  • add_contact / delete_contact โ€” Manage contacts

  • import_contacts / export_contacts โ€” Import or export contacts

  • block_user / unblock_user โ€” Manage blocked users

  • get_blocked_users โ€” List blocked users

  • resolve_username โ€” Resolve a Telegram username

  • search_public_chats โ€” Search public chats

  • create_group / create_channel โ€” Create a group or channel

  • invite_to_group โ€” Invite members

  • leave_chat โ€” Leave a group or channel

  • get_participants โ€” List participants

  • edit_chat_title โ€” Change a chat title

  • edit_chat_photo / delete_chat_photo โ€” Manage a chat photo

  • promote_admin / demote_admin โ€” Manage administrator roles

  • ban_user / unban_user โ€” Manage membership restrictions

  • get_admins โ€” List administrators

  • get_banned_users โ€” List banned users

  • get_recent_actions โ€” View recent administrative actions

  • send_file โ€” Send a document, photo, or video

  • download_media โ€” Download media from a message

  • get_media_info โ€” Inspect media metadata

  • send_voice โ€” Send a voice message

  • send_sticker โ€” Send a sticker

  • get_sticker_sets โ€” List available sticker sets

  • get_gif_search โ€” Search for GIFs

  • send_gif โ€” Send a GIF

  • get_me โ€” Get information about the authenticated account

  • update_profile โ€” Update supported profile fields

  • set_profile_photo / delete_profile_photo โ€” Manage profile photos

  • get_privacy_settings / set_privacy_settings โ€” Read or update privacy settings

  • get_user_photos โ€” Retrieve a user's profile photos

  • get_user_status โ€” Check a user's online status

  • get_bot_info โ€” Get bot information

  • set_bot_commands โ€” Configure bot commands

๐Ÿš€ Installation

Clone the repository

git clone https://github.com/Adarshukumar/telemcp.git
cd telemcp

Install from source

Run this from the project root, where pyproject.toml is located:

python -m pip install -e .

Using an editable install means changes made in this checkout are available to the installed Python environment.

๐Ÿ” Telegram credentials

TeleMCP requires Telegram API credentials. Create a private .env file in your project directory, or provide the same values through your MCP client's environment configuration:

TELEGRAM_API_ID=your_api_id
TELEGRAM_API_HASH=your_api_hash
TELEGRAM_SESSION_NAME=telemcp
# Optional alternative to a session file:
# TELEGRAM_SESSION_STRING=your_session_string

Get your API ID and API hash from Telegram's official API development page. Never commit your API hash, session string, .env file, or .session file.

First-time authentication

Choose one authentication method.

Session string:

python -m telemcp.session_string_generator

Add the generated value to TELEGRAM_SESSION_STRING in your private environment. Treat it like a password: anyone who obtains it may be able to access the authenticated Telegram session.

Session file:

python -m telemcp.authenticate

This creates a local session file. Keep it private and out of version control.

๐Ÿ”Œ Connect to an MCP client

Visual Studio Code

Add a server entry to .vscode/mcp.json. This example uses Python to launch the TeleMCP module and prompts for credentials instead of storing real secrets in the repository:

{
  "servers": {
    "telegram": {
      "type": "stdio",
      "command": "python",
      "args": ["-m", "telemcp"],
      "env": {
        "TELEGRAM_API_ID": "${input:telegram-api-id}",
        "TELEGRAM_API_HASH": "${input:telegram-api-hash}",
        "TELEGRAM_SESSION_STRING": "${input:telegram-session-string}",
        "MCP_NONINTERACTIVE": "true"
      }
    }
  },
  "inputs": [
    {
      "id": "telegram-api-id",
      "type": "promptString",
      "description": "Telegram API ID"
    },
    {
      "id": "telegram-api-hash",
      "type": "promptString",
      "description": "Telegram API hash",
      "password": true
    },
    {
      "id": "telegram-session-string",
      "type": "promptString",
      "description": "Telegram session string",
      "password": true
    }
  ]
}

The example uses the session-string method. For file-based authentication, replace TELEGRAM_SESSION_STRING with TELEGRAM_SESSION_NAME and use the session name configured on your machine. Keep the session file local.

The Python executable used by the MCP client must be the environment where TeleMCP is installed. MCP client configuration formats differ; adapt the example to the client you use.

โ–ถ๏ธ Run locally

From the project root, start the module with:

python -m telemcp

๐Ÿ Use from Python

import asyncio
from telemcp import client


async def main() -> None:
    await client.start()
    try:
        me = await client.get_me()
        print(f"Connected account: {me.first_name}")

        await client.send_message("username", "Hello from TeleMCP!")
    finally:
        await client.disconnect()


if __name__ == "__main__":
    asyncio.run(main())

Replace username with the intended Telegram username or chat reference. Use this example only with an account and conversations you are authorized to access.

โš™๏ธ Tool configuration

TeleMCP's tool groups are controlled by environment settings in the project configuration. The exact variable names should match the implementation in telemcp/tool_config.py. Check that file in your checkout before adding optional switches to an MCP client configuration; renaming a variable in documentation alone does not change the runtime behavior.

๐Ÿ›ก๏ธ Security notes

  • Keep TELEGRAM_API_HASH, TELEGRAM_SESSION_STRING, and session files private.

  • Add .env, *.session, and local credential files to .gitignore before committing.

  • Prefer environment variables or your MCP client's secret/input mechanism over hard-coded credentials.

  • Enable only the tool groups required for the task, especially administrative tools.

  • Review Telegram actions before allowing an AI client to send, edit, delete, forward, or administer content.

  • TeleMCP needs network access to Telegram. Review the account permissions and trust boundary of every MCP client you connect.

๐Ÿงช Verification checklist

Before treating a checkout as ready for use, verify it in the environment where you intend to run it:

  • Install the project in a clean virtual environment.

  • Generate a session using the chosen authentication method.

  • Start the MCP server and confirm that the client can discover its tools.

  • Test read-only operations before enabling message-sending or administrative actions.

  • Confirm that optional tool-group settings behave as expected.

  • Confirm that .env and session files are excluded from Git.

This README describes the documented project interface; the checklist is included so that runtime behavior can be verified against the exact checkout. It is not a claim that these tests have already been run.

๐Ÿค Contributing

Contributions, bug reports, and documentation improvements are welcome. When reporting an issue, include the Python version, MCP client, relevant tool name, and a sanitized error message. Never include API hashes, session strings, phone numbers, or private chat content in an issue.

๐Ÿ“„ License and maintenance

This repository retains its existing MIT license. Keep the original copyright and license notice in LICENSE intact when redistributing or modifying the code.

Documentation and ongoing maintenance for this repository are presented under Adarsh Kumar. This maintainer credit does not transfer authorship or ownership of previously published material.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to interact with Telegram accounts through MCP, supporting messaging, contacts, groups, media, and admin functions.
      4
      Apache 2.0
    • F
      license
      B
      quality
      D
      maintenance
      Enables MCP clients to interact with Telegram user accounts, providing tools for messaging, contacts, groups, channels, and media management through the Telegram API.
      85
      3
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP-compatible clients to interact with a Telegram account programmatically, covering chat and group management, messaging, contacts, profiles, media info, search, stickers, bots, privacy settings, and related operations.
      Apache 2.0