Skip to content

Latest commit

Β 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Telegram MCP Server

npm version License: Apache-2.0 TypeScript Telegram Bot API

A comprehensive Model Context Protocol (MCP) server for seamless Telegram Bot API integration

Empower your AI assistants with full Telegram functionality through a modern, type-safe interface

πŸ“š Documentation β€’ πŸš€ Quick Start β€’ πŸ› οΈ API Reference β€’ πŸ’‘ Examples


✨ Features

πŸ’¬ Core Messaging

  • πŸ“ Rich Text Messages - HTML, Markdown & MarkdownV2 support
  • πŸ–ΌοΈ Photo Sharing - Images with captions and formatting
  • πŸ“Ž Document Upload - Files with custom names and descriptions
  • πŸŽ₯ Video Content - Videos with metadata and streaming support
  • ↗️ Message Forwarding - Cross-chat message forwarding
  • πŸ—‘οΈ Message Management - Delete and manage messages

🏒 Chat Management

  • ℹ️ Chat Information - Detailed chat data and permissions
  • πŸ‘₯ User Management - Member info and administration
  • πŸ”’ Permission Control - Fine-grained access control
  • πŸ“Š Analytics Ready - Comprehensive data extraction

πŸš€ Installation

Option 1: NPM Package (Recommended)

# Install the package
npm install @xingyuchen/telegram-mcp

# Or using yarn
yarn add @xingyuchen/telegram-mcp

Option 2: From Source

# Clone the repository
git clone https://github.com/guangxiangdebizi/telegram-mcp.git
cd telegram-mcp

# Install dependencies
npm install

# Build the project
npm run build

πŸ“‹ Usage

πŸ”§ Setup Your Telegram Bot

First time? You'll need a Telegram Bot Token:

  1. πŸ’¬ Message @BotFather on Telegram
  2. πŸ€– Send /newbot command
  3. πŸ“ Follow the instructions to create your bot
  4. πŸ”‘ Copy the bot token provided by BotFather
  5. βœ… Use this token in the MCP tool calls

πŸš€ Deployment Options

πŸ“‘ Option 1: Local Development (Stdio)

Step 1: Start the MCP server

npm start

Step 2: Configure Claude Desktop

{
  "mcpServers": {
    "telegram-mcp": {
      "command": "node",
      "args": ["path/to/@xingyuchen/telegram-mcp/build/index.js"]
    }
  }
}
🌐 Option 2: SSE Deployment (Supergateway)

Step 1: Start the SSE server

npm run sse

Step 2: Configure Claude Desktop with SSE

{
  "mcpServers": {
    "telegram-mcp": {
      "type": "sse",
      "url": "http://localhost:3100/sse",
      "timeout": 600
    }
  }
}

πŸ› οΈ Available Tools

πŸ”§ Tool πŸ“ Description 🎯 Use Case
send_message Send rich text messages Basic communication, notifications
send_photo Share images with captions Visual content, screenshots
send_document Upload files and documents File sharing, reports
send_video Send video content Media sharing, tutorials
forward_message Forward messages between chats Content distribution
delete_message Remove messages Content moderation
get_chat Retrieve chat information Analytics, administration

πŸ“€ send_message

πŸ“ Send rich text messages with formatting support

πŸ“‹ Parameters
Parameter Type Required Description
token string βœ… Telegram bot token
chatId string|number βœ… Chat ID or username
text string βœ… Message text
parseMode string ❌ HTML, Markdown, or MarkdownV2
disableWebPagePreview boolean ❌ Disable link previews
disableNotification boolean ❌ Send silently
replyToMessageId number ❌ Reply to specific message

πŸ–ΌοΈ send_photo

πŸ“Έ Share images with captions and formatting

πŸ“‹ Parameters
Parameter Type Required Description
token string βœ… Telegram bot token
chatId string|number βœ… Chat ID or username
photo string βœ… Photo file path, URL, or file_id
caption string ❌ Photo caption
parseMode string ❌ Caption formatting
disableNotification boolean ❌ Send silently
replyToMessageId number ❌ Reply to specific message

πŸ“Ž send_document

πŸ“„ Upload files and documents with custom names

πŸ“‹ Parameters
Parameter Type Required Description
token string βœ… Telegram bot token
chatId string|number βœ… Chat ID or username
document string βœ… Document file path, URL, or file_id
caption string ❌ Document caption
parseMode string ❌ Caption formatting
filename string ❌ Custom filename
disableNotification boolean ❌ Send silently
replyToMessageId number ❌ Reply to specific message

