Skip to main content
Glama
RaspizDIYs

telegram-notes-mcp

by RaspizDIYs

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 (src/telegram_notes_mcp/server.py)

Exposes search tools to Claude Code / any MCP client

Web control panel (webui/)

Local browser UI: status, sync, search, ask-Ollama, chat whitelist editor

Topic analytics (analytics.py)

Clusters conversation into "bursts", extracts links, labels topics via LLM

Voice transcription (transcribe.py)

Transcribes voice/video messages via Telegram's built-in transcription (needs Premium)

Cross-device sharing (share.py)

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

search_messages(query, chat_name?, from_date?, to_date?, limit?)

Full-text search (SQLite FTS5)

semantic_search(query, chat_name?, limit?)

Search by meaning via embeddings, with rerank if a whitening index is trained

list_chats()

Whitelisted chats with message counts and last activity

get_chat_context(chat_name, around_message_id, window?)

Messages surrounding a specific message — useful to read the thread around a hit

sync_now()

Force an incremental re-sync of all whitelisted chats

embed_index(batch?)

Index one batch of messages without embeddings (call repeatedly while has_more is true)

transcribe_voices(limit?)

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.ps1

This creates a venv, installs dependencies (.[app,analytics]), makes a .env from the template, and creates shortcuts. Then:

  1. Fill in .env — your own TG_API_ID / TG_API_HASH (from my.telegram.org) and TG_CHAT_WHITELIST.

  2. Log in to your own Telegram: .venv\Scripts\python.exe scripts\login.py (creates your local session + database — your chats only).

  3. 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

  1. Windows only: if your only Python is the Microsoft Store version (where python points into WindowsApps\...), install a regular Python from python.org (or winget install Python.Python.3.13) and use that one below — the Store build has a known bug where the interactive login prompt can crash with EOFError on a repeated code entry.

  2. Create a virtualenv and install the package:

    • Windows: python -m venv .venv && .venv\Scripts\activate

    • macOS/Linux: python3 -m venv .venv && source .venv/bin/activate

    • Then: pip install -e ".[dev]"

  3. Create your own api_id/api_hash at my.telegram.org → "API development tools" — pick any app name, it's free and instant. Don't reuse someone else's api_id/api_hash — see docs/prd/001-login-code-never-arrives.md for why that silently breaks login codes.

  4. Copy .env.example to .env and fill in TG_API_ID / TG_API_HASH and TG_CHAT_WHITELIST (comma-separated usernames like @someone and/or numeric chat ids like -1001234567890; me = your own Saved Messages).

  5. 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 .session file at TG_SESSION_PATH).

  6. 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.server

On 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:

Running tests

pytest

Privacy

  • Your Telegram session (.session), database (messages.db), and .env never leave your machine and are git-ignored by default.

  • Semantic search and Q&A require an Ollama server — point TG_OLLAMA_URL at 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_WHITELIST are ever synced.

License

MIT — see LICENSE.

Available Tools

7 tools
embed_indexA

Проиндексировать (сгенерировать эмбеддинги) одну пачку сообщений без вектора. Вызывать повторно, пока has_more=true. Для полной переиндексации удобнее scripts/embed_backfill.py.

ParametersJSON Schema
NameRequiredDescriptionDefault
batchNo

TDQS

A4.3/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness3/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines5/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
windowNo
chat_nameYes
around_message_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.2/5.0
Behavior2/5

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.

Conciseness4/5

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.

Completeness2/5

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.

Parameters2/5

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.

Purpose5/5

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.

Usage Guidelines3/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines2/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo
queryYes
to_dateNo
chat_nameNo
from_dateNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.4/5.0
Behavior2/5

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.

Conciseness3/5

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.

Completeness2/5

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.

Parameters1/5

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.

Purpose4/5

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.

Usage Guidelines2/5

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.

sync_nowA

Force an incremental re-sync of all whitelisted chats.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.5/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness3/5

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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines2/5

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}.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.4/5.0
Behavior5/5

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.

Conciseness5/5

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.

Completeness5/5

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.

Parameters2/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.

  1. 7 tool updatesv0.1.0
    • First observedembed_index
    • First observedget_chat_context
    • First observedlist_chats
    • First observedsearch_messages
    • First observedsemantic_search
    • First observedsync_now
    • First observedtranscribe_voices

TDQS

A3.5/5.0

Scored across 7 tools

Disambiguation5/5

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 Consistency3/5

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.

Tool Count5/5

Seven tools is appropriate for the server's purpose of searching and analyzing Telegram messages. Each tool provides necessary functionality without excess.

Completeness4/5

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

ActivityStale
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    B
    maintenance
    An 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.
    -
  • A
    license
    Not graded
    quality
    B
    maintenance
    An 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 npm
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    MCP 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.
    8
    2
    MIT