telegram-notes-mcp
Enables semantic search over Telegram messages using embeddings generated by a local or self-hosted Ollama server, allowing meaning-based queries.
Provides tools for searching, syncing, and managing your own Telegram chats via full-text and semantic search, including listing whitelisted chats and retrieving message context.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@telegram-notes-mcpfind the link about the new design system in my chats"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
telegram-notes-mcp
A local MCP server that gives Claude Code (or any MCP client) full-text and semantic search over your own Telegram chats — via your personal MTProto (Telethon) login. Everything runs on your machine: your own Telegram session, your own SQLite database, your own (optional) Ollama server for embeddings. Nothing is sent to a third-party cloud unless you point it at one yourself.
Ask Claude things like "what did we decide about the deploy last Tuesday?" or "find that link someone shared about X" and get an answer grounded in your actual chat history — not a hallucination.
What's in here
Piece | What it does |
MCP server ( | Exposes search tools to Claude Code / any MCP client |
Web control panel ( | Local browser UI: status, sync, search, ask-Ollama, chat whitelist editor |
Topic analytics ( | Clusters conversation into "bursts", extracts links, labels topics via LLM |
Voice transcription ( | Transcribes voice/video messages via Telegram's built-in transcription (needs Premium) |
Cross-device sharing ( | Export/import the derived analytics layer between your own machines |
Only the MCP server needs to be registered with Claude Code — the rest are optional local tools you run yourself.
Related MCP server: telegram-mcp
MCP tools
Tool | Description |
| Full-text search (SQLite FTS5) |
| Search by meaning via embeddings, with rerank if a whitening index is trained |
| Whitelisted chats with message counts and last activity |
| Messages surrounding a specific message — useful to read the thread around a hit |
| Force an incremental re-sync of all whitelisted chats |
| Index one batch of messages without embeddings (call repeatedly while |
| Transcribe pending voice/video messages (requires Telegram Premium) |
Quick start — mini-app (Windows)
A standalone local app: control-panel window (no browser chrome) + a system tray icon, with Start Menu / Desktop shortcuts. After cloning:
powershell -ExecutionPolicy Bypass -File setup.ps1This creates a venv, installs dependencies (.[app,analytics]), makes a
.env from the template, and creates shortcuts. Then:
Fill in
.env— your ownTG_API_ID/TG_API_HASH(from my.telegram.org) andTG_CHAT_WHITELIST.Log in to your own Telegram:
.venv\Scripts\python.exe scripts\login.py(creates your local session + database — your chats only).Launch the telegram-notes shortcut → a window opens and a tray icon appears.
Panel without the tray (plain browser): .venv\Scripts\python.exe webui\panel.py.
More detail: webui/README.md.
Quick start — manual / macOS / Linux
Windows only: if your only Python is the Microsoft Store version (
where pythonpoints intoWindowsApps\...), install a regular Python from python.org (orwinget install Python.Python.3.13) and use that one below — the Store build has a known bug where the interactive login prompt can crash withEOFErroron a repeated code entry.Create a virtualenv and install the package:
Windows:
python -m venv .venv && .venv\Scripts\activatemacOS/Linux:
python3 -m venv .venv && source .venv/bin/activateThen:
pip install -e ".[dev]"
Create your own
api_id/api_hashat my.telegram.org → "API development tools" — pick any app name, it's free and instant. Don't reuse someone else'sapi_id/api_hash— see docs/prd/001-login-code-never-arrives.md for why that silently breaks login codes.Copy
.env.exampleto.envand fill inTG_API_ID/TG_API_HASHandTG_CHAT_WHITELIST(comma-separated usernames like@someoneand/or numeric chat ids like-1001234567890;me= your own Saved Messages).Run the one-time interactive login:
python scripts/login.py(asks for your phone number + the code Telegram sends you — check the Telegram app itself first, not just SMS; creates the.sessionfile atTG_SESSION_PATH).Register the server with Claude Code (see below).
Each machine (Windows, macOS, ...) does its own login and keeps its own
local .session file and SQLite database — nothing syncs between machines
unless you explicitly use the share.py export/import feature.
Configuration
All configuration lives in .env (see .env.example for the full list with
comments). Required: TG_API_ID, TG_API_HASH, TG_CHAT_WHITELIST.
Everything else — semantic search (TG_OLLAMA_URL / TG_EMBED_MODEL /
TG_OLLAMA_AUTH), analytics noise-filter (TG_OWN_BOT_USERNAME), and the
bot-message editor (TG_BOT_TOKEN) — is optional.
Registering with Claude Code
Preferred: use the CLI so it lands in whichever config file your Claude
Code version actually reads (this has moved between versions — don't
hand-edit ~/.claude/.mcp.json, it's not necessarily the file claude mcp list uses; check with claude mcp list after adding):
claude mcp add telegram-notes -- /absolute/path/to/telegram-notes-mcp/.venv/bin/python -m telegram_notes_mcp.serverOn Windows use the .venv\Scripts\python.exe path. A newly added
user-scope server may need a one-time approval — run claude mcp list and,
if it shows "Pending approval", approve it via claude mcp get telegram-notes or /mcp inside an interactive session.
Don't add a cwd field/flag — Claude Code silently ignores it and always
launches the server from wherever Claude Code itself was started, not this
directory. That's fine: config.py locates .env and resolves any
relative TG_SESSION_PATH/TG_DB_PATH by the project's own directory
(derived from this package's install location), not the process's current
working directory, so the server works correctly regardless of where the
MCP client actually launches it from.
Known issues and their fixes
If something doesn't work, check whether it's already documented:
docs/prd/001-login-code-never-arrives.md — login code never shows up
docs/prd/002-numeric-chat-id-not-resolving.md — a group/channel whitelisted by numeric id fails to sync
docs/prd/003-claude-code-mcp-registration.md — server doesn't show up in Claude Code after registering it
Running tests
pytest
Privacy
Your Telegram session (
.session), database (messages.db), and.envnever leave your machine and are git-ignored by default.Semantic search and Q&A require an Ollama server — point
TG_OLLAMA_URLat your own (local or self-hosted); no data goes to a third-party LLM API unless you configure one yourself.Only chats you explicitly list in
TG_CHAT_WHITELISTare ever synced.
License
MIT — see LICENSE.
Available Tools
7 toolsembed_indexA
Проиндексировать (сгенерировать эмбеддинги) одну пачку сообщений без вектора. Вызывать повторно, пока has_more=true. Для полной переиндексации удобнее scripts/embed_backfill.py.
| Name | Required | Description | Default |
|---|---|---|---|
| batch | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description carries full burden. It discloses batch processing, need for repeated calls, and that it only processes messages without vector. However, it does not mention side effects, idempotency, or error handling, but the key behaviors are covered.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Three short, efficient sentences in Russian. Front-loaded with purpose, then usage, then alternative. No fluff, every sentence adds value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Covers main purpose and usage pattern, but lacks return value structure (only mentions has_more flag, not how to access it) and prerequisites. Without output schema, description should provide more detail on what the tool returns.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Input schema has one optional parameter 'batch' with default 300, but schema description coverage is 0%. The description says 'one batch' implying batch size, but does not explicitly link the parameter name to its meaning. An agent can infer, but it's not explicit.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool indexes one batch of messages without vector (generates embeddings). It distinguishes from siblings like search_messages or semantic_search by focusing on batch indexing rather than retrieval or synchronization.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicit guidance: 'Call repeatedly while has_more=true' and mentions alternative scripts/embed_backfill.py for full reindexing. This helps an agent decide when to use this tool versus alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_chat_contextB
Return messages surrounding a specific message in a chat.
| Name | Required | Description | Default |
|---|---|---|---|
| window | No | ||
| chat_name | Yes | ||
| around_message_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided; description does not disclose any behavioral traits such as message ordering, size limits, or whether it returns only immediate neighbors. The agent is left to guess behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single, clear sentence that efficiently conveys the purpose. Could be longer to add missing details, but no wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has 3 parameters and an output schema, the description provides insufficient context. The meaning of 'window' and the structure of returned messages are absent, leaving the agent underinformed.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%. Description mentions chat_name and around_message_id implicitly but does not explain them. Parameter 'window' is not described at all. Output schema exists but is not referenced.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states the verb 'Return' and the resource 'messages surrounding a specific message in a chat'. Differentiates from siblings like search_messages which finds messages by query, not context.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Implies usage when needing context around a message, but no explicit when-not or alternative tools are mentioned. Sibling tools like search_messages could serve similar purposes, but no guidance on selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_chatsA
List whitelisted chats with message counts and last activity date.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided; description implies read-only behavior but does not explicitly state it. The term 'whitelisted' is mildly ambiguous. Adequate for a simple list tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence, no extraneous words. Highly concise and front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no parameters and an output schema, the description is reasonably complete. Could mention pagination or sorting, but not strictly necessary.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
No parameters exist, but the description adds meaning by specifying what is listed ('with message counts and last activity date'), which goes beyond the empty schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool lists 'whitelisted chats' with specific details (message counts and last activity date), distinguishing it from siblings like get_chat_context or search_messages.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool over alternatives such as search_messages or get_chat_context. The description lacks context for appropriate invocation.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_messagesC
Full-text search over indexed Telegram messages.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| query | Yes | ||
| to_date | No | ||
| chat_name | No | ||
| from_date | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It only says 'full-text search over indexed Telegram messages', failing to disclose that it is a read-only operation, what the search scope is (e.g., message text only), or any behavioral traits like rate limits or pagination.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is very concise (one sentence) and front-loaded with 'Full-text search', but it is too brief, sacrificing necessary detail. Every sentence should earn its place; this one does not provide enough information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool has 5 parameters and an output schema, but the description fails to mention filtering options, return behavior, or any context. It is incomplete for a search tool of this complexity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, yet the description adds no meaning to any of the 5 parameters. It does not explain the 'query' parameter, date range filters, chat filter, or limit. The agent must rely solely on parameter names.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool performs full-text search over Telegram messages, which is a specific verb-resource combination. It also distinguishes from the sibling tool 'semantic_search' by specifying 'full-text'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'semantic_search'. There is no mention of prerequisites, limitations, or context for usage.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
semantic_searchA
Поиск сообщений по СМЫСЛУ (эмбеддинги), а не по точным словам. Требует предварительной индексации (embed_index / scripts/embed_backfill.py). Если обучен whitening-индекс (scripts/build_white_index.py) — использует retrieve-more + bge-rerank; иначе честный fallback на сырой nomic.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| query | Yes | ||
| chat_name | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Since no annotations are provided, the description carries full burden. It discloses prerequisite indexing steps and the conditional behavioral difference between whitening-trained fallback and raw nomic, which is good transparency for a read-only search tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two concise sentences, front-loaded with the main purpose. The second sentence contains technical detail that, while valuable, could be daunting for some agents. Overall efficient with no wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the presence of an output schema, the description does not need to explain return values. It covers the core behavior, prerequisites, and algorithmic fallback. Missing is the role of 'chat_name' and the effect of 'limit', but these are minor gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0% and the description adds no parameter-level details. It does not explain 'query', 'limit', or 'chat_name' beyond the schema defaults and types, leaving the agent to guess their semantics.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it searches messages by meaning using embeddings, not exact words. It explicitly distinguishes from sibling 'search_messages' (exact match) by contrasting semantic vs. exact search.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context: use for semantic search when exact word search is insufficient. It mentions prerequisites (embed_index) and fallback behavior, but does not explicitly name the sibling tool for exact search as an alternative.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
sync_nowA
Force an incremental re-sync of all whitelisted chats.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full burden. It discloses the action (force sync) but lacks details on side effects, idempotency, or safety. For a potentially impactful operation, more behavioral context is needed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence with no extraneous text. It is front-loaded and concise, conveying the essential information efficiently.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple tool with no parameters and an output schema, the description covers the basic function. However, it omits behavioral details (e.g., idempotency, rate limits) and usage guidance, leaving gaps for an agent to decide when to invoke it.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has no parameters, so the description adds value by specifying the scope ('all whitelisted chats'). This clarifies what the tool operates on, which is not evident from the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's action: forcing an incremental re-sync of all whitelisted chats. The verb 'sync' and resource 'whitelisted chats' are specific, and the tool is distinct from its siblings (which involve embedding, listing, searching, etc.).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives. There is no mention of prerequisites, appropriate context, or when not to use it. The agent must infer usage from the tool name alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
transcribe_voicesA
Transcribe pending voice/video-note messages via Telegram's built-in transcription (requires the logged-in account to have Premium). Transcripts are written into messages.text so they flow into search, embeddings, bursts and topics. Returns {total, transcribed, failed}.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Despite no annotations, the description comprehensively discloses behavior: it uses Telegram's built-in transcription, requires Premium, modifies messages.text, affects downstream features (search, embeddings, bursts, topics), and returns a specific object. No annotation contradictions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, no redundancy, front-loaded with action and resource. Every sentence adds necessary information (prerequisite, effect, output).
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with one simple optional parameter and an output schema, the description provides all necessary context: what it does, prerequisites, side effects, and return shape. No gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The only parameter 'limit' is not mentioned in the description, and schema coverage is 0%. While the parameter is self-explanatory, the description should have clarified its purpose (e.g., limits number of messages to transcribe) to add value beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('transcribe') and the specific resource ('pending voice/video-note messages'). It distinguishes from sibling tools, which focus on indexing, search, or syncing, not transcription.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description mentions the requirement for a Premium account and that transcripts are written into messages.text. It implicitly tells when to use (to transcribe pending voice notes), but does not explicitly tell when not to use or provide alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
7 tool updates
v0.1.0- First observed
embed_index - First observed
get_chat_context - First observed
list_chats - First observed
search_messages - First observed
semantic_search - First observed
sync_now - First observed
transcribe_voices
TDQS
Scored across 7 tools
Each tool has a distinct function: indexing, context retrieval, listing chats, full-text search, semantic search, syncing, and transcription. No two tools overlap in purpose.
Naming is a mix of English and Russian, and patterns vary: verb_noun (list_chats), verb_adverb (sync_now), adjective_noun (semantic_search). All use snake_case, but the inconsistency reduces predictability.
Seven tools is appropriate for the server's purpose of searching and analyzing Telegram messages. Each tool provides necessary functionality without excess.
Core workflows (indexing, searching, syncing, transcription) are covered. Missing explicit get/export message operations, but the set is largely complete for its intended use.
Maintenance
Related MCP Connectors
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Personal knowledge base MCP server with semantic search, auto-categorization, metadata extraction
Related MCP Servers
- AlicenseBqualityAmaintenanceMCP server that exposes any Telegram-Archive instance to LLMs, enabling message search, chat browsing, and access to archived Telegram history.746 npm4GPL 3.0
- FlicenseNot gradedqualityBmaintenanceAn 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 gradedqualityBmaintenanceAn 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.11 npmMIT
- AlicenseAqualityAmaintenanceMCP server that acts as a gateway to Telegram, providing AI-optimized tools for messaging, search, and chat management via MTProto. Supports multi-user authentication with QR login and HTTP/stdio transports.82MIT