Cover image
Try Now
2025-03-14

Servidor MCP trabajará con Telegram a través de MtProto

3 years

Works with Finder

1

Github Watches

7

Github Forks

67

Github Stars

Telegram MCP server

About

The server is a bridge between the Telegram API and the AI assistants and is based on the Model Context Protocol.

[!IMPORTANT] Ensure that you have read and understood the Telegram API Terms of Service before using this server. Any misuse of the Telegram API may result in the suspension of your account.

Telegram Server MCP server

What is MCP?

The Model Context Protocol (MCP) is a system that lets AI apps, like Claude Desktop, connect to external tools and data sources. It gives a clear and safe way for AI assistants to work with local services and APIs while keeping the user in control.

What does this server do?

As of not, the server provides read-only access to the Telegram API.

  • Get the list of dialogs (chats, channels, groups)
  • Get the list of (unread) messages in the given dialog
  • Mark chanel as read
  • Retrieve messages by date and time
  • Download media files
  • Get the list of contacts
  • Draft a message
  • ...

Practical use cases

  • Create a summary of the unread messages
  • Find contacts with upcoming birthdays and schedule a greeting
  • Find discussions on a given topic, summarize them and provide a list of links

Prerequisites

Installation

uv tool install git+https://github.com/sparfenyuk/mcp-telegram

[!NOTE] If you have already installed the server, you can update it using uv tool upgrade --reinstall command.

[!NOTE] If you want to delete the server, use the uv tool uninstall mcp-telegram command.

Configuration

Telegram API Configuration

Before you can use the server, you need to connect to the Telegram API.

  1. Get the API ID and hash from Telegram API

  2. Run the following command:

    mcp-telegram sign-in --api-id <your-api-id> --api-hash <your-api-hash> --phone-number <your-phone-number>
    

    Enter the code you received from Telegram to connect to the API.

    The password may be required if you have two-factor authentication enabled.

[!NOTE] To log out from the Telegram API, use the mcp-telegram logout command.

Claude Desktop Configuration

Configure Claude Desktop to recognize the Exa MCP server.

  1. Open the Claude Desktop configuration file:

    • in MacOS, the configuration file is located at ~/Library/Application Support/Claude/claude_desktop_config.json
    • in Windows, the configuration file is located at %APPDATA%\Claude\claude_desktop_config.json

    Note: You can also find claude_desktop_config.json inside the settings of Claude Desktop app

  2. Add the server configuration

    {
      "mcpServers": {
        "mcp-telegram": {
            "command": "mcp-server",
            "env": {
              "TELEGRAM_API_ID": "<your-api-id>",
              "TELEGRAM_API_HASH": "<your-api-hash>",
            },
          }
        }
      }
    }
    

Telegram Configuration

Before working with Telegram’s API, you need to get your own API ID and hash:

  1. Login to your Telegram account with the phone number of the developer account to use.
  2. Click under API Development tools.
  3. A 'Create new application' window will appear. Fill in your application details. There is no need to enter any URL, and only the first two fields (App title and Short name) can currently be changed later.
  4. Click on 'Create application' at the end. Remember that your API hash is secret and Telegram won’t let you revoke it. Don’t post it anywhere!

Development

Getting started

  1. Clone the repository

  2. Install the dependencies

    uv sync
    
  3. Run the server

    uv run mcp-telegram --help
    

Tools can be added to the src/mcp_telegram/tools.py file.

How to add a new tool:

  1. Create a new class that inherits from ToolArgs

    class NewTool(ToolArgs):
        """Description of the new tool."""
        pass
    

    Attributes of the class will be used as arguments for the tool. The class docstring will be used as the tool description.

  2. Implement the tool_runner function for the new class

    @tool_runner.register
    async def new_tool(args: NewTool) -> t.Sequence[TextContent | ImageContent | EmbeddedResource]:
        pass
    

    The function should return a sequence of TextContent, ImageContent or EmbeddedResource. The function should be async and accept a single argument of the new class.

  3. Done! Restart the client and the new tool should be available.

Validation can accomplished either through Claude Desktop or by running the tool directly.

Debugging the server in terminal

To run the tool directly, use the following command:


# List all available tools
uv run cli.py list-tools

# Run the concrete tool
uv run cli.py call-tool --name ListDialogs --arguments '{"unread": true}'

Debugging the server in the Inspector

The MCP inspector is a tool that helps to debug the server using fancy UI. To run it, use the following command:

npx @modelcontextprotocol/inspector uv run mcp-telegram

[!WARNING] Do not forget to define Environment Variables TELEGRAM_API_ID and TELEGRAM_API_HASH in the inspector.

Troubleshooting

Message 'Could not connect to MCP server mcp-telegram'

If you see the message 'Could not connect to MCP server mcp-telegram' in Claude Desktop, it means that the server configuration is incorrect.

Try the following:

  • Use the full path to the uv binary in the configuration file
  • Check the path to the cloned repository in the configuration file

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • pontusab
  • La comunidad de cursor y windsurf, encontrar reglas y MCP

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • ravitemer
  • Un poderoso complemento Neovim para administrar servidores MCP (protocolo de contexto del modelo)

  • jae-jae
  • Servidor MCP para obtener contenido de la página web con el navegador sin cabeza de dramaturgo.

  • 1Panel-dev
  • 🔥 1Panel proporciona una interfaz web intuitiva y un servidor MCP para administrar sitios web, archivos, contenedores, bases de datos y LLM en un servidor de Linux.

  • patruff
  • Puente entre los servidores Ollama y MCP, lo que permite a LLM locales utilizar herramientas de protocolo de contexto del modelo

  • Mintplex-Labs
  • La aplicación AI de escritorio todo en uno y Docker con trapo incorporado, agentes de IA, creador de agentes sin código, compatibilidad de MCP y más.

  • GeyserMC
  • Una biblioteca para la comunicación con un cliente/servidor de Minecraft.

    Reviews

    3 (1)
    Avatar
    user_PRKm5lTR
    2025-04-17

    I have been using mcp-telegram by sparfenyuk for a while now, and it has exceeded my expectations. The seamless integration with Telegram makes managing my bots incredibly efficient. The setup was straightforward, and the welcome messages are engaging. Highly recommend checking it out on GitHub: https://github.com/sparfenyuk/mcp-telegram.