πŸŽ₯ send_video

🎬 Send video content with metadata and streaming

πŸ“‹ Parameters
Parameter Type Required Description
token string βœ… Telegram bot token
chatId string|number βœ… Chat ID or username
video string βœ… Video file path, URL, or file_id
duration number ❌ Video duration in seconds
width number ❌ Video width
height number ❌ Video height
caption string ❌ Video caption
parseMode string ❌ Caption formatting
supportsStreaming boolean ❌ Enable streaming
disableNotification boolean ❌ Send silently
replyToMessageId number ❌ Reply to specific message

↗️ forward_message

πŸ”„ Forward messages between different chats

πŸ“‹ Parameters
Parameter Type Required Description
token string βœ… Telegram bot token
chatId string|number βœ… Destination chat ID
fromChatId string|number βœ… Source chat ID
messageId number βœ… Message ID to forward
disableNotification boolean ❌ Send silently

πŸ—‘οΈ delete_message

❌ Remove messages from chats

πŸ“‹ Parameters
Parameter Type Required Description
token string βœ… Telegram bot token
chatId string|number βœ… Chat ID or username
messageId number βœ… Message ID to delete

ℹ️ get_chat

πŸ“Š Retrieve detailed chat information and permissions

πŸ“‹ Parameters
Parameter Type Required Description
token string βœ… Telegram bot token
chatId string|number βœ… Chat ID or username

πŸ”§ Development

πŸ“ Project Structure

πŸ“¦ telegram-mcp/
β”œβ”€β”€ πŸ“‚ src/
β”‚   β”œβ”€β”€ πŸ“„ index.ts          # πŸš€ MCP server entry point
β”‚   └── πŸ“‚ tools/           # πŸ› οΈ Business tool modules
β”‚       β”œβ”€β”€ πŸ“„ sendMessage.ts    # πŸ’¬ Text messaging
β”‚       β”œβ”€β”€ πŸ“„ sendPhoto.ts      # πŸ–ΌοΈ Photo sharing
β”‚       β”œβ”€β”€ πŸ“„ sendDocument.ts   # πŸ“Ž Document upload
β”‚       β”œβ”€β”€ πŸ“„ sendVideo.ts      # πŸŽ₯ Video sharing
β”‚       β”œβ”€β”€ πŸ“„ getChat.ts        # ℹ️ Chat information
β”‚       β”œβ”€β”€ πŸ“„ forwardMessage.ts # ↗️ Message forwarding
β”‚       └── πŸ“„ deleteMessage.ts  # πŸ—‘οΈ Message deletion
β”œβ”€β”€ πŸ“‚ examples/
β”‚   β”œβ”€β”€ πŸ“„ claude-config.json    # βš™οΈ Claude configuration
β”‚   └── πŸ“„ usage-examples.md     # πŸ’‘ Usage examples
β”œβ”€β”€ πŸ“„ package.json
β”œβ”€β”€ πŸ“„ tsconfig.json
└── πŸ“„ README.md

πŸ”¨ Adding New Tools

  1. Create a new tool file in src/tools/
  2. Follow the existing tool pattern:
    export const yourTool = {
      name: "your_tool_name",
      description: "Tool description",
      parameters: { /* JSON Schema */ },
      async run(args: any) { /* Implementation */ }
    };
  3. Import and register in src/index.ts
  4. Add to both ListToolsRequestSchema and CallToolRequestSchema handlers

πŸš€ Development Scripts

Command Description Usage
npm run build πŸ”¨ Compile TypeScript Production builds
npm run dev πŸ‘€ Watch mode Development
npm start πŸš€ Start MCP server Stdio mode
npm run sse 🌐 Start SSE server Port 3100

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ—ΊοΈ Roadmap

See telegram-api-planning.md for the complete feature roadmap and implementation priorities.


πŸ“„ License

Apache License 2.0

See LICENSE file for details.


πŸ‘€ Author

Xingyu Chen

Email GitHub LinkedIn NPM


⭐ Star this repo if you find it helpful! ⭐

About

A comprehensive Telegram Bot API server built on the Model Context Protocol (MCP), providing seamless integration with Telegram Bot functionality through a modern, modular architecture.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages