Skip to main content
Glama
BrainDAO

Telegram MCP Server

by BrainDAO

Telegram MCP Server

npm version License: MIT

Overview

An MCP (Model Context Protocol) server for interacting with Telegram bots and channels using the Telegraf library. This server enables AI agents to send messages, manage channels, forward content, and respond intelligently to Telegram conversations.

By implementing the Model Context Protocol (MCP), this server allows Large Language Models (LLMs) to interact with Telegram directly through their context window, bridging the gap between AI and messaging platforms.

Related MCP server: mcp-telegram

Features

Core Tools

  • SEND_MESSAGE: Send messages to channels or chats with optional topic support

  • GET_CHANNEL_INFO: Get information about channels/chats

  • FORWARD_MESSAGE: Forward messages between chats

  • PIN_MESSAGE: Pin messages in channels

  • GET_CHANNEL_MEMBERS: Get list of channel administrators

AI Sampling (Enhanced)

  • Intelligent Responses: AI-powered responses using FastMCP sampling

  • Mention-Only Mode: Smart filtering - responds when mentioned in groups

  • Multi-Message Types: Supports text, photos, documents, voice, video, stickers, locations, contacts, polls

  • Access Control: Configurable user/chat allow/block lists

  • Rate Limiting: Per-user and per-chat rate limiting

  • Advanced Configuration: Highly customizable behavior and templates

Installation

To use this server without installing it globally:

npx @iqai/mcp-telegram

Build from Source

git clone https://github.com/IQAIcom/mcp-telegram.git
cd mcp-telegram
pnpm install
pnpm run build

Running with an MCP Client

Add the following configuration to your MCP client settings (e.g., claude_desktop_config.json).

Minimal Configuration

{
  "mcpServers": {
    "telegram": {
      "command": "npx",
      "args": ["-y", "@iqai/mcp-telegram"],
      "env": {
        "TELEGRAM_BOT_TOKEN": "your_bot_token_here"
      }
    }
  }
}

Advanced Configuration (Local Build)

{
  "mcpServers": {
    "telegram": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-telegram/dist/index.js"],
      "env": {
        "TELEGRAM_BOT_TOKEN": "your_bot_token_here",
        "SAMPLING_ENABLED": "true",
        "SAMPLING_MENTION_ONLY": "true"
      }
    }
  }
}

Configuration (Environment Variables)

Required

Variable

Required

Description

TELEGRAM_BOT_TOKEN

Yes

Your Telegram bot token from @BotFather

Sampling Configuration

Variable

Default

Description

SAMPLING_ENABLED

true

Enable/disable AI sampling entirely

SAMPLING_MENTION_ONLY

true

Only respond when mentioned in groups

SAMPLING_RESPOND_TO_DMS

true

Always respond in DMs

SAMPLING_MAX_TOKENS

1000

Max tokens per AI response

SAMPLING_SHOW_TYPING

true

Show typing indicator

SAMPLING_SILENT_MODE

false

Log but don't respond

Access Control

Variable

Default

Description

SAMPLING_ALLOWED_CHATS

""

Comma-separated chat IDs/usernames to allow (empty = all)

SAMPLING_BLOCKED_CHATS

""

Comma-separated chat IDs/usernames to ignore

SAMPLING_ALLOWED_USERS

""

Comma-separated user IDs to allow (empty = all)

SAMPLING_BLOCKED_USERS

""

Comma-separated user IDs to ignore

SAMPLING_ADMIN_USERS

""

Comma-separated user IDs who can use admin commands

Rate Limiting

Variable

Default

Description

SAMPLING_RATE_LIMIT_USER

10

Max requests per user per minute

SAMPLING_RATE_LIMIT_CHAT

20

Max requests per chat per minute

Message Type Support

Variable

Default

Description

SAMPLING_ENABLE_TEXT

true

Enable text messages

SAMPLING_ENABLE_PHOTO

true

Enable photo messages

SAMPLING_ENABLE_DOCUMENT

true

Enable document uploads

SAMPLING_ENABLE_VOICE

true

Enable voice messages

SAMPLING_ENABLE_VIDEO

true

Enable video messages

SAMPLING_ENABLE_STICKER

true

Enable sticker messages

SAMPLING_ENABLE_LOCATION

true

Enable location sharing

SAMPLING_ENABLE_CONTACT

true

Enable contact sharing

SAMPLING_ENABLE_POLL

true

Enable poll messages

Content Filtering

Variable

Default

Description

SAMPLING_MIN_MESSAGE_LENGTH

1

Minimum message length

SAMPLING_MAX_MESSAGE_LENGTH

1000

Maximum message length

SAMPLING_KEYWORD_TRIGGERS

""

Only respond to messages with these keywords

SAMPLING_IGNORE_COMMANDS

true

Ignore messages starting with /

Usage Examples

Market Discovery

  • "Send a message to @mychannel saying hello"

  • "Get information about @telegram channel"

  • "Forward message 123 from @source to @destination"

