Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit c7d31ae

Browse files
committed
feat: add Telegram Bridge MCP Server for remote control of Roo Code
This PR implements the foundation for Issue #11146 - Native Telegram Bot Integration for Remote Control. Changes: - Add ApproveAsk and DenyAsk commands to IPC types - Add IPC command handlers in extension for approve/deny - Create @roo-code/telegram-bridge MCP server package - Add Telegram bot integration with approve/deny buttons - Add tests for new IPC commands The Telegram Bridge MCP Server allows users to: - Receive Roo Code messages on Telegram in real-time - Approve/reject tool operations via inline buttons - Send new instructions from Telegram - Monitor task status remotely
1 parent ede1d29 commit c7d31ae

10 files changed

Lines changed: 1041 additions & 1 deletion

File tree

packages/ipc/src/ipc-client.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ export class IpcClient extends EventEmitter<IpcClientEvents> {
108108
})
109109
}
110110

111+
public approveAsk(text?: string, images?: string[]) {
112+
this.sendCommand({
113+
commandName: TaskCommandName.ApproveAsk,
114+
data: { text, images },
115+
})
116+
}
117+
118+
public denyAsk(text?: string, images?: string[]) {
119+
this.sendCommand({
120+
commandName: TaskCommandName.DenyAsk,
121+
data: { text, images },
122+
})
123+
}
124+
111125
public sendMessage(message: IpcMessage) {
112126
ipc.of[this._id]?.emit("message", message)
113127
}

