Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

runner: every base takes an SSE MCP server; the runner speaks SSE over stdio for clients that cannot (#185)

github-actions[bot]f26989217bd5
diff --git a/docs/self-hosting-guide.md b/docs/self-hosting-guide.md
index 75064f17..e669f119 100644
--- a/docs/self-hosting-guide.md
+++ b/docs/self-hosting-guide.md
@@ -754,9 +754,9 @@ round-trips on the next PUT. The harness's own `mcpServers` and `skills` stay ex
there; a plugin's components are listed on the plugin. Names must not collide across the harness and
its enabled plugins. A package that declares a process (a `stdio` server) installs on every base: the
runner writes one launcher per server and each agent's own MCP client runs it (pi's adapter and dsh's
-client included). A remote server reaches each client in its own spelling; a transport a base's client
-does not speak (SSE on codex, dsh and goose) is recorded on the plugin's `skipped` list with the reason
-and the rest of the package installs. `GET /v1/harnesses/{id}/plugin` exports the harness's own tools and Skills as a
+client included). A remote server reaches each client in its own spelling, and a client without an SSE
+transport of its own (codex, dsh, goose) still takes an SSE server: the runner hands it a stdio bridge
+that speaks SSE to the remote end, so every transport installs on every base. `GET /v1/harnesses/{id}/plugin` exports the harness's own tools and Skills as a
package, credentials omitted. The full contract is the
[Plugins chapter](https://unifiedharnessprotocol.org/spec/2026-09-12/plugins) of the protocol.
diff --git a/gateway/app.py b/gateway/app.py
index a38543e8..969db329 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -13484,14 +13484,6 @@ def _skill_key(name: str) -> str:
"""The runner's skill directory name (its _skill_dir_name), so two skills the gateway sees
as different cannot land in one folder."""
return re.sub(r"[^A-Za-z0-9_-]+", "-", str(name or ""))
-# Transports a base's own MCP client does not speak, by runner backend. A plugin server on one of
-# these installs as `skipped` with the reason, so the omission is on the record (Plugins §2.2)
-# rather than a silent miss in a turn; the plugin's other components still install. codex's client
-# takes streamable HTTP and stdio; dsh-mcp-client's config is a union of stdio and streamable-http;
-# goose 1.50.0's ExtensionConfig has no sse variant.
-_MCP_TRANSPORTS_MISSING = {"codex": {"sse"}, "dsh": {"sse"}, "goose": {"sse"}}
-
-
def _plugin_invalid(name: str, path: str, reason: str) -> HTTPException:
return uhp_error(422, "plugin_invalid", f"Plugin {name or 'package'}: {reason}", "plugins",
{"path": path, "reason": reason})
@@ -13824,8 +13816,6 @@ async def _plugins_prepare(body: HarnessBody, org: str, previous: list[dict] | N
derived object and the blob handle, which is exactly what a client reads back and PUTs again.
`previous` is what the harness held before an update; packages the new list no longer refers to
are deleted once the new list is validated."""
- backend = str(_BASE_CATALOG.get(body.base or "", {}).get("backend") or "")
- missing = _MCP_TRANSPORTS_MISSING.get(backend, set())
staged: list[tuple[dict, str | None, str | None]] = [] # (entry, encoded files to store, kept blob)
seen: dict[str, str] = {}
for i, item in enumerate(body.plugins or []):
@@ -13864,10 +13854,6 @@ async def _plugins_prepare(body: HarnessBody, org: str, previous: list[dict] | N
# here instead, and written down: the turn would otherwise drop it with only a log line.
kept: list[dict] = []
for s in derived["mcpServers"]:
- if s.get("transport") in missing:
- derived["skipped"].append({"path": f"mcp.json#/mcpServers/{s['name']}",
- "reason": f"the {body.base} base's client has no {s['transport']} transport"})
- continue
blocked = await _ssrf_check(str(s.get("url") or "")) if s.get("transport") != "stdio" else ""
if blocked:
derived["skipped"].append({"path": f"mcp.json#/mcpServers/{s['name']}",
diff --git a/gateway/tests/test_plugins.py b/gateway/tests/test_plugins.py
index e73fb7c8..bf2e2674 100644
--- a/gateway/tests/test_plugins.py
+++ b/gateway/tests/test_plugins.py
@@ -180,22 +180,20 @@ def test_a_disabled_plugin_stays_installed_and_clears_collisions(api):
assert pl["name"] == "demo-plugin" and pl["enabled"] is False
-def test_a_transport_a_base_cannot_speak_is_recorded_not_refused(api):
- """codex, dsh and goose have no SSE client: an sse server in a package lands in `skipped`
- with the reason and the rest of the package installs; a base with an SSE client keeps it."""
+def test_every_transport_installs_on_every_base(api):
+ """A base whose client lacks a transport still takes the server: the runner speaks SSE to the
+ remote end through a stdio bridge for codex, dsh and goose, so nothing is refused or recorded
+ as missing at install time."""
mcp = {"$schema": MCP_SCHEMA, "mcpServers": {
"events": {"type": "sse", "url": "https://mcp.example.invalid/sse"},
"remote": {"type": "streamable-http", "url": "https://mcp.example.invalid/mcp"}}}
- r = api.post("/v1/harnesses", json={"name": "x", "base": "codex", "plugins": [{"files": _package(manifest=MANIFEST, mcp=mcp)}]})
- if r.status_code == 400:
- pytest.skip(f"codex is not a creatable base here: {r.json()['error']['code']}")
- assert r.status_code == 200, r.text
- (pl,) = r.json()["plugins"]
- assert [s["name"] for s in pl["mcpServers"]] == ["remote"] and [s["name"] for s in pl["skills"]] == ["demo-skill"]
- assert pl["skipped"] == [{"path": "mcp.json#/mcpServers/events", "reason": "the codex base's client has no sse transport"}]
- r = api.post("/v1/harnesses", json={"name": "x", "base": "claude-code", "plugins": [{"files": _package(manifest=MANIFEST, mcp=mcp)}]})
- (pl,) = r.json()["plugins"]
- assert {s["name"]: s["transport"] for s in pl["mcpServers"]} == {"events": "sse", "remote": "http"} and pl["skipped"] == []
+ for base in ("codex", "claude-code"):
+ r = api.post("/v1/harnesses", json={"name": "x", "base": base, "plugins": [{"files": _package(manifest=MANIFEST, mcp=mcp)}]})
+ if r.status_code == 400:
+ pytest.skip(f"{base} is not a creatable base here: {r.json()['error']['code']}")
+ assert r.status_code == 200, r.text
+ (pl,) = r.json()["plugins"]
+ assert {s["name"]: s["transport"] for s in pl["mcpServers"]} == {"events": "sse", "remote": "http"} and pl["skipped"] == []
def test_a_stdio_server_installs_on_every_base(api):
diff --git a/runner/dsh_driver.py b/runner/dsh_driver.py
index 5e79fcd0..0bf7ed1f 100644
--- a/runner/dsh_driver.py
+++ b/runner/dsh_driver.py
@@ -429,11 +429,6 @@ def _compose_patch(home: pathlib.Path, servers: list[dict], llm: dict | None = N
"config": {"transport": "stdio", "serverName": name, "cwd": cwd,
"command": str(s["command"]), "args": [str(a) for a in (s.get("args") or [])]}})
continue
- if str((s or {}).get("transport") or "").lower() == "sse":
- # dsh-mcp-client's config is a union of stdio and streamable-http; an sse endpoint
- # driven as streamable HTTP never answers, so the row is not written.
- print(f"[dsh] '{name}': sse transport is not one dsh-mcp-client speaks, skipped", flush=True)
- continue
entry = {"id": f"hr-mcp-{i}", "name": "@deepseek-ai/dsh-mcp-client",
"config": {"transport": "streamable-http", "serverName": name, "url": url}}
hdrs: dict = {}
diff --git a/runner/mcp_bridge.py b/runner/mcp_bridge.py
new file mode 100644
index 00000000..6b3ec0f8
--- /dev/null
+++ b/runner/mcp_bridge.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python3
+"""A remote MCP server, spoken to over stdio.
+
+Every agent CLI in the image launches a stdio MCP server; not every one speaks the remote
+transports (goose 1.50 and dsh's client have no SSE transport, codex takes streamable HTTP only).
+Rather than leave such a server out for that client, the runner hands it this bridge as a stdio
+server: the bridge connects to the remote end with the transport it names and forwards the tools,
+resources and prompts unchanged. One process per server per turn, started by the client, gone
+with it.
+
+ HR_MCP_URL the remote endpoint
+ HR_MCP_TRANSPORT sse (default) or http (streamable HTTP)
+ HR_MCP_HEADERS JSON object of request headers (Authorization and the rest)
+"""
+import asyncio
+import json
+import os
+import sys
+
+from mcp import ClientSession, types
+from mcp.client.sse import sse_client
+from mcp.client.streamable_http import streamablehttp_client
+from mcp.server.lowlevel import Server
+from mcp.server.stdio import stdio_server
+
+
+async def main() -> int:
+ url = os.environ.get("HR_MCP_URL", "")
+ if not url:
+ print("HR_MCP_URL is not set", file=sys.stderr)
+ return 2
+ transport = (os.environ.get("HR_MCP_TRANSPORT") or "sse").lower()
+ try:
+ headers = json.loads(os.environ.get("HR_MCP_HEADERS") or "{}")
+ except json.JSONDecodeError:
+ headers = {}
+ remote = sse_client(url, headers=headers or None) if transport == "sse" else streamablehttp_client(url, headers=headers or None)
+ async with remote as streams:
+ async with ClientSession(streams[0], streams[1]) as session:
+ init = await session.initialize()
+ caps = init.capabilities
+ server = Server(init.serverInfo.name if init.serverInfo else "bridge")
+
+ @server.list_tools()
+ async def list_tools() -> list[types.Tool]:
+ return (await session.list_tools()).tools
+
+ @server.call_tool()
+ async def call_tool(name: str, arguments: dict | None) -> types.CallToolResult:
+ # The remote result travels whole: a tool that declares an output schema answers
+ # with structured content too, and the SDK on this side checks for it.
+ result = await session.call_tool(name, arguments or {})
+ return types.CallToolResult(content=result.content, structuredContent=result.structuredContent,
+ isError=bool(result.isError))
+
+ if caps.resources:
+ @server.list_resources()
+ async def list_resources() -> list[types.Resource]:
+ return (await session.list_resources()).resources
+
+ @server.read_resource()
+ async def read_resource(uri):
+ got = await session.read_resource(uri)
+ return [types.ReadResourceContents(content=c.text if isinstance(c, types.TextResourceContents) else c.blob,
+ mime_type=c.mimeType) for c in got.contents]
+
+ if caps.prompts:
+ @server.list_prompts()
+ async def list_prompts() -> list[types.Prompt]:
+ return (await session.list_prompts()).prompts
+
+ @server.get_prompt()
+ async def get_prompt(name: str, arguments: dict | None) -> types.GetPromptResult:
+ return await session.get_prompt(name, arguments or {})
+
+ async with stdio_server() as (read_stream, write_stream):
+ await server.run(read_stream, write_stream, server.create_initialization_options())
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(asyncio.run(main()))
diff --git a/runner/server.py b/runner/server.py
index 84d2eb3f..e0a2d805 100644
--- a/runner/server.py
+++ b/runner/server.py
@@ -895,6 +895,52 @@ _PLUGIN_PLACEHOLDER = re.compile(r"\$\{PLUGIN_(ROOT|DATA)\}")
_ENV_NAME = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
+# Clients without a remote transport of their own: goose 1.50.0's ExtensionConfig has no sse
+# variant, dsh-mcp-client's config is a union of stdio and streamable-http, and codex's client
+# takes streamable HTTP and stdio. Every one of them launches a stdio server, so the runner hands
+# them the bridge (mcp_bridge.py) as one, and the bridge speaks SSE to the remote end. The server
+# reaches the agent on every base the same way; nothing is declared unsupported.
+_NO_SSE_BACKENDS = {"codex", "dsh", "goose"}
+_MCP_BRIDGE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "mcp_bridge.py")
+
+
+def _sse_bridges(cwd: str, servers: list[dict] | None, backend: str) -> list[dict]:
+ """Each SSE server, for a backend whose client cannot speak SSE, becomes a stdio launcher that
+ runs the bridge with the url and headers in its environment (never on the command line, where
+ a ps listing would show an Authorization header). Other servers and backends pass untouched."""
+ if backend not in _NO_SSE_BACKENDS:
+ return list(servers or [])
+ out: list[dict] = []
+ for s in servers or []:
+ s = s or {}
+ url = str(s.get("url") or "").strip()
+ if not url or str(s.get("transport") or "").lower() != "sse":
+ out.append(s)
+ continue
+ name = _mcp_name(str(s.get("name") or s.get("id") or "mcp"))
+ headers: dict = {}
+ auth = s.get("auth")
+ if auth:
+ headers["Authorization"] = auth if str(auth).lower().startswith("bearer ") else f"Bearer {auth}"
+ if isinstance(s.get("headers"), dict):
+ headers.update({str(k): str(v) for k, v in s["headers"].items() if k and v is not None})
+ bdir = pathlib.Path(_safe_join(cwd, ".harness/mcp-bridge"))
+ bdir.mkdir(parents=True, exist_ok=True)
+ launcher = bdir / f"{name}.sh"
+ lines = ["#!/bin/sh", "# written by the harness runner: this client has no SSE transport, so the bridge speaks it over stdio",
+ f"export HR_MCP_URL={shlex.quote(url)}", "export HR_MCP_TRANSPORT=sse",
+ f"export HR_MCP_HEADERS={shlex.quote(json.dumps(headers))}",
+ f"exec python3 {shlex.quote(_MCP_BRIDGE)}", ""]
+ if launcher.is_symlink() or (launcher.exists() and not launcher.is_file()):
+ launcher.unlink()
+ fd = os.open(str(launcher), os.O_WRONLY | os.O_CREAT | os.O_TRUNC | getattr(os, "O_NOFOLLOW", 0), 0o755)
+ with os.fdopen(fd, "w") as fh:
+ fh.write("\n".join(lines))
+ launcher.chmod(0o755)
+ out.append({k: v for k, v in s.items() if k not in ("url", "transport", "auth", "headers")} | {"name": s.get("name") or name, "command": str(launcher), "args": []})
+ return out
+
+
def _plugin_launchers(cwd: str, servers: list[dict] | None) -> list[dict]:
"""The stdio servers a plugin declares, made runnable (UHP Plugins §6, Agent Plugins §7.2.1
and §9): the two placeholders expanded once and non-recursively in args, env and cwd; a
@@ -4455,11 +4501,6 @@ def _goose_extensions(mcp_servers: list[dict] | None, tools_disabled: list[str]
url = (sv.get("url") or "").strip()
cmd = sv.get("command")
if url:
- if str(sv.get("transport") or "").lower() == "sse":
- # goose 1.50.0's ExtensionConfig has no sse variant (stdio, builtin, platform,
- # streamable_http); an sse entry would fail to parse and take the config with it.
- print(f"[goose] '{name}': sse transport is not one goose speaks, skipped", flush=True)
- continue
entry: dict = {"enabled": True, "type": "streamable_http", "name": name,
"uri": url, "timeout": 300}
hdrs = sv.get("headers")
@@ -5846,7 +5887,7 @@ def turn(req: TurnReq, identifier: str = "") -> dict:
# Installed plugin packages, whole, at their roots; then every stdio server a plugin declares
# becomes a launcher every backend writer below already knows how to hand to its CLI.
plugin_roots = _write_plugins(cwd, req.plugins)
- req.mcp_servers = _plugin_launchers(cwd, req.mcp_servers)
+ req.mcp_servers = _sse_bridges(cwd, _plugin_launchers(cwd, req.mcp_servers), req.backend)
# A package that is also a Claude Code plugin reaches the claude CLI whole through
# --plugin-dir, which loads its skills/ itself; folding those skills into the skills
# directory too would offer each one twice.
diff --git a/runner/tests/test_uhp_plugins.py b/runner/tests/test_uhp_plugins.py
index c2f09c83..e57a267b 100644
--- a/runner/tests/test_uhp_plugins.py
+++ b/runner/tests/test_uhp_plugins.py
@@ -186,21 +186,27 @@ def test_an_sse_server_reaches_each_client_in_its_own_spelling(tmp_path):
assert o["probe_sse"]["type"] == "sse" and o["probe_http"]["type"] == "http"
-def test_clients_without_an_sse_transport_leave_the_server_out(tmp_path):
- """goose 1.50.0's ExtensionConfig has no sse variant and dsh-mcp-client's config is a union of
- stdio and streamable-http: an sse endpoint driven as streamable HTTP never answers, so neither
- writer emits it (the gateway records the omission on the plugin at install time)."""
- import dsh_driver
- sse = {"name": "probe_sse", "url": "https://probe.example.invalid/sse", "transport": "sse"}
+def test_a_client_without_sse_gets_the_server_through_the_stdio_bridge(tmp_path):
+ """goose 1.50.0's ExtensionConfig has no sse variant, dsh-mcp-client's config is a union of
+ stdio and streamable-http, codex's client takes streamable HTTP and stdio. Each launches a
+ stdio server, so an SSE server reaches them as the bridge: url and headers in the launcher's
+ environment, never on its command line; other servers and other backends pass untouched."""
+ sse = {"name": "probe_sse", "url": "https://probe.example.invalid/sse", "transport": "sse",
+ "auth": "secret-token", "headers": {"X-Team": "t"}, "plugin": "hr-probe"}
http = {"name": "probe_http", "url": "https://probe.example.invalid/mcp", "transport": "http"}
- ext = rn._goose_extensions([sse, http], None)
- assert "probe_sse" not in ext and ext["probe_http"]["type"] == "streamable_http"
- out = pathlib.Path(dsh_driver._compose_patch(tmp_path / "home", [sse, http], relay_port=9999, model="m", cwd=str(tmp_path)))
- import yaml
- names = [r["config"]["serverName"] for e in yaml.safe_load(out.read_text()) if isinstance(e, dict)
- for r in (e.get("insert") or []) if r.get("name") == "@deepseek-ai/dsh-mcp-client"]
- assert names == ["probe_http"]
-
+ for backend in ("goose", "dsh", "codex"):
+ out = rn._sse_bridges(str(tmp_path), [sse, http], backend)
+ assert out[1] == http
+ b = out[0]
+ assert b["name"] == "probe_sse" and b["plugin"] == "hr-probe" and b["args"] == [] and "url" not in b and "auth" not in b
+ text = pathlib.Path(b["command"]).read_text()
+ assert "HR_MCP_URL=https://probe.example.invalid/sse" in text and "HR_MCP_TRANSPORT=sse" in text
+ assert '"Authorization": "Bearer secret-token"' in text and '"X-Team": "t"' in text
+ assert text.rstrip().endswith("mcp_bridge.py") and os.access(b["command"], os.X_OK)
+ assert rn._sse_bridges(str(tmp_path), [sse, http], "claude") == [sse, http]
+ # the writers then see a stdio entry, as for any plugin server
+ ext = rn._goose_extensions(rn._sse_bridges(str(tmp_path), [sse, http], "goose"), None)
+ assert ext["probe_sse"]["type"] == "stdio" and ext["probe_http"]["type"] == "streamable_http"
def test_dsh_job_keeps_a_stdio_server(tmp_path):
"""_build_dsh hands the driver a job whose server list kept only urls, from before plugins: