telegram-notes-mcp
A local MCP server that enables full-text and semantic search over your own Telegram chats using your personal MTProto login, with everything running locally.
README
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.
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:
- 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\activate - macOS/Linux:
python3 -m venv .venv && source .venv/bin/activate - Then:
pip install -e ".[dev]"
- Windows:
- 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.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:
- 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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。