Bot Commands

  • /start: Initialize the bot and get a welcome message

  • /help: Get help information about available features

  • /config: View current configuration (admin users only)

MCP Tools

FORWARD_MESSAGE

Forward a message from one chat to another

Parameter

Type

Required

Description

fromChatId

string

number

Yes

toChatId

string

number

Yes

messageId

number

Yes

ID of the message to forward

disableNotification

boolean

Forward message silently

GET_CHANNEL_INFO

Get information about a Telegram channel or chat

Parameter

Type

Required

Description

channelId

string

number

Yes

GET_CHANNEL_MEMBERS

Get a list of channel administrators and members

Parameter

Type

Required

Default

Description

channelId

string

number

Yes

limit

number

10

Maximum number of members to retrieve (1-50)

PIN_MESSAGE

Pin a message in a Telegram chat or channel

Parameter

Type

Required

Description

chatId

string

number

Yes

messageId

number

Yes

ID of the message to pin

disableNotification

boolean

Pin message silently

SEND_MESSAGE

Send a message to a Telegram chat or channel

Parameter

Type

Required

Description

chatId

string

number

Yes

text

string

Yes

The message text to send

topicId

number

The topic ID for forum channels (optional)

parseMode

string

Optional parse mode: Markdown, MarkdownV2, HTML, or Text (plain text)

Development

Build Project

pnpm run build

Development Mode (Watch)

pnpm run watch

Linting & Formatting

pnpm run lint
pnpm run format

Project Structure

  • src/tools/: Individual tool definitions

  • src/services/: Telegram service and bot logic

  • src/sampling/: AI sampling feature implementation

  • src/config.ts: Configuration with Zod validation

  • src/index.ts: Server entry point

Getting Your Bot Token

  1. Message @BotFather on Telegram

  2. Use /newbot command

  3. Follow the prompts to create your bot

  4. Copy the bot token provided

  5. Set it as an environment variable

Resources

Disclaimer

This project is an unofficial tool. Users should ensure their bot usage complies with Telegram's Terms of Service and Bot API policies.

License

MIT

Available Tools

5 tools
FORWARD_MESSAGEC

Forward a message from one chat to another

ParametersJSON Schema
NameRequiredDescriptionDefault
toChatIdYesDestination chat ID or username
messageIdYesID of the message to forward
fromChatIdYesSource chat ID or username
disableNotificationNoForward message silently

TDQS

C2.9/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 full burden. It only states the basic action without disclosing important behaviors like whether the user must be a member of both chats, if the original message content is preserved, or if there are any rate limits. The agent has no insight into side effects or setup requirements.

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

Conciseness4/5

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

The description is a single concise sentence that is front-loaded with the verb and key objects. Every word is functional, but it might be too brief and could benefit from a second sentence for clarity.

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?

Given the lack of annotations, output schema, and complexity of forwarding (which involves two chats and message IDs), the description is insufficient. It doesn't explain what happens if the message is deleted, if the user lacks permissions, or return behavior. Sibling tools are listed but no comparison is made.

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?

Schema coverage is 100%, so each parameter has a description within the schema. The tool description adds no additional meaning beyond the schema fields; it merely summarizes the action. No new parameter constraints or usage tips are given.

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

Purpose4/5

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

Description clearly states the verb 'Forward' and resource 'a message from one chat to another', making the action obvious. However, it doesn't differentiate from the sibling SEND_MESSAGE (which sends new messages) beyond the verb. No additional context like 'preserving original sender' is given.

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

Usage Guidelines2/5

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

No guidance on when to use this tool vs alternatives like SEND_MESSAGE, or when not to use it. The description is purely declarative without any context about prerequisites, restrictions, or comparison to siblings.

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

GET_CHANNEL_INFOB

Get information about a Telegram channel or chat

ParametersJSON Schema
NameRequiredDescriptionDefault
channelIdYesThe channel ID or username (e.g., @channelname or -1001234567890)

TDQS

B3.1/5.0
Behavior2/5

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

No annotations exist, so description must disclose behavior. It implies read-only but does not specify return format, permissions, rate limits, or whether it is destructive. Minimal transparency.

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

Conciseness4/5

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

The description is extremely concise with one sentence. It front-loads the purpose but sacrifices depth for brevity.

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?

Given no output schema and no annotations, the description should provide more context about what information is returned. It is incomplete for an agent to know what to expect.

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 parameter channelId is fully described in the schema (100% coverage). The description adds example formats, which is helpful but does not add significant new meaning beyond the schema.

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

Purpose4/5

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

The description clearly states 'Get information about a Telegram channel or chat', indicating a read operation distinct from siblings like SEND_MESSAGE or GET_CHANNEL_MEMBERS. However, 'information' is vague and could be more specific.

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?

No explicit guidance on when to use this tool versus alternatives. It is implied for retrieving metadata, but no direct comparison or exclusions are given.

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

GET_CHANNEL_MEMBERSC

Get a list of channel administrators and members

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of members to retrieve (1-50)
channelIdYesThe channel ID or username

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It does not mention important traits such as pagination (though limit parameter exists), rate limits, error handling, or whether the list is comprehensive.

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

Conciseness4/5

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

The description is a single sentence, concise and to the point. It front-loads the core functionality without extraneous words.

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 has no output schema and no annotations, so the description should compensate. It does not explain the return format, whether members include roles or metadata, or how pagination works with the limit parameter. This is insufficient for a tool that returns a list.

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 is fully documented (100% coverage) with descriptions for each parameter. The description adds no new meaning beyond the schema, so the baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the tool's purpose: retrieving a list of channel administrators and members. The verb 'Get' and resource 'channel members' make it specific. However, it does not explicitly distinguish from sibling tools like GET_CHANNEL_INFO, which might overlap.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives such as GET_CHANNEL_INFO or SEND_MESSAGE. There are no usage constraints or prerequisites mentioned.

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

PIN_MESSAGEB

Pin a message in a Telegram chat or channel

ParametersJSON Schema
NameRequiredDescriptionDefault
chatIdYesThe chat ID or channel username
messageIdYesID of the message to pin
disableNotificationNoPin message silently

TDQS

B3.2/5.0
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It does not mention permissions needed, effects on other pinned messages, or whether the action is reversible. The description is too minimal.

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

Conciseness4/5

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

The description is a single clear sentence with no unnecessary words. However, it could be slightly expanded without losing conciseness.

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

Completeness3/5

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

For a simple tool with 3 parameters and no output schema, the description is minimally complete but lacks context about the response or side effects. It does not cover potential failure modes or prerequisites.

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?

Schema description coverage is 100%, so each parameter is already documented in the schema. The description adds no additional meaning beyond the schema, meeting 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 action 'Pin a message' and the context 'in a Telegram chat or channel'. This is specific and distinct from sibling tools like SEND_MESSAGE or FORWARD_MESSAGE.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives, nor any prerequisites or exclusions. The description only states what the tool does, not when it's appropriate.

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

SEND_MESSAGEB

Send a message to a Telegram chat or channel

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesThe message text to send
chatIdYesThe chat ID or channel username (e.g., @channelname or -1001234567890)
topicIdNoThe topic ID for forum channels (optional)
parseModeNoParse mode for Telegram rendering. Use Text for plain text without formatting.

TDQS

B3.2/5.0
Behavior2/5

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

With no annotations, the description carries full burden of behavioral disclosure. It only states 'Send a message' without mentioning side effects, rate limits, permissions, or that the tool may return a message object. For a mutation tool, 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, clear sentence with no redundant words. It is front-loaded and appropriately sized for the tool's simplicity.

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?

Given no output schema, the description should explain what the tool returns (e.g., the sent message object). It does not, leaving the agent to infer. For a simple tool with 4 parameters, this is a notable gap.

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?

Schema coverage is 100%, so baseline is 3. The description adds no additional meaning beyond the parameter descriptions in the schema, but does not need to since the schema already describes each parameter.

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 'Send a message to a Telegram chat or channel' clearly states the verb (Send) and resource (message to a Telegram chat or channel). It distinguishes from sibling tools like FORWARD_MESSAGE and PIN_MESSAGE by specifying it sends a new message.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites, exclusions, or scenarios where other tools like FORWARD_MESSAGE would be more appropriate.

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. 5 tool updatesv0.1.4
    • First observedFORWARD_MESSAGE
    • First observedGET_CHANNEL_INFO
    • First observedGET_CHANNEL_MEMBERS
    • First observedPIN_MESSAGE
    • First observedSEND_MESSAGE

TDQS

A3.5/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: sending, forwarding, pinning messages, getting channel info, and listing members. No overlap or ambiguity.

Naming Consistency5/5

All tool names follow the same UPPER_SNAKE_CASE verb_noun pattern, e.g., SEND_MESSAGE, GET_CHANNEL_INFO. Highly consistent.

Tool Count5/5

Five tools is perfectly scoped for a Telegram MCP server, covering essential messaging and channel operations without excess.

Completeness4/5

Covers core operations (send, forward, pin, info, members) but is missing update/delete message capabilities, which are reasonable gaps for a focused tool set.

Maintenance

ActivityInactive
ResponsivenessSyncing

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
    C
    maintenance
    An MCP server that enables interaction with Telegram to send, read, and search messages across chats and dialogs. It supports waiting for incoming messages and retrieving conversation history through natural language commands.
    14
    4
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that wraps the Telegram Bot API into semantic tools for LLM agents, supporting multi-bot management for sending and receiving messages. It enables agents to send text, photos, and documents, as well as fetch recent updates from multiple configured Telegram bots.
    -
  • A
    license
    Not graded
    quality
    B
    maintenance
    MCP server that enables Telegram bot interaction via Telegraf, providing tools for sending, replying, reacting, editing, deleting, forwarding messages, and receiving Telegram events over an optional notification channel.
    46
    2
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server enabling AI agents to interact with users via Telegram, supporting message and image sending, inline quick replies, and waiting for user responses.
    13
    MIT

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/BrainDAO/mcp-telegram'

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