Telegram MCP Bridge

Telegram MCP Bridge

Enables MCP agents to request human confirmation for actions via a Telegram bot. It uses a Vercel-hosted proxy and Redis to facilitate secure, real-time YES/NO approvals from a mobile device.

Category
访问服务器

README

Telegram Confirmation MCP Bridge

A simple bridge to request human confirmation via Telegram from an MCP agent (like Antigravity).

Antigravity Configuration

To add this server to your Antigravity configuration (or any MCP client), use the following JSON block.

You need to replace:

  • <ABSOLUTE_PATH> with the absolute path where you cloned this repository.
  • <YOUR_VERCEL_URL> with your Vercel deployment URL (e.g., https://my-telegram-bot.vercel.app).
{
  "mcpServers": {
    "telegram-bot": {
      "command": "node",
      "args": ["<ABSOLUTE_PATH>/telegram-bot-mcp/mcp-server.js"],
      "env": {
        "VERCEL_URL": "https://<YOUR_VERCEL_URL>"
      }
    }
  }
}

Explanation

This script (mcp-server.js) acts as a local proxy. The agent communicates with it via stdio (standard), and the script makes HTTP requests to your Vercel backend, managing the question delivery and the polling (active waiting) for the response.


Architecture

  1. Agent (Local) → calls ask_telegram_confirmation
  2. Local Proxy (mcp-server.js) → calls POST /api/confirm on Vercel
  3. Vercel → sends a message to the Telegram Bot
  4. User → replies YES/NO on mobile
  5. Telegram → calls the Webhook POST /api/webhook on Vercel
  6. Vercel → saves the response in Redis (Upstash)
  7. Local Proxy → receives the response by polling GET /api/confirm-status
  8. Agent → receives the result "User replied: YES"

Installation and Deployment

1. Clone and Prepare

git clone https://github.com/aralroca/telegram-bot-mcp.git
cd telegram-bot-mcp
npm install

2. Configure Telegram

  1. Talk to @BotFather to create a bot (/newbot).
  2. Save the BOT_TOKEN.
  3. Get your CHAT_ID (send a message to the bot and check https://api.telegram.org/bot<TOKEN>/getUpdates).

3. Deploy to Vercel

npm run deploy

Configure environment variables in Vercel:

  • BOT_TOKEN: Your Telegram token.
  • CHAT_ID: Your chat ID.
  • ALLOWED_USER_ID: Your numeric user ID (for security).

Configure Upstash Redis (from Vercel Marketplace) for persistence.

4. Configure Webhook

Once deployed, register the Telegram webhook using your Vercel URL:

https://api.telegram.org/bot<BOT_TOKEN>/setWebhook?url=https://<YOUR_VERCEL_URL>/api/webhook

Troubleshooting and Tips

1. Vercel "401 Unauthorized"

If the agent receives a 401 error, it's likely due to Vercel Deployment Protection.

  • Go to your Vercel Dashboard → Settings → Deployment Protection.
  • Disable "Vercel Authentication".
  • This allows the local MCP proxy and Telegram webhooks to reach your API.

2. Forbidden (403)

Make sure the ALLOWED_USER_ID in your Vercel environment variables matches your actual Telegram User ID. You can find your ID by sending a message to @userinfobot.

3. State Persistence (Redis)

This bridge uses Redis to keep track of questions while waiting for your reply.

  • Use the Vercel Marketplace to add Upstash Redis.
  • Ensure it's Connected to your project in the Storage tab.
  • We support both REST protocol (UPSTASH_REDIS_REST_URL) and standard Redis protocol (REDIS_URL).
  • Redeploy your project after connecting the storage.

4. Continuous Polling (Wait state)

If the agent stays in a "Waiting" state even after you reply "YES":

  • Check if Redis is correctly initialized by visiting https://<YOUR_VERCEL_URL>/health.
  • You should see "redis_initialized": true.

5. Stable URLs

Always use the Production Domain (e.g., my-project.vercel.app) in your Antigravity configuration VERCEL_URL environment variable. Using the specific deployment URL (the one with the hash) will stop working after your next deploy.

How to use with an Agent

To trigger the confirmation, you should invoke the MCP server by its name (defined in your configuration, e.g., telegram-bot) in your prompt. This helps the agent select the correct tool.

Example Prompts:

  • "Use telegram-bot to ask for my confirmation before deleting any file."
  • "Tell telegram-bot to send me a confirmation request to proceed with the deployment."

What happens next:

  1. The agent will call the tool from the telegram-bot server.
  2. You will receive a message from your bot on Telegram: Should I proceed? Reply: YES / NO.
  3. The agent will stay in a "waiting" state while polling Vercel.
  4. Once you reply YES or NO on your phone, the agent will receive the answer and continue its task.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选