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.
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 工具 hook。hook 工作者线程常驻,持续从队列中取出请求并返回带有 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.0when you want every network adapter (e.g.,192.168.55.10:8888and192.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:8888与192.168.1.11:8888)都可访问时,使用--host 0.0.0.0。若只想绑定某个适配器,请指定具体地址(如--host 192.168.55.10 --port 8888);此时其他适配器将无法访问。
Flow (English)
- HTTP
POST /v1/chat/completionsenqueues the request and waits for thehookworker reply. - The
hooktool never terminates; it runs on a fixed background thread and returns MCP headers along with the chat response.
工作流(中文)
- HTTP
POST /v1/chat/completions会将请求入队,等待hook工作者返回结果。 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
pythonpoints to your virtual environment; the MCP stdin server and HTTP server start together on the specified host/port. - Keep the process running; the
hooktool 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 请求都会通过后台队列转发。
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.