safe-mcp-bridge-v2

safe-mcp-bridge-v2

A fail-closed policy boundary that translates local stdio MCP clients to authenticated Streamable HTTP servers, enforcing allowlists or read-only modes and redacting credentials from audit trails.

Category
访问服务器

README

safe-mcp-bridge-v2

A fail-closed policy boundary between local stdio MCP clients and authenticated Streamable HTTP servers.

CI MCP License

MCP's authorization standard answers who may connect. This bridge adds a local enforcement layer for what an agent may call and what must never leak through the bridge's logs or output.

It translates newline-delimited stdio JSON-RPC into MCP 2026-07-28 Streamable HTTP, injects credentials only at the outbound boundary, mirrors required routing metadata into HTTP headers, applies a local tool policy before network access, and fails closed on secret-shaped upstream output.

Why this still exists after MCP OAuth

OAuth, CIMD, scopes, and protected-resource metadata are essential remote authorization primitives. They do not replace:

  • per-agent local allowlists;
  • a conservative read-only mode;
  • proof that blocked calls never reach the upstream server;
  • redacted audit trails;
  • leak fixtures for wrapper and gateway behavior;
  • env-to-header credential isolation for local stdio clients.

safe-mcp-bridge-v2 is deliberately a narrow safety boundary, not another general MCP platform.

MCP 2026-07-28 support

  • stateless, self-describing requests with _meta protocol/client fields;
  • required MCP-Protocol-Version, Mcp-Method, and Mcp-Name headers;
  • spec Base64 sentinel encoding for non-ASCII or unsafe header values;
  • configured Mcp-Param-* mirroring for x-mcp-header deployments;
  • application/json and request-scoped text/event-stream responses;
  • transparent MRTR InputRequiredResult pass-through;
  • 202 Accepted notification handling;
  • explicit rejection of legacy session initialization;
  • fail-closed header/body and protocol-version checks.

See Compatibility for the exact support boundary.

Quick start

git clone https://github.com/efe-arv/safe-mcp-bridge-v2.git
cd safe-mcp-bridge-v2
uv sync --extra dev
cp examples/modern-read-only.yaml bridge.yaml

Set the credential named by auth.env without placing it in YAML:

export EXAMPLE_MCP_TOKEN='use-your-secret-manager-here'
uv run safe-mcp-bridge-v2 doctor bridge.yaml
uv run safe-mcp-bridge-v2 run bridge.yaml

Example stdio input:

{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":{"query":"status"}}}

The bridge adds modern MCP metadata and sends headers equivalent to:

MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/call
Mcp-Name: memory.search
Authorization: Bearer <injected at runtime>

Credentials are never included in audit records.

Policy modes

Allowlist

Only explicitly named tools may cross the network boundary:

policy:
  mode: allowlist
  allow_tools:
    - memory.search
    - memory.read

Read-only

Blocks tool names containing write-shaped segments such as create, delete, send, update, or write:

policy:
  mode: read_only

Read-only name matching is a conservative local guard, not semantic proof. Prefer an allowlist for consequential environments.

x-mcp-header deployments

The 2026-07-28 HTTP binding can mirror selected primitive tool arguments into Mcp-Param-* headers. Configure mappings learned from your server's tool schema:

protocol:
  custom_tool_headers:
    execute_sql:
      region: Region
      tenant.id: Tenant

The bridge performs spec-compliant primitive conversion and Base64 sentinel encoding. Automatic schema discovery is intentionally not in 0.1.0; mappings are explicit and auditable.

Commands

safe-mcp-bridge-v2 doctor CONFIG
safe-mcp-bridge-v2 run CONFIG
safe-mcp-bridge-v2 policy-check CONFIG METHOD [--tool TOOL]
safe-mcp-bridge-v2 leak-scan PATH

Verification

uv run ruff check .
uv run mypy
uv run pytest

CI runs the same checks on Python 3.11 and 3.12, plus dependency and secret scanning.

Security model

Read SECURITY.md and Threat model before deployment. Important boundaries:

  • redaction is defense in depth, not encryption;
  • upstream authorization and data minimization remain mandatory;
  • an allowlist cannot make a malicious upstream safe;
  • this bridge does not terminate an OAuth browser flow in 0.1.0;
  • legacy stateful MCP sessions require a separate compatibility adapter;
  • local process compromise remains outside the bridge's protection boundary.

Origin

This is a clean second-generation implementation of the original private safe-mcp-bridge, rebuilt for the MCP 2026-07-28 stateless protocol. Created by Efe Büken / Arven Digital.

License

Apache-2.0. See LICENSE.

推荐服务器

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

官方
精选