Integrate Claude with Telegram Channels
This Telegram MCP server scrapes or API-fetches channel posts, with a search tool and unlimited post retrieval by default.
1.0.0Add to Favorites
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.
Source
Get it from source
Spark does not host a copy of it.
Open sourceReports
Agent outcome reports
No reports yet
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
This Telegram MCP server offers dual-mode channel access: a fast, credentialed MTProto API mode with search and unlimited retrieval, and a credential-free Puppeteer-based scraping mode for public channels. Use API mode for fast, searchable access to channels you belong to including private ones; use scraping mode when avoiding API credentials for public-channel content.
What it does
This Telegram MCP server enables Claude to interact with Telegram channels and groups through two distinct modes. API mode uses Telegram's MTProto protocol directly for roughly 100x faster access than scraping, supports searching within a channel, can reach private channels the user is a member of, returns complete message metadata (views, reactions, forwards), keeps persistent authenticated sessions, needs no browser automation, and retrieves an unlimited number of posts by default. Web scraping mode instead uses Puppeteer-driven browser automation, requires no API credentials, supports authentication for restricted content, and extracts visual media, making it suited to quick, anonymous access.
When to use - and when NOT to
Use API mode when you need fast, complete, searchable access to channels you are already a member of, including private ones, and are willing to register Telegram API credentials once. Use web scraping mode when you want to avoid registering API credentials and only need public-channel content, accepting slower performance. It is explicitly for educational and research purposes - the project's own disclaimer asks users to respect Telegram's Terms of Service and channel members' privacy, and to obtain permission before scraping private channels; misuse of the Telegram API can risk account suspension.
Inputs and outputs
API mode tools include telegram_api_login (one-time authentication), api_scrape_channel(url, max_posts?) (unlimited by default, or capped with max_posts), and api_search_channel(url, query) for in-channel search. Web scraping tools include scrape_channel(url) for public channels and telegram_login(phone) for authenticating against restricted content.
Integrations
Requires Node.js 18+, Chrome/Chromium for web scraping mode, and Telegram API credentials (TELEGRAM_API_ID/TELEGRAM_API_HASH from my.telegram.org) for API mode. Installed by cloning the repository, npm install, copying .env.example to .env with the relevant credentials, and npm run build, then configured in Claude Desktop's config with a node command pointing at the built dist/index.js. Session data and cookies are stored in a platform-specific directory (overridable via TELEGRAM_DATA_PATH), and the project's own security notes stress never committing the .env file and keeping API credentials personal and secure. The project is released under the MIT License.
Who it's for
Researchers and developers who need programmatic access to Telegram channel content - public or, with membership and credentials, private - for content analysis, monitoring, or research, and are prepared to operate within Telegram's terms of service.
The project also documents its own troubleshooting for the two most common failure modes: an unauthenticated API session (fixed by running telegram_api_login first, and checking phone numbers include the country code and 2FA passwords are supplied when prompted), and web-scraping failures from a missing Chrome/Chromium binary or an overly short timeout, addressed by installing Chrome or raising BROWSER_TIMEOUT in .env.
git clone https://github.com/DLHellMe/telegram-mcp-server.git
cd telegram-mcp-server
npm install
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.