Get Claude Code in your local project talking to Telegram in 3 minutes! TSGram MCP connects Claude Code sessions to Telegram using TS/Node/Docker/cli-utils, enabling AI-powered code assistance directly in your Telegram chats. Ask questions about your codebase, get AI insights, and even edit files - all from Telegram on your phone! - Local Docker container runs the Telegram webhook server - TSGram
Add this skill
npx mdskills install areweai/tsgram-mcpBridges Claude to Telegram via MCP with local Docker deployment and web dashboard management
1# TSGram MCP ๐23**Get Claude Code in your local project talking to Telegram in 3 minutes!**45<img src="assets/IMG_3908.PNG" alt="TSGram in action - viewing package.json" height="450">67TSGram MCP connects Claude Code sessions to Telegram using TS/Node/Docker/cli-utils, enabling AI-powered code assistance directly in your Telegram chats. Ask questions about your codebase, get AI insights, and even edit files - all from Telegram on your phone!89## ๐ How It Works (All Local)10- Local Docker container runs the Telegram webhook server11- TSGram MCP server runs locally12- Your Claude Code or Claude Desktop runs locally and adds MCP locally13- Create and delete bots in-app through Telegram, access limited to your telegram user id14- Modern local web dashboard to manage bots from localhost15- Local means local! If your computer is offline, so are your bots.1617## Quick Start (3 Minutes)1819### ๐ค AI Agent Enhanced Setup (Recommended!)2021Let Claude handle the entire setup and ask you for the required values.2223**From your terminal:**240. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) and [Node.js 20+](https://nodejs.org/en/download) (npm included)251. Clone the repository:26 ```bash27 git clone https://github.com/areweai/tsgram-mcp.git28 cd tsgram-mcp29 ```30312. From the command line, start Claude:32 ```bash33 claude --model sonnet34 ```35363. Initialize with `/init`37384. Copy and paste this prompt:39 > First, explain to the human how to register a new Telegram bot with @BotFather and get their bot token (TELEGRAM_BOT_TOKEN), and how to get their Telegram user ID from @userinfobot (for AUTHORIZED_CHAT_ID). They can work on getting these credentials while you set up the system. Then help the user set up tsgram-mcp for claude code. Do everything from installing node modules to creating and deploying the local docker containers. Finally, when everything is deployed, remind the user to configure their bot token and authorized chat ID along wither other required .env variables.4041Make sure you replace the `TELEGRAM_BOT_TOKEN` and `AUTHORIZED_CHAT_ID` placeholders with the actual values.4243In order to retrieve those values, you will have to message the following Telegram bots and follow their instructions:44- [@BotFather](https://t.me/botfather)45- [@userinfobot](https://t.me/userinfobot)4647The AI will then handle all the setup steps for you, including:48- Installing dependencies49- Configuring environment variables50- Building Docker containers51- Starting services52- Guiding you through bot registration53- Setting up the MCP server (and allow you to extend functionality locally)5455**CLI no-AI Alternative If Hitting LLM troubles: Setup Shell Script**56Run from your project root:57```bash58# One-line install (macOS/Linux)59curl -sSL https://raw.githubusercontent.com/areweai/tsgram-mcp/main/setup.sh | bash6061# Or if you prefer to review first:62curl -sSL https://raw.githubusercontent.com/areweai/tsgram-mcp/main/setup.sh > setup.sh63chmod +x setup.sh64./setup.sh65```6667**Adding TSGram to an Existing Project:**6869If you already have a project and want to add TSGram as an MCP server:70711. From your existing project root:72 ```bash73 git clone https://github.com/areweai/tsgram-mcp.git .tsgram-mcp74 cd .tsgram-mcp75 ```76772. Use Claude to set it up:78 ```bash79 claude model --sonnet80 /init81 ```82833. Paste this prompt:84 > "First, explain to the human how to register a new Telegram bot with @BotFather and get their bot token (TELEGRAM_BOT_TOKEN) from @UserBotInfoBot, and how to get their Telegram user ID from @userinfobot (for AUTHORIZED_CHAT_ID). They can work on getting these credentials while you set up the system. Then help me add TSGram MCP to my existing project in the parent directory. Set up the Docker containers and MCP configuration so I can use Telegram to interact with my project files. The project root is one level up from here."8586This will configure TSGram to work with your existing project structure (and allow you to extend functionality locally).8788### Test Your Bot! ๐89**IMPORTANT: You will need to message your bot first before it can message you.**9091Send your bot a message and ask it something about your local project!9293<img src="assets/IMG_3913.PNG" alt="TSGram file permissions and dangerzone mode" height="450">94959697**โ ๏ธ Security Note**: TSGram has basic safeguards to not list, preview, or serve .env files but it is still strongly recommended that you do not use TSGram for anything highly sensitive as third party servers are part of the transport layer.9899## ๐ Web Dashboard100101Monitor and manage your bots through the beautiful web dashboard at **http://localhost:3000**:102103<img src="assets/tsgram-dashboard-1.png" alt="TSGram Web Dashboard - Bot management interface" width="600">104105The dashboard provides:106- **Real-time bot status** and activity monitoring107- **System health** indicators (MCP server, AI model, API keys)108- **Bot management** - create, test, and monitor Telegram bots109- **Activity logs** - track messages, responses, and system events110- **Quick actions** - send test messages and manage bot configurations111- **run from local** - npm run dashboard to view (chrome recommended)112113## ๐ You Will Need114115- [Docker Desktop](https://www.docker.com/products/docker-desktop/)116- [Node.js 20+](https://nodejs.org/en/download) (npm included)117- Telegram on a phone118- Claude Desktop or Claude Code (CLI)119- An OpenRouter API key (We recommend creating a new API key with a $1.00 limit. Trust, but limit!)120- Chrome (Optional but highly recommended for local management UI)121122## Manual Setup Steps123124### 1. Get Your Bot Token & User ID1251. **Create Bot**: Message [@BotFather](https://t.me/botfather) on Telegram1262. Send `/newbot` and follow prompts1273. Copy your bot token (keep this secret!)1284. **Get Your User ID** (IMPORTANT): Message [@userinfobot](https://t.me/userinfobot)129 - This returns your numeric user ID (e.g., `123456789`)130 - **Use the user ID, NOT your username** for security (usernames can be changed)131132### 2. Configure Environment133Edit `.env` with your values:134```env135TELEGRAM_BOT_TOKEN=your_bot_token_here136# CRITICAL: Use your numeric user ID from @userinfobot, not your username!137AUTHORIZED_CHAT_ID=123456789 # Your numeric user ID from step 1138139# Choose ONE AI provider:140OPENROUTER_API_KEY=your_openrouter_key # For Claude (recommended with $1 limit)141# OR142OPENAI_API_KEY=your_openai_key # For GPT-4143```144145**Security Note**: The bot now uses your **numeric user ID** instead of username for authorization. This is more secure because:146- User IDs never change147- Usernames can be changed by users148- User IDs cannot be guessed or easily discovered149150### 3. Start TSGram151```bash152npm install153npm run docker:build154npm run docker:start155```156157## ๐ฏ Key Features158159- **"Stop" and "Start" commands** in TSGram bot chat provide convenient output control160- **Select subset of unix commands supported** (`:h ls` or `:h cat $FILE`)161- **Opt-in edit mode** for vibe coding and debugging on the go (`:dangerzone` to enable)162- **AI-Powered Responses**: Uses Claude 3.5 Sonnet or GPT-4163- **Code Understanding**: Reads and analyzes your entire codebase164- **Web Dashboard**: Monitor bots at http://localhost:3000165166## ๐ฌ Bot Commands167168- **Regular messages**: Get AI responses about your code169- **`:h`** - Show help and available commands170- **`:h ls [path]`** - List files in directory171- **`:h cat filename`** - View file contents172- **`:dangerzone`** - Enable file editing (careful!)173- **`:safetyzone`** - Disable file editing174- **`stop`** - Pause bot responses175- **`start`** - Resume bot responses176177## ๐ ๏ธ Common Commands178179```bash180# View logs181npm run docker:logs182183# Check health184npm run docker:health185186# Stop services187npm run docker:stop188189# Rebuild after changes190npm run docker:rebuild191192# Access dashboard (Chrome recommended)193npm run dashboard194```195196## ๐ Useful Scripts197198The project includes several helper scripts in the `scripts/` directory:199200**Setup & Configuration**201- `setup.sh` - Automated install script (can be run via curl)202- `configure-mcp.sh` - Configure MCP settings for Claude Desktop/Code203- `fix-permissions.sh` - Fix file permissions if needed204205**Updates & Maintenance**206- `update-system.sh` - Update TSGram to latest version207- `update-ai-context.sh` - Update AI context files208209**Testing & Debugging**210- `test-api-keys.sh` - Verify your API keys are working211- `test-docker-setup.sh` - Test Docker configuration212213Run any script with:214```bash215./scripts/script-name.sh216# or217npm run script-name # for npm-wrapped scripts218```219220## ๐ง Advanced Setup221222### Using with Claude Code223Add to your Claude Code MCP settings:224```json225{226 "tsgram": {227 "command": "docker",228 "args": ["exec", "-i", "tsgram-mcp-workspace", "npx", "tsx", "src/mcp-server.ts"],229 "env": {230 "TELEGRAM_BOT_TOKEN": "your_bot_token_here",231 "AUTHORIZED_CHAT_ID": "123456789"232 }233 }234}235```236237**Note**: Replace `123456789` with your actual numeric user ID from [@userinfobot](https://t.me/userinfobot)238239### MCP Compatibility240241TSGram uses the standard Model Context Protocol (MCP) format and should be compatible with any MCP-supporting IDE or tool. **Tested with:**242- โ Claude Code CLI243- โ Claude Desktop244245**Should work with** (standard MCP format):246- Cursor IDE247- GitHub Copilot248- Other MCP-compatible editors249250Use the same Docker configuration pattern shown above, adapting the syntax for your specific MCP client.251252### CLI-to-Telegram Bridge253Forward Claude Code CLI responses to Telegram:254```bash255# Setup global command (may prompt for sudo password to create npm global install /usr/local/bin/claude-tg)256npm run setup257258# Use instead of 'claude'259claude-tg "analyze this codebase"260```261262## ๐จ Troubleshooting263264**Bot not responding?**265```bash266# Check if services are running267npm run docker:health268269# View logs for errors270npm run docker:logs271```272273**Can't connect to bot?**2741. Verify bot token is correct in `.env`2752. **Check your user ID**: Make sure `AUTHORIZED_CHAT_ID` is your numeric user ID (not username)276 - Get it from [@userinfobot](https://t.me/userinfobot) if unsure2773. Make sure you messaged the bot first2784. If you get "authorization not configured" error, set `AUTHORIZED_CHAT_ID` in your `.env` file279280**File edits not working?**281- Type `:dangerzone` to enable (one-time)282- Check logs for permission errors283- Ensure Docker has file access284285## ๐ Project Structure286287```288tsgram/289โโโ src/290โ โโโ telegram-bot-ai-powered.ts # Main bot logic291โ โโโ telegram-mcp-webhook-server.ts # MCP integration292โ โโโ models/ # AI providers293โโโ docker-compose.tsgram-workspace.yml # Main Docker config294โโโ .env.example # Environment template295โโโ data/ # Persistent storage296```297298## ๐ค Contributing299300PRs welcome! Please:3011. Fork the repository3022. Create a feature branch3033. Add tests if applicable3044. Submit a pull request305306## ๐ License307308MIT - Feel free to use in your own projects!309310---311312**Need help?** Open an issue on GitHub or message your bot with questions!
Full transparency โ inspect the skill content before installing.