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
Visit Server

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 请求都会通过后台队列转发。

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured