Skip to content

MCP proxy in the hub: one login per upstream, the same tools in every harness #316

Closed

Description

@7schmiede

Problem

Developers use several agent harnesses side by side (Claude Code, Codex, opencode, ...). Each one keeps its own list of MCP servers, and for every remote server that needs OAuth each one runs its own login and holds its own tokens. Adding a server or logging in again means doing it once per harness, and the lists drift apart. Servers that act for a concrete user (an issue tracker, for example) cannot be shared any other way.

devstack mcp is already registered in each of these harnesses.

Idea

devstack mcp exposes, next to its own tools, the tools of upstream MCP servers the user configured. The hub owns the connections to the upstreams and their tokens. One login per upstream, the same tools in every harness.

Why the hub (ADR-0021)

  • It runs per user, across all stacks, from logon, on a fixed loopback port, and without a stack. A stack's daemon is the wrong owner: it exists per stack.
  • One owner for the tokens. Every harness starts its own devstack mcp. Several processes refreshing at the same time invalidate each other when the upstream rotates refresh tokens.
  • It already serves HTTP on loopback: the natural redirect target for the OAuth browser flow, and its dashboard is the place to add upstreams and log in or out.

Auth model

  • The hub is an OAuth client of each upstream, per user (authorization code + PKCE, dynamic client registration where the upstream offers it). Tokens live in the OS keychain.
  • No token passthrough (MCP security best practices): a token a harness holds is never sent upstream, and an upstream token never leaves the hub.
  • Holding the tokens locally, per user, is the same thing every harness does today, done once. A central gateway on a server would hold every user's tokens in one place; that is out of scope here.
  • Upstreams with a static bearer token: the secret comes from the keychain or the environment, never from a config file.

Scope

In:

  • Upstreams over stdio and Streamable HTTP.
  • Per-user OAuth as above.
  • A prefix and a tool allowlist per upstream (shorter tool lists make agents better, and names collide).
  • The stack and lane context as a header to an upstream, opt-in per upstream.
  • An upstream that is down or logged out does not take devstack's own tools with it.
  • devstack mcp --proxy-only: works without a stack file, so a desktop app or a session outside any repository can use it as a plain stdio server.

Out: a registry or marketplace, a policy engine, caching, rewriting content, a gateway on a server for many users.

Configuration

  1. User level (hub settings): the base, works without a pool.
  2. Pool profile, optional: the pool hands upstream definitions to its members, administered in the pool's dashboard (ADR-0032). Never secrets; every member logs in for themselves.
  3. Stack file: at most non-secret declarations of upstreams the project suggests. The stack file is shared with everyone who has the repository.

Open questions (for an ADR)

  • Precedence between user and pool settings; may a user switch off an upstream the pool hands out?
  • Pool membership as identity: an upstream that trusts the pool CA could accept the member's client certificate, so removing a member also revokes access there. Worth it, or too much coupling?
  • What a harness sees for an upstream that is logged out: tools hidden, or listed and failing with "log in from the dashboard"? Use of notifications/tools/list_changed.
  • Hub not running: does devstack mcp start it, or offer only its own tools?
  • Headless machines and CI: no browser for the OAuth flow.

Prior art: MCPJungle (self-hosted MCP gateway, central, no OAuth).

Activity

  1. added
    enhancement
    on Oct 27, 2026
  2. 7schmiede commented on Oct 27, 2026

    @7schmiede
    MemberAuthor

    Review card: ADR-0069 as built (upstream login, proxy, dashboard)

    ADR-0069 was proposed before ADR-0070; per ADR-0070 point 7 its card-category points are reviewed here, before the code that depends on them. Already merged: the secrets store (#325). The rest comes in three pull requests: (a) upstream configuration, OAuth login and the dashboard section, (b) the hub's loopback API and devstack mcp listing and forwarding, (c) stdio upstreams.

    # Category Point Beats Reversing costs
    1 trust The hub is the only OAuth client of each upstream: authorization code with PKCE, its redirect on its own loopback port, a callback accepted only for a flow it started (one-time state, ten minutes), tokens kept only in the secrets store of #325. If wrong: a forged callback ties the user's hub to an attacker's upstream account, and whoever reads the store acts on every upstream as the user. Each harness logging in and keeping tokens itself (today) Medium: users log in again per harness
    2 trust devstack mcp reaches upstream tools only through a loopback API of the hub behind the user token (ADR-0019) that lists tools and forwards calls; no route ever returns a token. If wrong: any process of the user that reads the user token calls every upstream tool as the user, the reach it has today over the harnesses' own token files, now in one place. Handing tokens to each devstack mcp (token passthrough) Medium: an API both sides depend on
    3 trust A stdio upstream is a command the user entered in the dashboard; the hub starts it as the user with only the environment the user set for it (secrets from the store), never a command from a stack file or the pool. If wrong: whoever can change the hub's upstream list runs commands as the user, as they could already with the dashboard session or the user's files. Upstream definitions from a repository or the pool (ADR-0069 options B, C) Low while only the user adds them
    4 contract Upstreams are kept per user in upstreams.toml in the hub's state directory (name, URL or command, prefix, tool allowlist, auth kind), with no secret in it. Declaring them in the stack file or a pool profile Medium: a migration of that file
    5 contract An upstream's tools appear in every harness as <prefix>__<tool> beside devstack's own, unprefixed; a logged-out or unreachable upstream keeps its tools listed, and they answer with an error that names the dashboard. Hiding them until they work Medium: harness allowlists and prompts name these tools
    6 concept devstack mcp starts the hub when it is not running, as devstack ui does; with DEVSTACK_NO_HUB it does not, and only upstreams with a static token from the environment work. devstack mcp without upstreams until the user starts the hub Low
    7 term The dashboard names them MCP upstreams, in the hub's settings, per user, each with log in and log out; nothing about them is per stack. A section per stack Low

    Decided by the agent: the crates (oauth2 5, MIT OR Apache-2.0, for the flow; the MCP client written against the protocol rather than a framework crate), dynamic client registration where an upstream offers it and a client id the user enters where not, refreshing a token before it expires and once on a 401, the timeouts, error texts and the layout of the dashboard section, the order of the three pull requests.

    Approved by the owner: 2026-10-27, points 1–7.

  3. 7schmiede commented on Oct 27, 2026

    @7schmiede
    MemberAuthor

    Built in #325 (secrets store), #329 (configuration, OAuth login, dashboard page), #332 (devstack mcp offers and forwards upstream tools through the hub) and #333 (stdio upstreams), on the approved review card above. ADR-0069 notes the paths as built. Not yet tried against a real upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions