Standalone Go MCP server that connects to Telegram MTProto and exposes tools for digest workflows.
main.go- MCP server + Telegram clientauth.go- OAuth/OIDC middleware and metadata/proxy endpointslogging.go- log level helpers (MCP_LOG_LEVEL=info|debug)auth_test.go- auth middleware testsMakefile- build/run/test/tunnel helpersDockerfile- multi-stage Linux container builddocker-compose.yml- local Docker Compose template
- Go 1.23+
- Telegram API credentials (
api_id,api_hash) from https://my.telegram.org/apps cloudflared(optional, for temporary public tunnel)- Docker + Compose plugin (optional, for containerized runs)
cp .env.example .env
# edit .env with your real values
make tidy
make build
make runFirst interactive run may ask for Telegram auth code.
cp .env.example .env
# edit .env with real values
docker compose buildFirst run should be interactive once to complete Telegram login and persist session:
make docker-authAfter successful login, start normally:
make docker-up
make docker-logsNotes:
- Compose stores Telegram session data in Docker volume
telegram_mcp_data. - Container sets
SESSION_DIR=/data, so gotd session is persisted across restarts. docker-compose.ymlbinds to127.0.0.1:8765by default for local-only exposure.- For reverse proxy only, remove
portsand attach the service to your proxy network.
Start server in no-auth mode:
make docker-up-noauthCheck MCP connectivity with FastMCP:
fastmcp list http://127.0.0.1:8765/mcpExpected result: FastMCP prints the available tools (3 tools in this server).
make tidy # go mod tidy
make test # go test ./...
make build # go build -o telegram-digest-mcp .
make run # run with current env
make run-debug # run with MCP_LOG_LEVEL=debug
make run-noauth # run with MCP_AUTH_MODE=off (local testing only)
make tunnel # cloudflared temporary tunnel to http://localhost:${PORT}
make docker-up # docker compose up -d --build
make docker-up-noauth # docker compose up -d --build with MCP_AUTH_MODE=off
make docker-down # docker compose down
make docker-logs # follow container logs
make docker-auth # interactive first run for Telegram OTP/2FADefaults:
BIN_NAME=telegram-digest-mcpPORT=8765
Override example:
make PORT=9000 tunnelSecure mode is default:
MCP_AUTH_MODE=oauthMCP_OAUTH_ISSUER=https://<tenant>.auth0.com/MCP_OAUTH_AUDIENCE=https://<your-public-host>/mcp(must exactly match Auth0 API Identifier)MCP_OAUTH_REQUIRED_SCOPES=mcp.readMCP_PUBLIC_BASE_URL=https://<public-host>
Detailed Auth0 setup guide: AUTH0_MCP_CONFIGURATION.md
The server exposes:
GET /.well-known/oauth-protected-resourceGET /.well-known/oauth-authorization-serverGET /authorize(proxy)POST /token(proxy)
This server exposes 3 MCP tools:
-
get_messages(channels, hours_back=24)Fetches recent posts from one or more public Telegram channels and returns text, timestamp, views, forwards, and message links. -
get_similar_channels(channels)Uses Telegram recommendations to find adjacent/similar channels for the provided seeds. -
expand_and_collect(seed_channels, depth=2, hours_back=24)Runs a full pipeline: expands from seed channels into nearby channels, then collects recent posts from the full discovered set.
Why this is useful for social-media bubble analysis:
- You can start from a known channel and map nearby communities automatically.
- You can compare narratives across adjacent bubbles instead of looking at one channel in isolation.
- You can feed structured, cross-channel data to AI for clustering, summarization, trend detection, and narrative drift analysis over time.
- Keep
.envand Telegram session files private. - Do not run with
MCP_AUTH_MODE=offon public internet. - Logs go to
stderr(MCP protocol usesstdout).