TypeScriptADK-TS

MCP Telegram

Enable AI agents to send and receive messages through Telegram bots.

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-telegram

Use 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

VariableRequiredDescription
TELEGRAM_BOT_TOKENYesToken from BotFather for your Telegram bot

Credentials

To create a bot and get your bot token:

  1. Open Telegram and search for @BotFather
  2. Send /newbot and follow the prompts to name your bot
  3. Copy the bot token BotFather gives you

Available Tools

SEND_MESSAGE
chatId:stringnumbertext:stringtopicId:number

Description

Send a message to a Telegram chat or channel

GET_CHANNEL_INFO
channelId:stringnumber

Description

Get information about a Telegram channel or chat

FORWARD_MESSAGE
fromChatId:stringnumbertoChatId:stringnumbermessageId:numberdisableNotification:boolean

Description

Forward a message from one chat to another

PIN_MESSAGE
chatId:stringnumbermessageId:numberdisableNotification:boolean

Description

Pin a message in a Telegram chat or channel

GET_CHANNEL_MEMBERS
channelId:stringnumberlimit:number

Description

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);

Further Resources