Skip to main content
Glama
bonzhigh

Telegram MCP Server

by bonzhigh

Telegram MCP Server

⚠️ Disclaimer: This project contains AI-generated code that has not been thoroughly tested. Use at your own risk and verify all functionality before production deployment.

A Model Context Protocol (MCP) server that enables AI assistants to send messages to Telegram users. Features a web-based configuration interface and supports both chat IDs and usernames.

Features

  • MCP Tool: send_telegram_message tool for AI assistants

  • Default User Support: Send messages to a configured default user when no recipient is specified

  • Web Interface: Easy configuration and testing via web browser

  • Flexible Recipients: Support for both Telegram chat IDs and usernames

  • Real-time Status: Live status monitoring of server and bot configuration

Related MCP server: Telegram Bot MCP

Prerequisites

  • Node.js 18 or higher

  • A Telegram bot token from @BotFather

Quick Start

1. Create a Telegram Bot

  1. Open Telegram and search for @BotFather

  2. Start a chat and send the command /newbot

  3. Follow the prompts to:

    • Choose a name for your bot

    • Choose a username for your bot (must end with bot)

  4. Copy the API token provided by BotFather

2. Install and Configure

# Clone or download this repository
git clone <repository-url>
cd telegram-mcp-server

# Install dependencies
npm install

# Copy environment template
cp .env.example .env

# Edit .env file with your bot token
# TELEGRAM_BOT_TOKEN=your_bot_token_here

3. Start the Server

# Start the server
npm start

The web interface will be available at http://localhost:3000

4. Configure via Web Interface

  1. Open http://localhost:3000 in your browser

  2. Enter your bot token in the configuration section

  3. Optionally set a default user (chat ID or username)

  4. Click "Save Configuration"

5. Test the Bot

  1. In the web interface, go to the "Test Message Sending" section

  2. Enter a test message

  3. Optionally specify a recipient (leave empty to test default user)

  4. Click "Send Test Message"

Configuration

Configuration should be managed through Cursor's MCP Servers settings:

  1. Open Cursor Settings (Ctrl+, or Cmd+,)

  2. Search for "MCP" or navigate to MCP Servers settings

  3. Add or edit the telegram server configuration

  4. Set environment variables:

    • TELEGRAM_BOT_TOKEN (required): Your bot token from @BotFather

    • TELEGRAM_DEFAULT_USER (optional): Default chat ID or username for messages

Configuration Priority:

  1. Primary: Environment variables from MCP Server configuration (Cursor GUI) - used at startup

  2. Secondary: Runtime updates via web interface API - for testing/debugging only

Stored Values as Defaults:

  • When tool calls don't provide chatId or username, the stored TELEGRAM_DEFAULT_USER is used automatically

  • If TELEGRAM_DEFAULT_USER is not configured and no recipient is provided, an error is returned

Web Interface Configuration (Testing/Debugging)

The web interface (http://localhost:3000) allows runtime configuration changes for testing:

  • Bot Token: Enter your Telegram bot token (runtime only)

  • Default User: Set a fallback recipient when no user is specified in messages

    • Use chat ID (numeric) for reliability

    • Username can be used but requires the user to have started your bot

⚠️ Note: Web interface configuration is temporary and for testing purposes. For persistent configuration, use Cursor's MCP Servers GUI.

Legacy: Environment Variables File

For standalone usage (not via MCP), you can create a .env file:

# Required: Your bot token from BotFather
TELEGRAM_BOT_TOKEN=your_bot_token_here

# Optional: Default user for messages (chat ID or username)
TELEGRAM_DEFAULT_USER=123456789

# Optional: Web interface port (default: 3000)
WEB_PORT=3000

Usage with MCP Clients

Connecting to Cursor

  1. Build the project:

    npm run build
  2. Configure in Cursor's MCP Servers GUI:

    • Open Cursor Settings (Ctrl+, or Cmd+,)

    • Search for "MCP Servers" or navigate to MCP settings

    • Add a new server or edit existing:

      • Name: telegram

      • Command: node

      • Arguments: C:\AppDev\Projects\MsgMCP\dist\index.js (use your full path)

      • Environment Variables:

        • TELEGRAM_BOT_TOKEN: Your bot token from @BotFather

        • TELEGRAM_DEFAULT_USER: (Optional) Default chat ID or username

  3. Restart Cursor for changes to take effect

Cursor AI Notification Rule

Purpose: Ensure the user is promptly notified whenever user intervention is required.

Triggers:

  • Completion of the process with a success message

  • Any unexpected halts or issues in the process

  • When Cursor AI requires user input or has questions

Action: Utilize send_telegram_message tool to send a detailed Telegram message to the user.

Connecting to Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "telegram": {
      "command": "node",
      "args": ["/path/to/telegram-mcp-server/dist/index.js"],
      "env": {
        "TELEGRAM_BOT_TOKEN": "your_bot_token_here",
        "TELEGRAM_DEFAULT_USER": "your_default_user"
      }
    }
  }
}

