Telegram Human-in-the-Loop MCP Server
Integrates with the Telegram Bot API to send AI prompts and questions to a user's Telegram chat, wait for their response, and return it to the AI. Supports text replies, photos with OCR extraction, voice message transcription, rich text formatting, and long-message splitting, enabling human-in-the-loop communication through Telegram.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
๐ค๐ฌ Telegram Human-in-the-Loop MCP Server
Let your AI talk to you through Telegram. This MCP server gives any AI coding assistant the ability to pause, ask you questions, and wait for your reply โ right in your Telegram chat. Now with rich text formatting, image support, local file browsing, window screenshots, OCR, and voice message transcription.
๐ What is this?
When an AI agent works on your code, it sometimes needs to ask you a question โ "What should I name this?", "Which approach do you prefer?", "Is this the right file?"
This server intercepts those questions and sends them to your Telegram. You reply on your phone (or desktop Telegram), and the AI continues working with your answer.
No browser tabs. No terminal switching. Just Telegram.
Related MCP server: Prompt for User Input MCP Server
โจ Key Features
๐ฌ Bidirectional Text Communication
AI sends prompts to your Telegram chat
You reply with text โ AI receives it and continues working
Supports multi-line input, choices, confirmations, and info messages
Rich text formatting โ AI messages render with bold, italic,
inline code, andcode blocksin Telegram (Markdown โ HTML conversion with automatic plain-text fallback)Auto-splitting for long messages โ messages over 4096 chars are automatically chunked at paragraph/newline/space boundaries with part indicators (๐ 1/3, 2/3, etc.)
๐ธ Image Support (Telegram โ AI)
Send photos from your phone/desktop directly to the AI
Images are forwarded as MCP
ImageContentโ the AI can "see" what you sendIncludes OCR extraction โ text in photos is automatically extracted
Perfect for: sharing error screenshots, UI mockups, diagrams, handwritten notes
๐๏ธ Local Image Browsing (AI โ AI)
AI can read any image file from the local filesystem
Browse folders to discover and preview multiple images at once
Automatic resizing for large images (configurable max size)
Optional OCR text extraction from local images
Supports PNG, JPEG, GIF, BMP, WebP, TIFF, SVG
Toggleable via
HITL_IMAGE_TOOLS_ENABLEDenvironment variable
๐ฅ๏ธ Window Screenshots (AI โ Telegram)
AI can capture screenshots of any window by title
Win32 PrintWindow API โ works even for minimized or occluded windows
Automatic OCR text extraction from captured screenshots
Results returned as image + metadata (dimensions, OCR text, confidence)
๐ค Voice Message Transcription (Whispr)
Send voice messages in Telegram โ they are transcribed to text automatically
Uses a local Whisper model (Whispr module) for privacy
Transcribed text is sent to the AI as a regular text response
Edit tracking: shows original transcription plus any edits applied
๐ Fallback System
If Telegram is not configured, all tools fall back to native GUI popups (tkinter)
Works offline with local dialog boxes
Graceful degradation โ never blocks the AI
๐งฉ Compatible Platforms
Platform | Status | Config location |
VS Code (GitHub Copilot Agent Mode) | โ Fully tested | User |
VS Code (Copilot Chat) | โ Works | Same as above |
Claude Code (CLI) | โ Compatible |
|
Claude Desktop | โ Compatible | See config examples below |
Cursor | โ Compatible |
|
Windsurf (Codeium) | โ Compatible |
|
Cline | โ Compatible | Via Cline MCP settings UI |
Any MCP stdio client | โ Compatible | Pass |
The server uses the standard MCP stdio transport โ it works with any client that supports MCP.
๐ Available Tools
Tool | Description |
| Send a prompt to Telegram, wait for the user's reply. Supports text, photos (returned as ImageContent + OCR), and voice messages (Whispr transcription). Main communication tool. |
| Simple text/number input dialog |
| Multiple choice selection dialog |
| Read a single image file from the local filesystem. Resizes if needed, optional OCR. Returns image + metadata. |
| Browse a folder for images. Returns up to N images with thumbnails + metadata. Supports sorting, filtering, recursive scan. |
| Capture a screenshot of any window by title. Uses Win32 PrintWindow (works minimized). Returns image + OCR metadata. Windows only. |
| Yes/No confirmation dialog |
| Display information to the user |
| Enable/disable voice message transcription module |
| Check server status, Telegram connectivity, available features |
๐ง How it Works
โโโโโโโโโโโโโโโโ MCP stdio โโโโโโโโโโโโโโโโโ Telegram API โโโโโโโโโโโโโ
โ AI Agent โ โโโโโโโโโโโโโโโโโโบ โ HITL Server โ โโโโโโโโโโโโโโโโโโบ โ You โ
โ (Copilot, โ tool calls + โ (Python) โ send message โ Telegram โ
โ Claude...) โ results โ โ wait for reply โ โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโThe AI calls
get_multiline_input(or another tool)The server sends the prompt to your Telegram chat via Bot API
You read the message on your phone/desktop and reply (text, photo, or voice)
The server captures your reply and returns it to the AI
The AI continues working with your input
Image Flow
You (Telegram) HITL Server AI Agent
โ โ โ
โโโ Send photo โโโโโโโโโโโโโโโโโโโบโ โ
โ โโโ Download image โ
โ โโโ Run OCR extraction โ
โ โโโ Return ImageContent โโโโโโโโโบโ
โ โ + OCR text metadata โ
โ โ โโโ AI "sees" the imageWindow Screenshot Flow
AI Agent HITL Server AI Agent
โ โ โ
โโโ get_window_screenshot โโโโโโโบโ โ
โ (window_title="Settings") โโโ Find window by title โ
โ โโโ Win32 PrintWindow capture โ
โ โโโ Run OCR on screenshot โ
โ โโโ Return image + metadata โโโโบโ
โ โ โโโ AI processes screenshotFallback: If Telegram is not configured, all tools fall back to native GUI popups (tkinter).
๐ Quick Start
Prerequisites
Python 3.10+
A Telegram Bot token (create via @BotFather)
Your Telegram Chat ID
Installation
git clone https://github.com/theohero/telegram-human-in-the-loop.git
cd telegram-human-in-the-loop
git checkout main
pip install fastmcp pydanticOptional dependencies (for full feature set):
pip install pygetwindow pyautogui Pillow numpy rapidocr-onnxruntimePackage | Required for |
| Window screenshot capture |
| Fallback screenshot method |
| Image processing |
| OCR support |
| OCR text extraction from images |
Environment Variables
Variable | Required | Description |
| Yes | Your Telegram Bot API token |
| Yes | Your personal Telegram Chat ID |
| No | Timeout for waiting for reply (default: 3600) |
VS Code Configuration (GitHub Copilot)
Add to your .vscode/mcp.json or user mcp.json:
{
"servers": {
"hitl-mcp-server": {
"type": "stdio",
"command": "python",
"args": ["path/to/hitl_mcp_server.py"],
"env": {
"HITL_TELEGRAM_BOT_TOKEN": "your-bot-token-here",
"HITL_TELEGRAM_CHAT_ID": "your-chat-id-here"
}
}
}
}Claude Desktop Configuration
Add to your Claude Desktop config:
{
"mcpServers": {
"hitl-mcp-server": {
"command": "python",
"args": ["path/to/hitl_mcp_server.py"],
"env": {
"HITL_TELEGRAM_BOT_TOKEN": "your-bot-token-here",
"HITL_TELEGRAM_CHAT_ID": "your-chat-id-here"
}
}
}
}Claude Code (CLI)
{
"mcpServers": {
"hitl-mcp-server": {
"command": "python",
"args": ["path/to/hitl_mcp_server.py"],
"env": {
"HITL_TELEGRAM_BOT_TOKEN": "your-bot-token-here",
"HITL_TELEGRAM_CHAT_ID": "your-chat-id-here"
}
}
}
}๐ Finding Your Chat ID
Open Telegram and search for @userinfobot
Send it any message โ it replies with your Chat ID
Copy the number (e.g.,
123456789)
Alternative: Open https://web.telegram.org, go to any chat, and look at the URL โ the number after # is your Chat ID.
๐ธ Image Capabilities in Detail
Receiving Images from Telegram
When you send a photo in Telegram as a reply to the AI's prompt:
The server downloads the highest-resolution version of the photo
Runs OCR (Optical Character Recognition) to extract any text in the image
Returns mixed MCP content:
TextContent(metadata + OCR text) +ImageContent(the actual image)The AI receives both the image and any extracted text
Response metadata includes:
{
"success": true,
"user_input": "caption or OCR text",
"has_image": true,
"image_width": 1920,
"image_height": 1080,
"image_file_size": 245000,
"image_mime_type": "image/jpeg",
"ocr_enabled": true,
"ocr_text": "extracted text from the image",
"ocr_lines": ["line 1", "line 2"],
"ocr_avg_confidence": 0.95
}Window Screenshots
The get_window_screenshot tool captures any window by title:
# AI calls this tool with:
get_window_screenshot(window_title_contains="Settings", max_size=1400)Capture strategy:
Primary: Win32 PrintWindow API โ works even for minimized or occluded windows (Windows only)
Fallback: pyautogui region capture โ requires the window to be visible
The screenshot is returned as:
TextContentwith metadata (title, dimensions, OCR text)ImageContentwith the actual screenshot image
๐ค Voice Message Support (Whispr)
The server includes an optional Whispr module for local voice-to-text transcription using faster-whisper (CTranslate2-based Whisper).
How It Works
You send a voice message in Telegram
Whispr downloads the audio and transcribes it locally using a Whisper model
The transcribed text is sent to the AI as a regular text response
Metadata includes original transcription and any edits
Setup โ Zero Configuration
Whispr auto-installs everything when you first enable it:
From Telegram: Tap
/whispr_onin any message footer (shown at the bottom of every AI message)From AI: The
toggle_whisprMCP tool auto-installs dependencies and downloads the model
No pip install, no model downloads, no terminal โ just tap and go.
Commands
Command | Description |
| Enable voice transcription (auto-installs if needed) |
| Disable voice transcription |
| Show current Whispr status and settings |
| Change model: |
| Set language: |
Message Footer
Every AI message includes a Whispr status footer at the bottom:
๐ Whispr: OFF ยท /whispr_on โ tap to enable
๐ Whispr: ON ยท /whispr_off โ tap to disableModels
Model | Size | Speed | Accuracy | Best for |
| ~75 MB | Fastest | Basic | Quick notes, short phrases |
| ~150 MB | Fast | Good | General use (default) |
| ~500 MB | Medium | Better | Longer messages |
| ~1.5 GB | Slower | High | Detailed transcription |
| ~3 GB | Slowest | Best | Maximum accuracy |
Environment Variables
Variable | Default | Description |
|
| Enable Whispr on server start |
|
| Whisper model to use |
| (auto) | Language code, or empty for auto-detect |
Models are cached locally in ~/.hitl-mcp/whispr_models/.
โ FAQ
Q: Is there a message length limit? A: No practical limit. Messages over 4096 characters (Telegram's limit) are automatically split into multiple messages with part indicators. The reply keyboard is attached only to the last chunk.
Q: Do I need all the optional dependencies?
A: No. The core functionality (text chat via Telegram) only needs fastmcp and pydantic. Install optional packages only for the features you want.
Q: Can I disable the image file browsing tools?
A: Yes. Set HITL_IMAGE_TOOLS_ENABLED=false in your environment or MCP config. The get_image and list_images tools will not be registered.
Q: Does it work without Telegram? A: Yes! All tools fall back to native GUI popup dialogs (tkinter) when Telegram is not configured.
Q: Can the AI see my photos? A: Only photos you explicitly send as replies to the AI's prompts. The server does not access your Telegram in any other way.
Q: Is OCR always enabled?
A: OCR runs automatically if rapidocr-onnxruntime, numpy, and Pillow are installed. If not installed, images are still forwarded but without OCR text extraction.
Q: Does it work on macOS/Linux?
A: Text communication and image support work everywhere. Window screenshots (get_window_screenshot) currently use Win32 APIs and only work on Windows.
๐ Environment Variables Reference
Variable | Default | Description |
| โ | Telegram Bot API token (from @BotFather) |
| โ | Your Telegram Chat ID |
|
| How long to wait for a reply (seconds) |
|
| Enable/disable |
|
| Enable/disable OCR text extraction from images |
|
| Enable voice transcription on server start |
|
| Whisper model size ( |
| (auto) | Language code for transcription ( |
|
| Logging level |
๐ License
MIT License. See LICENSE for details.
๐ Credits
Built with FastMCP and the Telegram Bot API.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
This server cannot be deployed
Maintenance
Related MCP Connectors
Let your AI agent ask a person for a decision, a date or a photo, and get a structured answer back.
Give any AI agent a way to ask a person โ for approval, a decision, an answer or a review.
Connect ChatGPT, Claude, Cursor or VS Code to your Windows PC: files, terminal, browser, apps.
Generate AI images, videos, music, SFX & speech in any AI assistant. Results appear inline in chat.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to request human input through a web interface, allowing them to pause execution and wait for responses via interactive tools like single questions, multiple choice selections, hypothesis challenges, and decision workflows.2MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI models to interactively prompt users for input or clarification directly through their code editor. It facilitates real-time communication between assistants and users during development tasks.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to request user input through interactive popups in VS Code, supporting button selections, text inputs, and confirmation dialogs. This system allows for seamless human-in-the-loop interactions without interrupting the conversational flow.4-
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with humans through GUI dialogs for text input, choices, confirmations, and information display.6MIT