telegram-bot-mcp

telegram-bot-mcp

Lets Claude manage a Telegram channel through the Bot API, including tracking subscriber growth and publishing, editing, pinning, or deleting posts.

Category
Visit Server

README

telegram-bot-mcp

An MCP server that lets Claude manage a Telegram channel through the Telegram Bot API — track subscriber growth day over day, and publish, edit, pin, or delete posts.

🇮🇷 راهنمای فارسی · Deployment guide · راهنمای دپلوی


What this is

Telegram's Bot API is a plain HTTPS API. This repository wraps it in the Model Context Protocol so an AI assistant can call it as tools — "how did the channel do this week?" instead of curl https://api.telegram.org/bot.../getChatMemberCount.

It ships in two forms, from the same tool definitions:

Remote server (remote/) Local plugin (plugin/)
Runs on Val Town (or any Deno-compatible host) Your own machine
Connects via Claude custom connector (OAuth) Claude Code plugin (stdio)
Works in Claude web, desktop, mobile, scheduled tasks Claude Code CLI
Persistence Val Town blob storage CSV file on disk
Auth Built-in OAuth 2.1 + password gate Local config file
Needs your computer on No Yes

Pick the remote server if you want daily reports that run without you. Pick the plugin if you only use Claude Code and prefer nothing leaving your machine.

Tools

Both builds expose the same eight tools.

Tool Description
get_channel_info Title, username, description, subscriber count, admin count, invite link
get_member_count Subscriber count only — fast
snapshot_members Record today's count, return the change since the previous snapshot
get_growth_history Recorded snapshots with per-day changes and a net-change summary
send_post Publish a text post (HTML/Markdown, silent, no-preview options)
edit_post Replace the text of a post
delete_post Delete a post by message id
pin_post Pin or unpin a post

Quick start (remote server)

  1. Create a bot with @BotFather/newbot → copy the token.
  2. Add the bot as an administrator of your channel.
  3. Create an HTTP val on val.town and paste in remote/telegram-mcp.ts.
  4. Set three environment variables in the val's sidebar: TELEGRAM_BOT_TOKEN, TELEGRAM_CHANNEL, MCP_PASSWORD.
  5. In Claude: Settings → Connectors → Add custom connectorhttps://<your-val>.web.val.run/mcp → enter your password.

Full walkthrough, including the local plugin path and troubleshooting: docs/deployment.md.

Security

No credentials are committed to this repository. config.json and .env are gitignored; only .example files are tracked. Before pushing any fork, confirm with git status that neither appears.

The remote server implements a full OAuth 2.1 authorization flow rather than sitting open on the internet:

  • Requests without a valid bearer token get 401 with a WWW-Authenticate header pointing at the resource metadata, per RFC 9728.
  • Clients register dynamically (RFC 7591); no client secrets to distribute.
  • Authorization codes are protected with PKCE (S256), and redirect URIs are validated against the registered set.
  • Access and refresh tokens are HMAC-SHA256 signed and stateless — 24-hour access, 30-day refresh.
  • The consent screen is gated by MCP_PASSWORD, which you choose.

Your bot token stays in the host's environment variables and is never returned by any tool.

Treat MCP_PASSWORD like a password to your channel. Anyone who has it can connect and publish posts.

Limitations

The Bot API reports subscriber counts only. Post views, forwards, reach, and Telegram's official channel-statistics graphs are not exposed to bots — those require an MTProto client signed in with a user account that administers the channel.

A bot can generally only edit messages it sent itself. Telegram defines a can_edit_messages administrator right ("can edit messages of other users; for channels only"), but bot behaviour against posts published by human admins is not clearly documented — test it against your own channel before relying on it. Deletion is different: can_delete_messages explicitly covers other users' messages.

Growth comparison requires the history store to survive between runs. On Val Town that is blob storage and it persists. In the local plugin it is a CSV file — keep it somewhere durable, not a temp directory.

Repository layout

remote/telegram-mcp.ts              Remote MCP server (Val Town HTTP val, Deno)
plugin/                             Claude Code plugin
  .claude-plugin/plugin.json          Plugin manifest
  .mcp.json                           stdio MCP server registration
  server/telegram_mcp_server.py        MCP server (Python 3, stdlib only)
  skills/telegram-channel-report/      Skill that turns tools into a readable report
  config.example.json                  Template — copy to config.json
tests/                              Test suite for the remote server
docs/                               Deployment guides (English / فارسی)

Tests

npm test

Requires Node 22.6+. Twenty-two checks cover the OAuth flow (401 challenge, discovery documents, dynamic registration, PKCE rejection, token and refresh grants, forged-token rejection) and the MCP protocol (initialize, notifications, tool listing, growth-delta arithmetic, tool error paths). The Telegram API is mocked; no network access and no real bot token are needed.

The suite runs against the deployed source itself — tests/build.mjs rewrites exactly one line, the Val Town blob import, and changes nothing else.

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured