mcpgram
mcpgram is a self-hosted corporate Telegram MCP (Model Context Protocol) server written in Go. It allows team members to connect their AI agents—such as Cursor, Claude Desktop, Claude Code, OpenCode, or CLI agents—directly to work Telegram group chats over Streamable HTTP while keeping all messages strictly inside company infrastructure.
Most corporate knowledge in design studios and engineering teams ends up buried across dozens of active Telegram groups, Forum Topics, and voice notes. I built mcpgram to make that collective context safely queryable by agents without sacrificing privacy or exposing write permissions: Telegram chat membership acts as the live source of truth for access control, personal DMs are never touched, and the server ingests updates solely via outbound Long Polling with no inbound webhooks or public ports required.
The server compiles into a single static zero-CGO binary backed by SQLite WAL + FTS5, running in lite mode on 256 MB of RAM—or scaling into a 100% air-gapped pro deployment paired with local Ollama and Whisper sidecars for hybrid semantic search, nightly chat digests, and in-memory voice transcription.
Key Architecture & Security Principles
- Hybrid RBAC & Fail-Closed Isolation: Real-time chat_member push updates combined with a 5-minute TTL chat_acl cache and live getChatMember verification. Network failures fail closed at the SQL layer, with per-chat full_history or since_join policies.
- Strictly Read-Only MCP Surface: Exposes five read-only tools (list_chats, get_digests, search_messages, get_messages, get_thread) with zero send/edit/delete capabilities. All chat payloads are wrapped in untrusted_text envelopes against indirect prompt injection.
- Zero-Secret Onboarding (OAuth 2.1): Supports full MCP OAuth 2.1 (RFC 9728/8414/7591 + PKCE S256) with one-click Telegram deep-link confirmation, plus SHA-256 hashed Bearer tokens for CLI agents. Tokens stay in the MCP client config and never enter LLM prompts.
- Local-First AI & Archive Backfill: Optional local bge-m3 vector RRF search, nightly qwen2.5 structured digests, in-memory Whisper voice/video transcription (no media stored on disk), #offrecord opt-out, and drag-and-drop JSON/HTML history import directly in Bot DM.