fix(mcp): hide the path the application serves, not the sidecar's

f5272fa85f derived the 404 from mcp.endpoint.path, which for an
adapter-fronted provider names the sidecar. Mattermost declares /mcp
there and answers on /plugins/mattermost-ai/mcp-server/mcp, so the proxy
blocked a path the application never served while the native surface
stayed reachable. Baserow passed only because its two paths coincide -
one role agreeing proved nothing about the other four.

That surface is what the adapter exists to narrow: it serves four tools
out of fourteen, and the native path reaches all fourteen.

adapter.upstream_path joins upstream_network and upstream_transport in
meta, and the four roles whose upstream lives on their own vhost declare
it there. Gitea does not: its upstream is a separate sidecar on its own
network, so it has nothing to hide on the application's vhost, and the
absence says that.

The roles read the value back through lookup('config', ...) rather than
keeping a second copy, so the path is stated once.

The template now separates the two roles the old variable conflated:
endpoint.path is what gets served, and only where the surface is public
and enabled; every declared path that differs from it gets a 404. Three
tests pin the distinction rather than the outcome - mattermost's two
paths must differ, gitea must declare none, and a passthrough provider
must say where its upstream lives.
This commit is contained in:
kevinveenbirkenbach committed 2026-08-29 17:47:03 +02:00
1 parent 57ff37693c
commit 06c13e7f3e
11 files changed
+74 -11

No files matched your search

@@ -198,5 +198,52 @@ class TestTheAppVhostServesOnlyPublicSurfaces(unittest.TestCase):
self.assertEqual(served, {r for r in PUBLIC_ROLES if r != "web-app-wordpress"})
class TestTheHiddenPathIsTheOneTheAppServes(unittest.TestCase):
"""What must be hidden is the upstream, not the sidecar's endpoint.
An adapter-fronted provider declares `endpoint.path` on its sidecar and
serves the real MCP surface somewhere else on its own vhost. Blocking the
sidecar's path there hides nothing: mattermost declares `/mcp` and answers
on `/plugins/mattermost-ai/mcp-server/mcp`, so the native surface stayed
reachable while the deploy looked correct. Baserow's two paths happen to
coincide, which is why one role passing proved nothing about the rest.
"""
def passthrough_roles(self) -> dict[str, dict]:
found = {}
for meta in (PROJECT_ROOT / "roles").glob(f"*/{ROLE_FILE_META_MCP}"):
block = load_yaml(meta)
if (block.get("adapter") or {}).get("type") == "mcp_passthrough":
found[meta.parent.parent.name] = block
return found
def test_a_passthrough_provider_says_where_its_upstream_lives(self):
"""Either on the application's own vhost, or on a separate network."""
for role, block in self.passthrough_roles().items():
with self.subTest(role=role):
adapter = block["adapter"]
self.assertTrue(
adapter.get("upstream_path") or adapter.get("upstream_network"),
f"{role} declares neither upstream_path nor upstream_network, "
f"so nothing states whether its native surface is exposed",
)
def test_the_role_that_made_this_visible_declares_its_real_path(self):
adapter = self.passthrough_roles()["web-app-mattermost"]["adapter"]
self.assertEqual(
"/plugins/mattermost-ai/mcp-server/mcp", adapter["upstream_path"]
)
self.assertNotEqual(
adapter["upstream_path"],
self.passthrough_roles()["web-app-mattermost"]["endpoint"]["path"],
)
def test_a_sidecar_upstream_declares_no_path_on_the_app_vhost(self):
"""Gitea's upstream is its own service, so it has nothing to hide."""
adapter = self.passthrough_roles()["web-app-gitea"]["adapter"]
self.assertNotIn("upstream_path", adapter)
self.assertTrue(adapter.get("upstream_network"))
if __name__ == "__main__":
unittest.main()