MCP Telegram
Enable AI agents to send and receive messages through Telegram bots.
- Package:
@iqai/mcp-telegram - Provider: Telegram
Overview
The Telegram MCP server lets your agent interact with Telegram via a bot. It can send messages to users or groups, read incoming messages, and respond to commands — making it straightforward to build agents that communicate through Telegram as their primary interface.
Bot Token Security
Your Telegram bot token gives full control over your bot. Never expose it in client-side code or commit it to source control.
Getting Started
Install the package:
pnpm add @iqai/mcp-telegramUse the server in your agent:
import { McpTelegram } from "@iqai/adk";
const toolset = McpTelegram({
env: {
TELEGRAM_BOT_TOKEN: process.env.TELEGRAM_BOT_TOKEN,
},
});
const tools = await toolset.getTools();import { McpToolset } from "@iqai/adk";
const toolset = new McpToolset({
name: "Telegram MCP Client",
description: "Client for Telegram bot messaging",
transport: {
mode: "stdio",
command: "npx",
args: ["-y", "@iqai/mcp-telegram"],
env: {
TELEGRAM_BOT_TOKEN: process.env.TELEGRAM_BOT_TOKEN,
PATH: process.env.PATH || "",
},
},
});
const tools = await toolset.getTools();{
"mcpServers": {
"telegram-mcp-server": {
"command": "npx",
"args": ["-y", "@iqai/mcp-telegram"],
"env": {
"TELEGRAM_BOT_TOKEN": "your_telegram_bot_token"
}
}
}
}Environment Variables
| Variable | Required | Description |
|---|---|---|
TELEGRAM_BOT_TOKEN | Yes | Token from BotFather for your Telegram bot |
Credentials
To create a bot and get your bot token:
- Open Telegram and search for @BotFather
- Send
/newbotand follow the prompts to name your bot - Copy the bot token BotFather gives you
Available Tools
SEND_MESSAGEchatId:stringnumbertext:stringtopicId:number
SEND_MESSAGEDescription
Send a message to a Telegram chat or channel
GET_CHANNEL_INFOchannelId:stringnumber
GET_CHANNEL_INFODescription
Get information about a Telegram channel or chat
FORWARD_MESSAGEfromChatId:stringnumbertoChatId:stringnumbermessageId:numberdisableNotification:boolean
FORWARD_MESSAGEDescription
Forward a message from one chat to another
PIN_MESSAGEchatId:stringnumbermessageId:numberdisableNotification:boolean
PIN_MESSAGEDescription
Pin a message in a Telegram chat or channel
GET_CHANNEL_MEMBERSchannelId:stringnumberlimit:number
GET_CHANNEL_MEMBERSDescription
Get a list of channel administrators and members
Integration Example
import { AgentBuilder, McpTelegram } from "@iqai/adk";
import * as dotenv from "dotenv";
dotenv.config();
async function main() {
// Initialize McpTelegram toolset
const toolset = McpTelegram({
env: {
TELEGRAM_BOT_TOKEN: process.env.TELEGRAM_BOT_TOKEN,
},
});
// Get available McpTelegram tools
const telegramTools = await toolset.getTools();
// Create agent with McpTelegram tools
const { runner } = await AgentBuilder.create("telegram_agent")
.withModel("gemini-2.5-flash")
.withDescription("An agent that communicates with users through Telegram")
.withTools(...telegramTools)
.build();
const response = await runner.ask(
"Send a message to chat ID 123456789 saying the daily report is ready",
);
console.log(response);
}
main().catch(console.error);