Skip to content

feat: notice a pool's upstream an agent has set up itself - #479

Merged
7schmiede merged 1 commit into
mainfrom
feat/upstream-direct
Nov 6, 2026
Merged

7schmiede merged 1 commit into
mainfrom
feat/upstream-direct

Conversation

@7schmiede

Copy link
Copy Markdown
Member

What and why

A member had a pool's MCP upstream set up in Claude Code directly (claude mcp add --scope user --transport http …, a service's own setup hint) and had never answered the pool's offer. The agent had the tools, but both hooks of a pool skill bound to that upstream stayed silent for the whole session, and nothing pointed at the cause. Accepting the upstream as well would have given the agent the tools twice (#473).

  • Reading the agents' own servers (crates/devstack-hub/src/agentmcp.rs): Claude Code's .claude.json (in CLAUDE_CONFIG_DIR, else the home folder; mcpServers user scope, projects.<folder>.mcpServers local scope) and a working tree's .mcp.json (project scope); Codex's config.toml ([mcp_servers.<name>] with a url). Read only, name and URL only, never headers. URLs compare normalised: scheme and host in lower case, default port, user, query and fragment dropped, no trailing /.
  • The hook gate (agenthooks.rs, upstream_there): a hook bound to an upstream applies when it is accepted, as before, or, read only then, when the agent running the hook has a server of its own at the pool's URL.
  • Visible: GET /hub/upstreams carries pool.direct (agent, scope, entry, file, the removal command); the MCP upstreams page shows it under the pool's entry with what to do (accepted: the tools twice; not accepted: use it here, then remove the own entry) and the command; devstack doctor warns with the same.
  • Docs: docs/pool.md, docs/dashboard-api.md; addenda to ADR-0069 (points 4, 6) and ADR-0094 (point 5); CHANGELOG.

Review card

# Category Point Beats Reversing costs
4 trust The dispatcher and the hub read the MCP servers configured directly in the agents (Claude Code ~/.claude.json, global and per project, and a working tree's .mcp.json; Codex ~/.codex/config.toml), read only, names and URLs only; nothing leaves the machine, nothing is written. If wrong: nothing gained by an attacker; they are the user's own files and no token is read. calling claude mcp list (slow, starts the servers) low
5 concept A hook with upstream also applies when the agent has a server of its own whose URL (normalised: scheme, lower-case host, port, path without trailing /) is the pool upstream's URL: a direct configuration counts as the upstream being there (amends ADR-0094 point 5 additively). only a note line instead of silence low
6 term The Upstreams page shows on a pool upstream "already set up directly in Claude Code (scope, entry)" with the command that removes it; devstack doctor warns with the same; the hub never changes an agent's MCP configuration. a button "accept and remove the own entry" (the hub writing ~/.claude.json) low: a button can come later

Approved by the owner in the conversation on 2026-11-06: points 4, 5 and 6.

Decided on my own: the page reads the agents' files only when a pool offers upstreams, and for the project scope only the .mcp.json of registered stacks' repositories; Claude Code's local scope counts for a working tree in that folder or below it; Codex has a user scope only, and its "removal command" names the table to delete (there is no stable codex mcp remove to rely on); the member's own hub upstream of the same name still keeps the pool's out.

Verified (Windows 11)

  • Hook gate, end to end with the built binary, a hub state fixture (an index with a session-start hook bound to nuts-timetrack, the pool's list, the upstream not accepted) and a .claude.json fixture via CLAUDE_CONFIG_DIR: without an own entry, nothing; with an own entry at the pool's URL (trailing /, different case), the hook's text; the installed 0.41.0 binary with the same fixture prints nothing (the issue's case).
  • devstack doctor against this machine's real hub state with a .claude.json fixture naming the pool's timetrack URL: warn upstream \nuts-timetrack` of pool `default` (…) is also configured directly in Claude Code (user scope, entry `nuts-timetrack`): the agent gets its tools twice; remove the own entry with `claude mcp remove --scope user nuts-timetrack``. Without the fixture, no warning.
  • Dashboard: the lane served the changed view and the mock hub's crm entry with a direct record; the page itself was not looked at in a browser (no browser at hand): the text comes from ui/src/lib/upstreams.ts, covered by vitest.
  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test -p devstack-hub -p devstack (lib, bins), npm run typecheck, npm test (190), npm run build green.

Closes #473

🤖 Generated with Claude Code

The hub reads the MCP servers Claude Code (.claude.json, user and local
scope; a tree's .mcp.json) and Codex (config.toml) have configured, names
and URLs only, read only, and matches them to the pool's upstreams by URL.
A hook bound to the upstream applies for the agent that has it set up
itself; the MCP upstreams page and devstack doctor name the own entry with
the command that removes it.

Closes #473

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede force-pushed the feat/upstream-direct branch from 5a9a81d to d2c185d Compare November 6, 2026 15:09
@7schmiede
7schmiede merged commit 69a3bfc into main Nov 6, 2026
@7schmiede
7schmiede deleted the feat/upstream-direct branch November 6, 2026 15:18
@7schmiede 7schmiede mentioned this pull request Nov 6, 2026
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.

Hub: detect a pool upstream that the agent already has as its own MCP server

1 participant