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
|
|
# Install the package
npm install @xingyuchen/telegram-mcp
# Or using yarn
yarn add @xingyuchen/telegram-mcp# Clone the repository
git clone https://github.com/guangxiangdebizi/telegram-mcp.git
cd telegram-mcp
# Install dependencies
npm install
# Build the project
npm run buildFirst time? You'll need a Telegram Bot Token:
- π¬ Message @BotFather on Telegram
- π€ Send
/newbotcommand - π Follow the instructions to create your bot
- π Copy the bot token provided by BotFather
- β Use this token in the MCP tool calls
π‘ Option 1: Local Development (Stdio)
Step 1: Start the MCP server
npm startStep 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 sseStep 2: Configure Claude Desktop with SSE
{
"mcpServers": {
"telegram-mcp": {
"type": "sse",
"url": "http://localhost:3100/sse",
"timeout": 600
}
}
}| π§ 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 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 |
πΈ 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 |
π 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 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 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 |
β 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 |
π Retrieve detailed chat information and permissions
π Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
token |
string |
β | Telegram bot token |
chatId |
string|number |
β | Chat ID or username |
π¦ 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
- Create a new tool file in
src/tools/ - Follow the existing tool pattern:
export const yourTool = { name: "your_tool_name", description: "Tool description", parameters: { /* JSON Schema */ }, async run(args: any) { /* Implementation */ } };
- Import and register in
src/index.ts - Add to both
ListToolsRequestSchemaandCallToolRequestSchemahandlers
| 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 |
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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
See telegram-api-planning.md for the complete feature roadmap and implementation priorities.
Apache License 2.0
See LICENSE file for details.