Skip to content

fix(mcp): degrade a server whose bearer does not resolve instead of failing the run (OB9) - #148

Merged
lg2m merged 1 commit into
feat/eng-879-initfrom
fix/eng-861-mcp-credential-degrade
Sep 23, 2026
Merged

lg2m merged 1 commit into
feat/eng-879-initfrom
fix/eng-861-mcp-credential-degrade

Conversation

@lg2m

@lg2m lg2m commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Stack: #146 (OB8) → #147 (OB5) → #148 (OB9). Merge in that order; each PR is based on the previous branch and shows only its own diff. After merging one, retarget the next to main (GitHub does this automatically when the base branch is deleted on merge).

Plan slice OB9 of docs/plans/onboarding-ux.md. Linear: ENG-861.

Problem

An HTTP MCP server declared with bearer: Stored("linear/default") whose credential is not registered on this machine failed plan compilation (resolve_server → AuthError → RunFailureKind::Authentication), so every run in the workspace failed. A server whose connection failed was already degraded to unavailable MCP servers: NAME and the run proceeded — the two cases now behave the same.

User-visible behavior

  • The run proceeds with built-ins and the other servers. The tool-catalog readiness message reads:
    unavailable MCP servers: linear (credential `linear/default` is not registered; run `qq auth set linear/default`)
    
    Other causes word their own remedy: secret missing from the keyring → qq auth logout NAME then qq auth set NAME; bound to a different endpoint → qq auth set NAME --endpoint <url>; keyring unavailable → start it or --allow-file; unset Env("VAR") → export VAR.
  • Calls to the degraded server's tools return an Unavailable outcome carrying the reason (not UnknownTool); its allow grants remain in effect.
  • After qq auth set NAME, the next run picks the credential up without restarting: the registry cache key already includes the credential epoch and plan sources include the credential-index fingerprint.
  • Connection and list_tools failures now also carry their text in the readiness message instead of the bare server name.
  • qq doctor gains an mcp check: none declared / N declared; every bearer resolves / a warning (never a failure) naming each server and remedy, with runs proceed without this server.

Design notes

  • qq-mcp stays free of qq-auth: McpTransportSettings::Http { bearer: McpBearer } with McpBearer::{None, Token(String), Unavailable { reason }}. ServerHandle::connect returns the reason for Unavailable without building a transport; the handle takes the ordinary last_failure path so nothing else in the manager changes.
  • McpCatalog::unavailable is now Vec<McpUnavailable { server, reason }>; ServerHandle::tools() returns Err(String) instead of Err(()). Both are public qq-mcp API changes (no external consumers).
  • resolve_server is infallible. The AuthError → wording mapping lives in one BearerFailure { problem, remedy } in src/mcp.rs, shared by the readiness message and qq doctor so both surfaces say the same thing. The match is explicit for every variant resolve_with_endpoint can produce; the ~20 store-level variants (corrupt index, unreadable state) fall through to their Display plus a remedy keyed on the reference kind.
  • qq config check is unchanged: it never opened a credential store and still doesn't.

Docs

docs/guide/mcp.md § "When a server is unavailable" (the "planned (OB9)" paragraph is gone), docs/guide/troubleshooting.md (both MCP entries), docs/guide/cli.md (doctor mcp row), docs/design/tools.md. Ledger: OB9 → In review; OB0 → Shipped (#128); OB6 → Shipped (#139).

Verification

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace — 1780 passed
  • New tests:
    • qq-mcp: an_unresolvable_bearer_keeps_the_server_declared_but_unavailable
    • src/mcp.rs: an_unregistered_stored_bearer_degrades_only_its_server_until_it_is_set (two HTTP servers against the in-process MCP fixture: one degraded, one serving; then set_with_metadata, new epoch → Ready and the token is sent); wired_mcp_adapter_passes_the_availability_subset_for_an_unresolved_bearer (qq-core host conformance suite)
    • src/doctor.rs: mcp_check_passes_with_no_servers_and_with_resolvable_bearers, mcp_check_warns_about_an_unregistered_stored_bearer_without_failing, mcp_check_names_the_endpoint_when_the_stored_bearer_is_bound_elsewhere

Performance / compatibility

Compile path: the credential lookup that happened before now happens the same number of times; a failure no longer aborts. The readiness message is part of the plan descriptor digest (as connection failures already were), so a degraded → resolved transition produces a new plan generation, which is the desired behavior.

HostSummary.readiness_message already flows to clients as ToolHostSummary.message; the TUI does not render it yet — a follow-up if we want the degraded reason visible in-session rather than only via qq doctor and logs.

…ailing the run (OB9)

An HTTP MCP server declared with `bearer: Stored("name")` whose credential
is not registered on this machine used to fail plan compilation with an
authentication error for every run in the workspace. The bearer now
resolves into `McpBearer::{None, Token, Unavailable { reason }}`; an
unresolvable one keeps the server declared (grants, tool names) but never
connects, so the catalog reports it under `unavailable MCP servers: NAME
(credential `NAME` is not registered; run `qq auth set NAME`)` while the
other servers and built-ins run. Calls to it return Unavailable. The
registry cache key already includes the credential epoch, so the next run
after `qq auth set` resolves it without a restart.

`McpCatalog::unavailable` now carries `McpUnavailable { server, reason }`
and connection/list failures keep their text too. `qq doctor` gains an
`mcp` check that warns (never fails) with the same wording.

Closes ENG-861.
@lg2m
lg2m force-pushed the fix/eng-861-mcp-credential-degrade branch from ceb43a6 to 4b48c5a Compare September 23, 2026 22:29
@lg2m
lg2m changed the base branch from main to feat/eng-879-init September 23, 2026 22:29
@lg2m
lg2m added this pull request to stack #149 September 23, 2026 22:37
@lg2m
lg2m merged commit 474b965 into main Sep 23, 2026
4 checks passed
@lg2m
lg2m deleted the fix/eng-861-mcp-credential-degrade branch September 23, 2026 23:09
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