packages/telegram-bridge/README.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# @roo-code/telegram-bridge
2+
3+
Telegram bridge for remote control of Roo Code. This MCP server enables you to interact with Roo Code via Telegram, allowing you to:
4+
5+
- **Receive messages**: Get real-time updates from Roo Code on your Telegram
6+
- **Approve/Reject operations**: Use inline buttons to approve or deny tool operations
7+
- **Send instructions**: Forward messages to Roo Code as new instructions
8+
- **Monitor task status**: Track task progress remotely
9+
10+
## Prerequisites
11+
12+
1. **Create a Telegram Bot**:
13+
- Open Telegram and search for [@BotFather](https://t.me/BotFather)
14+
- Send `/newbot` and follow the prompts
15+
- Save the bot token you receive
16+
17+
2. **Get your Chat ID**:
18+
- Start a conversation with your new bot
19+
- Send any message to the bot
20+
- Visit `https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates`
21+
- Find your `chat.id` in the response
22+
23+
## Installation
24+
25+
### As an MCP Server
26+
27+
Add the following to your MCP settings file (`~/.roo-code/settings/mcp_settings.json`):
28+
29+
```json
30+
{
31+
"mcpServers": {
32+
"telegram-bridge": {
33+
"command": "node",
34+
"args": ["/path/to/roo-code/packages/telegram-bridge/build/index.js"],
35+
"env": {
36+
"TELEGRAM_BOT_TOKEN": "your-bot-token",
37+
"TELEGRAM_CHAT_ID": "your-chat-id"
38+
}
39+
}
40+
}
41+
}
42+
```
43+
44+
### Build from Source
45+
46+
```bash
47+
cd packages/telegram-bridge
48+
npm install
49+
npm run build
50+
```
51+
52+
## Usage
53+
54+
Once the MCP server is running, you can use the following tools:
55+
56+
### start_bridge
57+
58+
Start the Telegram bridge with your credentials.
59+
60+
```json
61+
{
62+
"botToken": "your-bot-token",
63+
"chatId": "your-chat-id",
64+
"socketPath": "/path/to/roo-code.sock",
65+
"enableTts": false
66+
}
67+
```
68+
69+
### stop_bridge
70+
71+
Stop the Telegram bridge.
72+
73+
### bridge_status
74+
75+
Get the current status of the bridge.
76+
77+
### send_telegram_message
78+
79+
Send a custom message to Telegram.
80+
81+
```json
82+
{
83+
"message": "Hello from Roo Code!"
84+
}
85+
```
86+
87+
## Telegram Commands
88+
89+
Once connected, you can use these commands in Telegram:
90+
91+
- `/start` or `/help` - Show help message
92+
- `/status` - Show connection status
93+
- `/cancel` - Cancel the current task
94+
95+
Any other message will be forwarded to Roo Code as a new instruction.
96+
97+
## How It Works
98+
99+
1. The bridge connects to Roo Code via IPC (Inter-Process Communication)
100+
2. It listens for task events and messages from Roo Code
101+
3. Messages are formatted and sent to your Telegram chat
102+
4. When approval is needed, inline buttons are shown
103+
5. Button clicks and messages are sent back to Roo Code
104+
105+
## Architecture
106+
107+
```
108+
┌─────────────┐ IPC ┌──────────────────┐ Telegram API ┌──────────┐
109+
│ Roo Code │◄────────────►│ Telegram Bridge │◄──────────────────►│ Telegram │
110+
│ Extension │ │ (MCP Server) │ │ App │
111+
└─────────────┘ └──────────────────┘ └──────────┘
112+
```
113+
114+
## Environment Variables
115+
116+
| Variable | Description | Required |
117+
|----------|-------------|----------|
118+
| `TELEGRAM_BOT_TOKEN` | Your Telegram bot token | Yes |
119+
| `TELEGRAM_CHAT_ID` | Your Telegram chat ID | Yes |
120+
| `ROO_CODE_SOCKET_PATH` | Custom IPC socket path | No |
121+
122+
## Security Considerations
123+
124+
- Keep your bot token secret - never commit it to version control
125+
- The bridge only responds to messages from the configured chat ID
126+
- Consider using a private chat or group for better security
127+
- All communication between the bridge and Roo Code happens locally via IPC
128+
129+
## Troubleshooting
130+
131+
### Bridge not connecting
132+
133+
1. Ensure Roo Code is running with IPC enabled
134+
2. Check the socket path is correct
135+
3. Verify your bot token is valid
136+
137+
### Not receiving messages
138+
139+
1. Ensure you've started a conversation with the bot
140+
2. Check the chat ID is correct
141+
3. Look for errors in the MCP server logs
142+
143+
### Buttons not working
144+
145+
1. Make sure the bridge is still connected
146+
2. Check for any error messages in Telegram
147+
3. Try stopping and restarting the bridge
148+
149+
## License
150+
151+
Apache-2.0
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@roo-code/telegram-bridge",
3+
"version": "0.1.0",
4+
"description": "Telegram bridge for remote control of Roo Code via IPC",
5+
"type": "module",
6+
"main": "build/index.js",
7+
"types": "build/index.d.ts",
8+
"scripts": {
9+
"build": "tsc",
10+
"start": "node build/index.js",
11+
"dev": "tsx src/index.ts",
12+
"clean": "rm -rf build",
13+
"typecheck": "tsc --noEmit"
14+
},
15+
"dependencies": {
16+
"@modelcontextprotocol/sdk": "^1.0.0",
17+
"@roo-code/ipc": "workspace:*",
18+
"@roo-code/types": "workspace:*",
19+
"node-telegram-bot-api": "^0.66.0",
20+
"zod": "^3.24.1"
21+
},
22+
"devDependencies": {
23+
"@types/node": "^22.10.0",
24+
"@types/node-telegram-bot-api": "^0.64.7",
25+
"tsx": "^4.0.0",
26+
"typescript": "~5.8.0-dev.20250121"
27+
},
28+
"peerDependencies": {
29+
"typescript": "~5.8.0-dev.20250121"
30+
},
31+
"keywords": [
32+
"roo-code",
33+
"telegram",
34+
"mcp",
35+
"remote-control"
36+
],
37+
"license": "Apache-2.0"
38+
}

0 commit comments

Comments
 (0)