Skip to content

feat(hub): MCP upstreams, configured once per user and logged in by the hub (ADR-0069) - #329

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

7schmiede merged 1 commit into
mainfrom
feat/hub-mcp-upstreams

Conversation

@7schmiede

Copy link
Copy Markdown
Member

What and why

First of the three pull requests of ADR-0069 (#316): where a user's MCP upstreams are configured and how the hub logs in to them. Their tools in devstack mcp (the loopback API) and stdio upstreams follow.

  • crates/devstack-hub/src/upstreams.rs:
    • upstreams.toml per user in the hub's state directory (name, URL, prefix, tool allowlist, auth kind; no secret).
    • OAuth: authorization server from the upstream (RFC 9728, then RFC 8414 / OpenID discovery), registration where offered (RFC 7591, public client), PKCE S256, resource (RFC 8707). A callback is taken only by the one-time state of a flow the hub started, within ten minutes.
    • A static token the user gives the hub, or one from an environment variable.
    • Credentials in the secrets store of feat(hub): a store for the secrets of upstream MCP servers (ADR-0069) #325; bearer() refreshes before expiry and once on request, keeping a rotated refresh token (used by the next PR).
  • Hub routes: GET/POST /hub/upstreams, DELETE /hub/upstreams/{name}, POST .../login|token|logout (session + Origin as every /hub/ mutation), GET /oauth/upstream/callback (outside /hub/: the authorization server's redirect carries no session; the state admits it, Host is still checked). No route returns a secret.
  • Dashboard: a page MCP upstreams (sidebar, beside Pool): add/change, log in (opens the authorization URL in a new tab), give a token, log out, remove; a note when secrets are in a file.
  • ADR-0069 status → Accepted with the card; dashboard-api.md; CHANGELOG.

Review card

On #316, approved by the owner 2026-10-27, points 1–7. This PR builds points 1 (OAuth by the hub, one-time state, keychain), 4 (upstreams.toml) and 7 (the dashboard's MCP upstreams, per user).

Decided by the agent: the flow written against ureq instead of the oauth2 crate listed on the card (it needs another HTTP client); base64 added (sha2 was a dependency already); the callback path /oauth/upstream/callback and its plain HTML page; ten minutes for a flow; refresh 60 s before expiry; a new URL or auth kind forgets the stored credential; the dashboard as its own page beside Pool, since the hub has no settings page.

Tests

  • upstreams.rs: the full OAuth flow against a fake upstream and authorization server (discovery, registration, PKCE, resource, one-time state, refresh with rotation), the configuration keeping no secret, the checks, the PKCE challenge against an independently computed value.
  • tests/hub.rs: the routes need a session and Origin, plain http beyond loopback is refused, a callback for no flow of this hub changes nothing and works without a session.
  • clippy, cargo test -p devstack-hub (80) and the hub tests; dashboard typecheck, vitest, build:mock. Not tried against a real upstream's authorization server, and the page not clicked through in a browser.

🤖 Generated with Claude Code

…he hub (ADR-0069)

The first part of ADR-0069 (card on #316, approved 2026-10-27, points
1, 4, 7): `upstreams.toml` per user in the hub's state directory, no
secret in it; the hub's own OAuth login (RFC 9728 and RFC 8414
discovery, RFC 7591 registration where offered, PKCE S256, RFC 8707
resource, a one-time `state` for ten minutes, the browser back at
`/oauth/upstream/callback` on the hub's port); a static token the user
gives the hub; credentials in the keychain store of #325; refresh before
expiry with rotation. The dashboard's page *MCP upstreams* (sidebar)
adds, changes, logs in and out, and removes them. No route returns a
secret. Their tools in `devstack mcp` follow.

The OAuth flow is written against `ureq` rather than the `oauth2` crate
(another HTTP client); `base64` added for PKCE, `sha2` was there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede merged commit 868177d into main Oct 27, 2026
13 checks passed
@7schmiede
7schmiede deleted the feat/hub-mcp-upstreams branch October 27, 2026 20:43
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