telegram-archive-mcp
An MCP server that gives LLMs read-only access to an archived Telegram history through a Telegram-Archive viewer.
List chats (
list_chats,list_folders): browse archived chats, most recent first, filterable/paged, plus Telegram folders.Search messages (
search_messages): keyword search within a single chat, with a result limit.Read messages (
get_messages): page through a chat newest-first using offset or a keyset cursor (before_date/before_id), or fetch newer messages withafter_id.Read one day (
get_messages_by_date): every message of a calendar day in a given IANA timezone, oldest first.Pinned messages and topics (
get_pinned_messages,get_topics): retrieve a chat's pins and its forum threads/topics.Statistics (
get_chat_stats): message/media counts and size for a chat;refresh_statsrecalculates global stats (the only non-read-only tool, hidden withREAD_ONLY=1).Media (
get_media): returns the photo attached to a message as a viewable image (scaled to 1568px max) with metadata, or only file details for unsupported types.Every tool returns structured content with an output schema alongside the same JSON as text.
Enables searching archived Telegram messages, browsing chats and folders, and retrieving chat statistics through a Telegram-Archive instance.
Features
Speaks MCP 2026-07-28 and every earlier revision down to 2024-11-05 on stdio and Streamable HTTP. Clients that still use the
initializehandshake work unchanged.Search one chat or every chat at once, read a chat page by page, one calendar day in your timezone, or the conversation around one message.
Forum topics, pinned messages, folders and per-chat statistics.
The photo attached to a message, returned as an image the model can look at and scaled to 1568 pixels when larger (
get_media).Every tool is read-only except
refresh_stats;READ_ONLY=1hides that one too.Signs in to Telegram-Archive through
/api/loginwithTELEGRAM_ARCHIVE_USERandTELEGRAM_ARCHIVE_PASS.HTTP listens on loopback by default, checks
Origin, caps request bodies, and requiresMCP_AUTH_TOKENon any other address.Ships as an npm package, a Docker image and multi-arch Go binaries.
Related MCP server: telegram-user-mcp
Install
Every client below runs the server over stdio. Set the URL, user and password of your Telegram-Archive viewer.
Claude Code
claude mcp add --env TELEGRAM_ARCHIVE_URL=http://localhost:8000 \
--env TELEGRAM_ARCHIVE_USER=admin --env TELEGRAM_ARCHIVE_PASS=your-viewer-password \
--transport stdio telegram-archive -- npx -y telegram-archive-mcpClaude Desktop (claude_desktop_config.json) and Cursor (~/.cursor/mcp.json)
{
"mcpServers": {
"telegram-archive": {
"command": "npx",
"args": ["-y", "telegram-archive-mcp"],
"env": {
"TELEGRAM_ARCHIVE_URL": "http://localhost:8000",
"TELEGRAM_ARCHIVE_USER": "admin",
"TELEGRAM_ARCHIVE_PASS": "your-viewer-password"
}
}
}
}VS Code (.vscode/mcp.json, asks for the password once)
{
"inputs": [
{ "type": "promptString", "id": "tg-pass", "description": "Telegram-Archive viewer password", "password": true }
],
"servers": {
"telegram-archive": {
"type": "stdio",
"command": "npx",
"args": ["-y", "telegram-archive-mcp"],
"env": {
"TELEGRAM_ARCHIVE_URL": "http://localhost:8000",
"TELEGRAM_ARCHIVE_USER": "admin",
"TELEGRAM_ARCHIVE_PASS": "${input:tg-pass}"
}
}
}
}Codex (~/.codex/config.toml)
[mcp_servers.telegram-archive]
command = "npx"
args = ["-y", "telegram-archive-mcp"]
env = { TELEGRAM_ARCHIVE_URL = "http://localhost:8000", TELEGRAM_ARCHIVE_USER = "admin", TELEGRAM_ARCHIVE_PASS = "your-viewer-password" }Docker, for any client above: use docker as the command with these arguments, and a release tag from the releases page, never latest:
docker run -i --rm -e TELEGRAM_ARCHIVE_URL -e TELEGRAM_ARCHIVE_USER -e TELEGRAM_ARCHIVE_PASS drumsergio/telegram-archive-mcp:vX.Y.ZThe npm package downloads the release binary on first start and checks it against the checksums published with the package, so it also works with npm 12, which skips install scripts. A long-running HTTP server (Docker Compose) and local builds are in Getting started.
Tools
Tool | What it does |
| Lists chats, most recent first; filter by |
| Lists your Telegram folders and their ids. |
| Searches message text in every chat at once. |
| Searches one chat, optionally one forum topic. |
| Reads a chat newest first, by offset or keyset cursor, optionally one forum topic. |
| Returns one message with the messages before and after it. |
| Returns every message of one calendar day in a timezone. |
| Returns a chat's pinned messages. |
| Lists a forum group's topics; their ids feed |
| Message and media counts and size of one chat. |
| The photo attached to a message, as an image, or the file's details. |
| Makes the viewer recalculate archive-wide statistics. Hidden with |
Every tool returns structured content with an output schema, alongside the same JSON as text. Arguments and defaults are on Usage.
Documentation
The full documentation is at geiserx.github.io/telegram-archive-mcp.
Getting started: npm, Docker Compose, local build
Configuration: environment variables and client configuration
Usage: the 4 resources and 12 tools, paging, reading one day at a time
Development: testing, contributing, credits
Related projects: Telegram Archive, other MCP servers, where this one is listed
License
Available Tools
12 toolsget_chat_statsChat statisticsARead-onlyIdempotent
Get the archive's statistics for one chat: how many messages and media files it holds, their total size, and the dates of its first and last message. Use telegram-archive://stats for the totals of the whole archive.
Inputs: chat_id (required). Returns: object
get_mediaLook at a message's photoARead-onlyIdempotent
Get the photo or file attached to one message. A JPEG, PNG, WebP or GIF image comes back as an image you can look at, scaled to at most 1568 pixels on its longest side, after a JSON text block with the message's message_id, date, sender, text (the caption) and reply_to_msg_id, and the file's media_key, kind, file_name, mime_type, size_bytes, image_returned, width, height and scaled. Any other file returns only that JSON text block, with a note saying why the file is not included.
Inputs: chat_id (required), message_id (required). Returns: date, kind, note, text, +11 more
get_message_contextRead around a messageARead-onlyIdempotent
Read the conversation around one message: the message itself with up to before older and after newer messages of the same chat, oldest first. Use it after search_messages or search_all_chats finds a hit, or to see what a reply_to_msg_id points at.
Inputs: chat_id (required), message_id (required), after, before. Returns: after, before, messages, message_id
get_messagesRead a chat's messagesARead-onlyIdempotent
Get messages from a Telegram chat, newest first. Page with offset, or with the keyset cursor: pass the date and id of the last message you received as before_date and before_id to get the older ones (constant time on huge chats). after_id returns the messages right after an id. Dates are naive UTC. Each message carries reply_to_msg_id and, when it has a file, media (pass its id to get_media).
Inputs: chat_id (required), limit, offset, after_id, +3 more. Returns: messages
get_messages_by_dateRead one day of a chatARead-onlyIdempotent
Get every message of a Telegram chat sent on one calendar day, oldest first. The day is taken in the given timezone (default UTC); the archive stores dates in UTC. Walks the chat with the keyset cursor, so it is cheap even on chats with hundreds of thousands of messages. Use it to answer "what was said on "; use get_messages to page through a chat instead.
Inputs: date (required), chat_id (required), limit, timezone, +1 more. Returns: date, count, messages, timezone, +2 more
get_pinned_messagesRead pinned messagesARead-onlyIdempotent
Get every pinned message of a Telegram chat, newest first, with the same fields as get_messages. Pinned messages often hold a group's rules, addresses or key links.
Inputs: chat_id (required). Returns: messages
get_topicsList forum topicsARead-onlyIdempotent
List the forum topics (threads) of a forum supergroup, with message counts. Pass a topic's id as topic_id to get_messages, search_messages or get_messages_by_date to read only that thread. A chat that is not a forum has no topics.
Inputs: chat_id (required). Returns: topics
list_chatsList archived chatsARead-onlyIdempotent
List archived Telegram chats, most recent first. Use this first: each chat's ref is the chat_id the other tools take. Each row also carries id (the numeric Telegram chat id), type, accounts (the archive account ids holding the chat), and its title or name. Narrow it with search (by name), archived or folder_id (from list_folders). The answer is {chats, total, limit, offset, has_more}; page with offset while has_more is true.
Inputs: limit, offset, search, archived, +1 more. Returns: chats, limit, total, offset, +1 more
list_foldersList chat foldersARead-onlyIdempotent
List the Telegram chat folders (Telegram's dialog filters, such as Work or Family) with their ids. Pass a folder's id to list_chats as folder_id to see the chats inside it.
Inputs: no named parameters. Returns: folders
refresh_statsRecalculate archive statisticsAIdempotent
Make the viewer recalculate the archive-wide statistics now and return them (chat, message and media counts, total size). It scans the whole archive, so it can take a while and load the viewer's database; it changes no message. Needs the viewer's master login. The cached totals in telegram-archive://stats are usually enough. Hidden when the server runs with READ_ONLY=1.
Inputs: no named parameters. Returns: object
search_all_chatsSearch every chatARead-onlyIdempotent
Search message text across every chat this archive login may see, newest first. Matching is by word prefix on the viewer's full-text index. Each hit names its chat, and chat.ref is the chat_id for get_message_context or get_messages. Use search_messages instead to search one known chat. Needs a Telegram Archive viewer with cross-chat search; an older viewer answers 404.
Inputs: query (required), limit, offset. Returns: limit, query, offset, indexed, +2 more
search_messagesSearch one chatARead-onlyIdempotent
Search the messages of one chat for a keyword, newest first, and return the matching messages with the same fields as get_messages. Use search_all_chats when you do not know the chat. To read the conversation around a hit, pass its id to get_message_context.
Inputs: query (required), chat_id (required), limit, topic_id. Returns: messages
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Every tool has a clearly distinct scope: get_messages (paging), get_messages_by_date (single day), get_message_context (window around a hit), get_pinned_messages, and get_topics each target different access patterns, and the descriptions explicitly cross-reference when to use one over another. The search pair (search_messages vs search_all_chats) and stats pair (get_chat_stats vs refresh_stats) are likewise cleanly separated by scope and caching behaviour.
All 12 tools follow a consistent snake_case verb_noun pattern (get_*, list_*, search_*, refresh_*). No camelCase or stylistic outliers, and noun choice is predictable (chats, folders, messages, topics, media, stats).
12 tools sit comfortably in the well-scoped range and each earns its place by covering a distinct retrieval need of an archive browser. Nothing feels redundant or padded.
The read-only archive domain is well covered: discovery (list_chats, list_folders, get_topics), retrieval (paging, by-date, pinned, context), search at both chat and cross-chat levels, media, and stats. Minor gaps remain, such as no way to enumerate archive accounts or fetch a single message by id directly, though these are workable via existing tools.
Maintenance
Related MCP Connectors
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
MCP server for AI dialogue using various LLM models via AceDataCloud
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that connects to a Telegram group chat, persists messages to a local SQLite database, and exposes tools to search, retrieve, and send messages via SSE.-
- AlicenseNot gradedqualityCmaintenanceAn MCP server that connects to Telegram as your real user account and exposes read-only tools to read and search messages, list chats and folders, inspect group info, and download media.19 npmMIT
- AlicenseAqualityDmaintenanceAn MCP server that gives AI agents full access to a personal Telegram account via MTProto, enabling chat reading, history search, messaging, media handling, and automations.79MIT
- FlicenseNot gradedqualityCmaintenanceRead-only MCP server that exposes retrieval tools over a Telegram chat archive, including archive overview, full-text search with Russian morphology, aggregates, message retrieval, and local context. It lets LLM agents answer questions from chat history without syncing Telegram, downloading files, or modifying the index.-