Skip to main content
Glama
chenzhaoxuan0

telegram-mcp

README.md
# telegram-mcp

Dedalus MCP server for Telegram Bot API workflows. It exposes bot identity, message sending, photo sending, update polling, callback answers, and message editing.

## Tools

- `get_me` - Get bot identity.
- `send_message` - Send a text message to a chat.
- `send_photo` - Send a photo by URL or file ID.
- `get_updates` - Fetch bot updates.
- `answer_callback_query` - Respond to an inline keyboard callback query.
- `edit_message_text` - Edit a bot message.

## Safety Notes

`send_message`, `send_photo`, `answer_callback_query`, and `edit_message_text` are user-visible. They can contact real Telegram users or groups and may trigger notifications. Confirm `chat_id`, `message_id`, callback IDs, and message contents before calling write tools.

Telegram bot tokens grant control of the bot. Do not commit tokens or chat exports.

## Important DAuth Limitation

Telegram's official Bot API requires the token in the request URL:

```text
https://api.telegram.org/bot<TOKEN>/<method>
```

`dedalus_mcp` 0.7.0 `Connection` supports secret injection into HTTP headers, not URL path templating. This repository still declares a DAuth connection named `telegram-mcp` with secret key `TELEGRAM_BOT_TOKEN`, but the implemented HTTP calls use a server-side `TELEGRAM_BOT_TOKEN` environment variable until path-secret support is available.

This means the current code is best deployed as a Type 2/3 server with a server or required credential environment value, not as a fully isolated path-templated DAuth server. Revisit this once Dedalus supports path credential templating for Telegram.

## Environment

```bash
TELEGRAM_BOT_TOKEN=123456:ABC-DEF...
DEDALUS_AS_URL=https://as.dedaluslabs.ai
```

For `_client.py`:

```bash
DEDALUS_API_KEY=dsk-live-...
DEDALUS_API_URL=https://api.dedaluslabs.ai
DEDALUS_MCP_SERVER=dedalus-labs/telegram-mcp
TELEGRAM_TEST_CHAT_ID=...
TELEGRAM_TEST_MESSAGE_ID=...
TELEGRAM_TEST_CALLBACK_QUERY_ID=...
```

## Run Locally

```bash
uv run python src/main.py
```

In another terminal:

```bash
MCP_SERVER_URL=http://127.0.0.1:8080/mcp uv run python src/_client.py
```

The client calls every tool. It intentionally includes write calls, so use a safe test chat.

## Deploy

Publish as `dedalus-labs/telegram-mcp`, configure `TELEGRAM_BOT_TOKEN` securely, deploy, then run:

```bash
DEDALUS_MCP_SERVER_ONLY=1 DEDALUS_MCP_SERVER=dedalus-labs/telegram-mcp uv run python src/_client.py
```