tg-mcp-spy
Caches Telegram channel posts in a local database and provides tools for tracking channels, fetching posts, and summarizing recent content.
Click on "Install 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., "@tg-mcp-spylist posts from @technews from last week"
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.
tg-mcp-spy
A Python MCP (Model Context Protocol) server that caches Telegram channel posts in a local SQLite database and exposes them via MCP tools. It connects to Telegram through a user session (Telethon) and mirrors the user's broadcast-channel subscriptions into a queryable local cache.
Quick start
1. Install dependencies
uv sync --all-extras2. Set environment variables
export TELEGRAM_API_ID=your_api_id
export TELEGRAM_API_HASH=your_api_hash
export TELEGRAM_SESSION_STRING=your_session_stringThe session string must be generated externally (e.g. via Telethon's interactive login). Optional variables:
Variable | Default | Description |
|
| Path to the SQLite database |
|
| Days to retain cached posts |
3. Run the server
python -m package_tgmcpspy.serverThe server binds to 127.0.0.1:8000 by default.
Related MCP server: tg-mcp-tools
MCP Tools
Tool | Description |
| List all locally tracked channels |
| Add a channel to the local tracked list |
| Remove a channel from the local tracked list |
| Sync tracked channels with your Telegram subscriptions |
| Fetch latest posts for a single channel |
| Fetch latest posts for all tracked channels |
| Get a specific cached post |
| List posts from one channel by date range |
| List posts from all tracked channels by date range |
Channel identifiers accept a Telegram username or numeric id (including -100... format). Dates accept YYYY-MM-DD or ISO timestamps, interpreted as UTC.
MCP Resources
URI | Description |
| Tracked channels (placeholder; use the tool for live data) |
| Single cached post (placeholder; use the tool for live data) |
MCP Prompt
URI | Description |
| Summarize recent posts from a channel (default: last 7 days) |
Development
make format # Format code with ruff
make lint # Run ruff linter
make typecheck # Run mypy
make test # Run pytest
make check # Run format-check + lint + typecheck + testArchitecture
src/package_tgmcpspy/
models.py — domain dataclasses, exceptions, identifier normalization
config.py — environment-based configuration loading
db.py — SQLAlchemy Core schema + async repository
telegram.py — Telethon wrapper with FloodWait retry
server.py — FastMCP application, lifespan, tools, resources, promptsAll MCP tool calls are processed sequentially. Cached posts are immutable — edits and deletions on Telegram are ignored. Posts older than the configured TTL are purged automatically.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/serjteplov/tg-mcp-spy'
If you have feedback or need assistance with the MCP directory API, please join our Discord server