# Telegram MCP server for public channels

Give your agent read-only access to public Telegram channels through glim.sh. Find a channel by topic, search its post history and follow a post URL to read the discussion. Reading a channel or post needs its public web preview. The tools cannot read private chats or send messages.

## Telegram API pricing

- `POST /api/v1/telegram/search` or `glim_telegram_search` costs $0.01 per discovery search.
- `POST /api/v1/telegram/get` or `glim_telegram_get` costs $0.005 per read, including searches within one channel.

The REST examples use a glim.sh API key. You can also [pay per call with a wallet](https://glim.sh/docs/payments.md).

## Connect the Telegram MCP server

Add `https://glim.sh/mcp` to your MCP client. To give your agent just the Telegram search and get tools, connect to `https://glim.sh/mcp?tools=glim_telegram_search,glim_telegram_get`.

- **Claude Code**: `claude mcp add -s user -t http glim https://glim.sh/mcp`
- **Codex**: `codex mcp add glim --url https://glim.sh/mcp`
- **OpenCode**: `opencode mcp add`
  Interactive: choose remote, paste https://glim.sh/mcp
- **Wallet**: `npx x402-proxy mcp add glim https://glim.sh/mcp`
  No account: your agent pays per call in USDC (x402) from a local wallet, auto-generated on first run.

## Find public channels by topic

Use `kind: "channels"` to look up channel names and topics. Choose `posts` for indexed public pages on `t.me`, or omit `kind` to search both. Discovery results can miss posts. If you know the channel, search its history directly.

**REST request**

```
curl -X POST https://glim.sh/api/v1/telegram/search \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"spaceflight","kind":"channels"}'
```

**MCP tools/call parameters**

```
{
  "name": "glim_telegram_search",
  "arguments": {
    "query": "spaceflight",
    "kind": "channels"
  }
}
```

## Read recent posts or search a channel's history

Pass a channel URL as `ref` to read the newest posts first. Add `query` to search that channel's public history. For older matches, keep the same query and pass the returned `next_cursor` as `before`.

**REST request**

```
curl -X POST https://glim.sh/api/v1/telegram/get \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ref":"https://t.me/durov","query":"privacy","limit":5}'
```

**MCP tools/call parameters**

```
{
  "name": "glim_telegram_get",
  "arguments": {
    "ref": "https://t.me/durov",
    "query": "privacy",
    "limit": 5
  }
}
```

## Read a post and its discussion comments

Use the post URL from a channel result (`https://t.me/<channel>/<id>`). The get tool includes recent comments when the public discussion is visible. To read the post alone, set `include_comments` to `false`.

**MCP tools/call parameters**

```
{
  "name": "glim_telegram_get",
  "arguments": {
    "ref": "https://t.me/durov/540"
  }
}
```

## Compared with the Telegram Bot API

[Telegram's bot tutorial](https://core.telegram.org/bots/tutorial) shows how to use a bot token and send a message. glim.sh reads public channel posts for research. It does not run a chat bot, register a webhook or send replies.

## Good to know

- For channel reads, `limit` defaults to 20 and accepts 1 to 100 posts per call. You may receive fewer posts.
- A post read returns a window of its most recent comments. For older comments, call again with `comment` set to the oldest comment id you received.
- A private, missing or preview-disabled channel returns HTTP `404` over REST and a tool error over MCP.
- Posts can include views, reactions, media, polls and link previews. Use the post URL for a lasting reference because media links expire.

## FAQ

### Do I need a Telegram account, API ID or API hash?

No. [Telegram's API](https://core.telegram.org/api/obtaining_api_id) needs a Telegram account with an `api_id` and `api_hash`. glim.sh reads public pages, so your request needs only a search query or a channel or post reference, and a way to pay glim.sh.

### Can I read private channels or group chats?

No. A channel needs a public web preview. A public post can also have discussion comments that are unavailable through that preview.

---

## All docs pages


**Get started**

- [Introduction](https://glim.sh/docs.md)
- [MCP quickstart](https://glim.sh/docs/quickstart.md)
- [REST API quickstart](https://glim.sh/docs/quickstart-rest.md)
- [JavaScript quickstart](https://glim.sh/docs/quickstart-javascript.md)
- [Python quickstart](https://glim.sh/docs/quickstart-python.md)
- [Payments & auth](https://glim.sh/docs/payments.md)
- [MPP (Tempo)](https://glim.sh/docs/mpp.md)

**Tools**

- [Twitter / X](https://glim.sh/docs/twitter.md)
- [Reddit](https://glim.sh/docs/reddit.md)
- [Web](https://glim.sh/docs/web.md)
- [GitHub](https://glim.sh/docs/github.md)
- [Amazon](https://glim.sh/docs/amazon.md)
- [YouTube](https://glim.sh/docs/youtube.md)
- [Telegram](https://glim.sh/docs/telegram.md)

**Reference**

- [Changelog](https://glim.sh/docs/changelog.md)
- [API reference](https://glim.sh/docs/api-reference)
- [OpenAPI spec](https://glim.sh/openapi.json)