Using the Tool

The server provides one MCP tool: send_telegram_message

Parameters

  • message (required): The text message to send to the default user

Examples

Send to default user:

Send a message saying "Hello from AI!"

The tool automatically sends to the TELEGRAM_DEFAULT_USER configured in the .env file. No recipient specification needed!

Simple usage:

Tell the user that the task is complete
Notify that the server is running

API Endpoints

The server exposes a REST API for configuration and testing:

GET /api/status

Get server and bot status information.

Response:

{
  "server": "running",
  "bot": "initialized",
  "config": {
    "hasToken": true,
    "hasDefaultUser": true
  }
}

GET /api/config

Get current configuration (masked for security).

Response:

{
  "telegramBotToken": "configured",
  "telegramDefaultUser": "123456789",
  "webPort": 3000
}

POST /api/config

Update configuration.

Request:

{
  "telegramBotToken": "new_token_here",
  "telegramDefaultUser": "new_default_user"
}

POST /api/test

Send a test message.

Request:

{
  "message": "Test message",
  "chatId": "123456789",
  "username": "@testuser"
}

Development

Build

npm run build

Development Mode

npm run dev

Run Web Interface Only

npm run web

Troubleshooting

Bot Not Sending Messages

  1. Check Bot Token: Ensure your bot token is correct and the bot is not revoked

  2. User Interaction: For username-based sending, the user must have started your bot first

  3. Chat ID vs Username: Use chat IDs for more reliable message delivery

Web Interface Not Loading

  1. Port Conflict: Check if port 3000 is available

  2. Firewall: Ensure the port is not blocked by firewall

  3. Environment: Verify Node.js version and dependencies

MCP Connection Issues

  1. Path: Ensure the path to dist/index.js is correct in your MCP client config

  2. Environment Variables: Make sure required environment variables are set

  3. Build: Ensure the project is built (npm run build) before connecting

Security Considerations

  • Store bot tokens securely and never commit them to version control

  • The web interface is intended for local configuration only

  • Consider additional authentication for production deployments

  • Bot tokens have full access to your bot - keep them confidential

License

MIT License

Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Test thoroughly

  5. Submit a pull request

Support

For issues and questions:

  1. Check the troubleshooting section above

  2. Review the Telegram Bot API documentation

  3. Check MCP documentation for client integration

Changelog

v1.0.0

  • Initial release

  • MCP server with Telegram messaging tool

  • Web-based configuration interface

  • Support for chat IDs and usernames

  • Default user fallback functionality

Available Tools

1 tool
send_telegram_messageB

Send a message to the default Telegram user configured in .env file.

ParametersJSON Schema
NameRequiredDescriptionDefault
messageYesThe message text to send to the default user configured in .env file

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the basic action but omits important traits such as side effects (external message delivery), error behavior if .env is misconfigured, whether the send is synchronous or asynchronous, or any rate limits. For a tool with no annotation safety net, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that directly states what the tool does without any redundant or extraneous words. It earns its place by being both concise and informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple, but with no output schema and no annotations, the description should explain what happens after sending, such as return values or error behavior. The current description ends at the action itself, leaving the agent without information about outcomes. This is a significant gap for proper tool selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already provides 100% coverage for the single 'message' parameter with a clear description, so the tool description does not need to add more. The description adds no additional parameter meaning beyond the schema, placing it at the baseline of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action ('Send') and resource ('a message to the default Telegram user configured in .env file'). It is specific and directly mirrors the tool name, with no ambiguity. There are no sibling tools to differentiate from, so this fully satisfies purpose clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage whenever a message needs to be sent to the configured default Telegram user, but it does not explicitly state when to use this tool or mention any alternatives. Since there are no sibling tools, explicit exclusions are unnecessary, but the guidance is implied rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 1 tool updatev1.0.0
    • First observedsend_telegram_message

TDQS

B3.4/5.0
Disambiguation5/5

Only one tool exists, so there is no possibility of confusing it with others. The tool's purpose is clearly stated.

Naming Consistency5/5

The tool name follows a clear verb_noun pattern (send_telegram_message), and with only one tool, consistency is trivially maintained.

Tool Count2/5

A single tool is far too few for a Telegram MCP server, which typically requires sending, receiving, editing, and media operations. The narrow scope of sending only to a default user makes the server feel like a minimal notification service rather than a general Telegram integration.

Completeness1/5

The tool surface is severely incomplete, covering only text message sending to a default recipient. Missing common operations such as sending media, editing messages, handling updates, and selecting recipients makes most Telegram workflows impossible.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    A Model Context Protocol server that enables AI assistants to interact with Telegram, allowing them to search channels, list available channels, retrieve messages, and filter messages by regex patterns.
    51
    42
    MIT
  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    A comprehensive integration that allows AI models to interact with Telegram accounts for messaging, group management, and contact synchronization. It enables automated tasks like chat history analysis, message scheduling, and webhook-based responses through the Model Context Protocol.
    -

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bonzhigh/MsgMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server