Skip to content

feat(mcp): devstack mcp offers the MCP upstreams' tools, called through the hub (ADR-0069) - #332

Merged
7schmiede merged 1 commit into
mainfrom
feat/mcp-upstream-proxy
Oct 27, 2026
Merged

7schmiede merged 1 commit into
mainfrom
feat/mcp-upstream-proxy

Conversation

@7schmiede

Copy link
Copy Markdown
Member

What and why

Second of the three pull requests of ADR-0069 (#316): the upstreams configured and logged in by the hub (#329) now reach every coding agent through devstack mcp.

  • crates/devstack-hub/src/mcpclient.rs: an MCP client over Streamable HTTP: initialize once per session (Mcp-Session-Id, MCP-Protocol-Version), answers as JSON or as an event stream, a 404 for a forgotten session starts a new one once, 401/403 as refused.
  • upstreams.rs: tools() lists every upstream's tools as <prefix>__<tool> with its allowlist, asked at most once a minute; one that cannot be asked keeps the tools it listed last (upstream-tools.json), its description says why; one never listed shows <prefix>__login. call() forwards with the hub's credential, refreshed once when refused, and answers a CallToolResult (with isError and the dashboard's page when logged out, not allowed or unreachable).
  • Hub routes behind the user token: GET /hub/upstreams/tools, POST /hub/upstreams/call (each call in the hub's log, tool name only).
  • devstack mcp (crates/devstack/src/upstream.rs): its own tools plus the upstreams'; a name with __ is an upstream's (none of its own has one, tested). It starts the hub when upstreams are configured and the hub does not run; with none configured it neither starts nor asks anything. tools.listChanged, and a look once a minute that sends notifications/tools/list_changed when the tools changed. With DEVSTACK_NO_HUB it asks upstreams without a login or with a token from the environment itself (Secrets::nothing).
  • Docs: dashboard-api.md, CHANGELOG, the devstack skill (what <prefix>__ tools are, and that a login is the user's).

Review card

On #316, approved by the owner 2026-10-27, points 1–7. This PR builds points 2 (loopback API behind the user token, no token returned), 5 (<prefix>__<tool>, a logged-out upstream keeps its tools listed and answers with the dashboard) and 6 (devstack mcp starts the hub; DEVSTACK_NO_HUB: environment tokens only). The owner chose one user token for every agent over a token per agent (2026-10-27).

Decided by the agent: the MCP client written against the protocol (no framework crate; rmcp is Apache-2.0 only); a tool list taken as current for a minute; upstream-tools.json for the last tool lists; <prefix>__login for an upstream never listed; the hub started only when upstreams.toml has an upstream; a look for changes once a minute; ten minutes for a tool call; the descriptions' [<name> via devstack].

Tests

  • upstreams.rs: tools and calls against a fake MCP server wanting a bearer token (one session for all calls, an event-stream answer, the prefix and allowlist, never listed → login, a refused token → kept tools and "log in again"); mcpclient.rs: the answer found among events.
  • tests/hub.rs: a real hub, a fake upstream and the real devstack mcp over stdio: initialize announces listChanged, tools/list has status and fk__echo but not the disallowed tool, tools/call returns the upstream's answer, the disallowed one an error.
  • upstream.rs: devstack's own tool names never look like an upstream's.
  • clippy; cargo test -p devstack -p devstack-hub. Not tried against a real MCP upstream, nor with notifications/tools/list_changed in a real harness.

🤖 Generated with Claude Code

…gh the hub (ADR-0069)

The second part of ADR-0069 (card on #316, approved 2026-10-27, points
2, 5, 6):

- `mcpclient`: a Streamable HTTP client (initialize and session,
  JSON or event-stream answers, a forgotten session started again).
- The hub lists the upstreams' tools as `<prefix>__<tool>` with their
  allowlist (`GET /hub/upstreams/tools`) and forwards calls with its
  credential, refreshed once when refused (`POST /hub/upstreams/call`),
  behind the user token; no route returns a token. An upstream that
  cannot be asked keeps the tools it listed last (`upstream-tools.json`);
  one never listed shows `<prefix>__login`.
- `devstack mcp` adds them to its own tools and forwards their calls; it
  starts the hub when upstreams are configured and it does not run, and
  announces a change (`notifications/tools/list_changed`, looked at once
  a minute). With `DEVSTACK_NO_HUB` it asks the upstreams without a login
  or with a token from the environment itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede merged commit 5894d27 into main Oct 27, 2026
13 checks passed
@7schmiede
7schmiede deleted the feat/mcp-upstream-proxy branch October 27, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant