MCP Token Bridge

MCP Token Bridge

Bridges MCP tool calls with OpenAI-compatible HTTP endpoints, allowing MCP clients to forward chat completion requests through a unified FastAPI server that returns responses with MCP-specific headers.

Category
访问服务器

README

MCPTokenBridge

Overview (English)

MCPTokenBridge is a single-file Python bridge that simultaneously runs an OpenAI-compatible /v1/chat/completions HTTP endpoint (FastAPI + uvicorn) and a stdin-based MCP tool named hook. The hook worker thread never stops; it drains an internal queue so web requests are forwarded to MCP and returned with X-MCP-* headers. The process has only one entrypoint and starts both services together.

概览(中文)

MCPTokenBridge 是一个单文件的 Python 桥接程序,同时运行 OpenAI 风格的 /v1/chat/completions HTTP 接口(FastAPI + uvicorn)和基于 STDIN 的 MCP 工具 hookhook 工作者线程常驻,持续从队列中取出请求并返回带有 X-MCP-* 头的结果;整个流程只有一个入口,启动即同时运行两种服务。

Getting Started / 快速开始

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Run: single entry (HTTP + MCP) / 运行方式:单一入口(HTTP + MCP)

python mcptb.py --host 0.0.0.0 --port 8000
# MCP stdin is handled on the same process; for example:
echo '{"jsonrpc":"2.0","id":1,"method":"initialize"}' | python mcptb.py --host 0.0.0.0 --port 8000

Network binding guidance / 网络绑定说明

  • English: Use --host 0.0.0.0 when you want every network adapter (e.g., 192.168.55.10:8888 and 192.168.1.11:8888) to be reachable on the same port. Use a specific host (e.g., --host 192.168.55.10 --port 8888) to bind only that adapter; other adapters will not accept connections.
  • 中文:当需要让所有网卡(例如 192.168.55.10:8888192.168.1.11:8888)都可访问时,使用 --host 0.0.0.0。若只想绑定某个适配器,请指定具体地址(如 --host 192.168.55.10 --port 8888);此时其他适配器将无法访问。

Flow (English)

  1. HTTP POST /v1/chat/completions enqueues the request and waits for the hook worker reply.
  2. The hook tool never terminates; it runs on a fixed background thread and returns MCP headers along with the chat response.

工作流(中文)

  1. HTTP POST /v1/chat/completions 会将请求入队,等待 hook 工作者返回结果。
  2. hook 工具常驻后台线程,不会结束,同时返回 MCP 相关的响应头与聊天内容。

Project Layout / 目录结构

  • mcptb.py — single runtime module for both HTTP and MCP modes / 兼作 HTTP 与 MCP 入口的单文件模块
  • requirements.txt — dependencies / 依赖声明
  • tests/ — pytest suite / 单元测试
  • logs/, bin/ — outputs and helper scripts / 输出与辅助脚本

VS Code MCP configuration (English)

Place mcp.json under .vscode/ (or your global MCP directory) so Copilot Chat launches the combined entrypoint and keeps hook alive:

{
  "mcpServers": {
    "mcp-token-bridge": {
      "command": "python",
      "args": ["mcptb.py", "--host", "127.0.0.1", "--port", "8000"],
      "env": {},
      "enabled": true
    }
  }
}
  • Ensure python points to your virtual environment; the MCP stdin server and HTTP server start together on the specified host/port.
  • Keep the process running; the hook tool never terminates and forwards all chat completions through the queue.

VS Code MCP 配置(中文)

.vscode/(或全局 MCP 目录)下放置 mcp.json,让 Copilot Chat 启动组合入口并保持 hook 持续运行:

{
  "mcpServers": {
    "mcp-token-bridge": {
      "command": "python",
      "args": ["mcptb.py", "--host", "127.0.0.1", "--port", "8000"],
      "env": {},
      "enabled": true
    }
  }
}
  • 确认 python 指向虚拟环境;MCP stdin 与 HTTP 服务器会在指定的主机和端口同时启动。
  • 进程需保持常驻;hook 工具不会结束,所有 Chat Completion 请求都会通过后台队列转发。

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选