Integrate Claude with Telegram Channels
MCP server enabling Claude to scrape and search Telegram channels via API (100x faster) or web scraping, with support for private channels and unlimited post
Why it matters
Connect Claude to Telegram channels and groups for enhanced interaction. Leverage both API access and web scraping for efficient data retrieval and analysis.
Outcomes
What it gets done
Authenticate with Telegram API and access private channels.
Extract unlimited posts from public and private Telegram channels.
Search within Telegram channels using keywords.
Scrape public Telegram channels via web scraping.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-telegram-mcp-server | bash Capabilities
Tools your agent gets
Authenticate with Telegram API for first-time use to enable direct MTProto protocol access.
Extract posts from Telegram channels with unlimited retrieval using direct API access.
Search within a Telegram channel by keywords using the API.
Extract posts from public Telegram channels via web scraping with Puppeteer.
Login to access restricted Telegram content via web scraping mode.
Overview
Telegram-mcp-server MCP Server
Telegram-mcp-server is an MCP server that provides dual-mode access to Telegram channels: API mode using MTProto protocol and web scraping mode using Puppeteer. Use API mode for fast, frequent access to channels with search capabilities and metadata extraction; use web scraping mode for quick anonymous access to public channels without API credentials.
What it does
Telegram-mcp-server is an MCP (Model Context Protocol) server that enables interaction with Telegram channels and groups through two operational modes: a high-speed API mode using Telegram's MTProto protocol (100x faster than scraping) and a browser-based web scraping mode using Puppeteer. It provides tools for retrieving channel posts, searching within channels, accessing private channels you're a member of, and obtaining message metadata including views, reactions, and forwards.
When to use - and when NOT to
Use this connector when you need to analyze Telegram channel content, monitor public or private channels you belong to, search historical messages within channels, or extract data from Telegram posts for research or monitoring purposes. API mode is recommended for frequent access, large-scale retrieval (unlimited posts by default), and when you need search functionality or access to private channels. Web scraping mode suits quick, anonymous access to public channels without API setup.
Do NOT use this for scraping private channels you're not a member of, as it respects Telegram's access controls. Avoid web scraping mode for high-volume or frequent operations, as it's significantly slower than API mode.
Inputs and outputs
For API mode, you provide Telegram API credentials (api_id and api_hash from https://my.telegram.org), authenticate via telegram_api_login, then supply channel URLs and optional parameters like max_posts or search queries. For web scraping mode, you provide channel URLs and optionally phone numbers for authentication.
API mode provides complete message metadata including views, reactions, and forwards. Web scraping mode extracts visual media. Both modes retrieve message content from channels.
Integrations
Configured for Claude Desktop by adding to your config file:
{
"mcpServers": {
"telegram-scraper": {
"command": "node",
"args": ["/absolute/path/to/telegram-mcp-server/dist/index.js"],
"env": {
"TELEGRAM_API_ID": "your_api_id",
"TELEGRAM_API_HASH": "your_api_hash"
}
}
}
}
Built with GramJS (Telegram client library) for API access and Puppeteer for browser automation. Requires Node.js 18.0.0 or higher and Chrome/Chromium for web scraping mode.
Who it's for
Researchers analyzing Telegram content at scale, developers building Telegram monitoring tools, analysts tracking public discourse across channels, and users needing programmatic access to Telegram data. API mode serves users with Telegram developer credentials who need fast, reliable access and search capabilities. Web scraping mode suits users wanting quick public channel access without API setup. API mode features persistent sessions requiring authentication only once.
Source README
Telegram MCP Server
A powerful MCP (Model Context Protocol) server that enables Claude to interact with Telegram channels and groups. This server provides both web scraping and direct API access to Telegram content.
๐ Features
Version 0.3.0 - Dual Mode Operation
API Mode (Recommended) โก
- 100x faster than web scraping
- Direct access via Telegram's MTProto protocol
- Search functionality within channels
- Access to private channels you're a member of
- Complete message metadata (views, reactions, forwards)
- Persistent sessions - authenticate once
- No browser automation needed
- Unlimited post retrieval by default
Web Scraping Mode ๐
- No API credentials required
- Browser-based scraping with Puppeteer
- Authentication support for restricted content
- Visual media extraction
- Suitable for quick, anonymous access
๐ Prerequisites
- Node.js 18.0.0 or higher
- Chrome/Chromium (for web scraping mode)
- Telegram API credentials (for API mode) - Get them here
๐ ๏ธ Installation
- Clone this repository:
git clone https://github.com/DLHellMe/telegram-mcp-server.git
cd telegram-mcp-server
- Install dependencies:
npm install
- Copy the example environment file:
cp .env.example .env
Edit
.envand add your configuration:- For API mode: Add your
TELEGRAM_API_IDandTELEGRAM_API_HASH - For web scraping: Default settings work out of the box
- For API mode: Add your
Build the project:
npm run build
๐ง Configuration
Getting Telegram API Credentials
- Go to https://my.telegram.org
- Log in with your phone number
- Click "API development tools"
- Create a new application
- Copy your
api_idandapi_hashto the.envfile
Claude Desktop Configuration
Add this to your Claude Desktop config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"telegram-scraper": {
"command": "node",
"args": ["/absolute/path/to/telegram-mcp-server/dist/index.js"],
"env": {
"TELEGRAM_API_ID": "your_api_id",
"TELEGRAM_API_HASH": "your_api_hash"
}
}
}
}
๐ Usage
After configuration, restart Claude Desktop. The Telegram tools will be available in Claude.
API Mode Tools
telegram_api_login - Authenticate with Telegram (first time only)
Use telegram_api_login to connect to Telegramapi_scrape_channel - Scrape channel posts (unlimited by default)
Use api_scrape_channel with url="https://t.me/channelname"Or with a limit:
Use api_scrape_channel with url="https://t.me/channelname" and max_posts=50api_search_channel - Search within a channel
Use api_search_channel with url="https://t.me/channelname" and query="keyword"
Web Scraping Tools
scrape_channel - Scrape public channels
Use scrape_channel with url="https://t.me/channelname"telegram_login - Login for restricted content
Use telegram_login with phone="+1234567890"
๐ Data Storage
Session data and cookies are stored in platform-specific directories:
- Windows:
%APPDATA%\telegram-mcp-data - macOS:
~/Library/Application Support/telegram-mcp-data - Linux:
~/.config/telegram-mcp-data
You can override this with the TELEGRAM_DATA_PATH environment variable.
๐ก๏ธ Security Notes
- Never commit your
.envfile - it contains sensitive API credentials - API credentials are personal - each user needs their own
- Session files contain authentication data - keep them secure
- Use the
.gitignorefile to prevent accidental commits
๐ Development
# Run in development mode
npm run dev
# Build the project
npm run build
# Watch for changes
npm run watch
๐ค Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
๐ License
MIT License - see LICENSE file for details
๐ Acknowledgments
Built with:
- Model Context Protocol SDK
- GramJS - Telegram client library
- Puppeteer - Browser automation
โ ๏ธ Disclaimer
This tool is for educational and research purposes. Please respect Telegram's Terms of Service and the privacy of channel members. Always obtain permission before scraping private channels.
๐ Troubleshooting
API Mode Issues
- "Not connected to Telegram API": Run
telegram_api_loginfirst - Phone number format: Include country code (e.g., +1234567890)
- 2FA errors: Enter your 2FA password when prompted
Web Scraping Issues
- "No Chrome binary found": Install Chrome or Chromium
- Login issues: Ensure you're using the correct phone format
- Timeout errors: Increase
BROWSER_TIMEOUTin.env
๐ Support
- Create an issue on GitHub for bugs
- Check existing issues before creating new ones
- Include error messages and logs when reporting issues
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.