Skip to content

[mcp] Surface OAuth at add time so netclaw mcp auth precedes permissions - #1773

Open
Aaronontheweb wants to merge 3 commits into
devfrom
inspect/mcp-add-auth-hint
Open

[mcp] Surface OAuth at add time so netclaw mcp auth precedes permissions#1773
Aaronontheweb wants to merge 3 commits into
devfrom
inspect/mcp-add-auth-hint

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

[mcp] Surface OAuth at add time so netclaw mcp auth precedes permissions for OAuth-protected servers

Changes

  • netclaw mcp add now probes HTTP/SSE endpoints for RFC 9728 protected-resource metadata (best-effort; never fails the add) and prints netclaw mcp auth <name> as step 1, before netclaw mcp permissions, when OAuth is required.
  • When the authorization server publishes no registration_endpoint, the output says to re-add with a pre-registered --client-id instead of letting the auth flow fail later.
  • New --auth flag runs the OAuth flow immediately after adding; prints a fallback hint when the daemon is unavailable, and is ignored for stdio.
  • Servers with an explicit Authorization header and stdio transports skip the probe entirely — their output is unchanged.
  • McpOAuthProbe is a self-contained static class mirroring the daemon's existing RFC 9728 discovery; tests are theory-based and fully hermetic via FakeHttpMessageHandler.

Closes #1772.

  • Tests added/updated (93 MCP tests pass, 0 warnings)
  • CLI help updated (--auth, --client-id, probe behavior)
  • No new value objects needed — reuses McpServerName

Comment thread src/Netclaw.Cli/Mcp/McpOAuthProbe.cs Fixed
Comment thread src/Netclaw.Cli/Mcp/McpCommand.cs Fixed
… add

The daemon owns RFC 9728/8414 OAuth discovery through McpOAuthClientRegistrar.
The CLI must not run a second, client-side discovery. This commit removes
McpOAuthProbe and the add-time probe call in McpCommand.

netclaw mcp add no longer probes the endpoint. It now prints an unconditional
hint for HTTP/SSE servers added without an Authorization header: run
netclaw mcp auth first if the server needs OAuth. stdio servers and servers
with an explicit Authorization header keep the permissions-only guidance.

The --auth flag keeps its behavior. It still starts the OAuth flow through
the daemon after add.

Deletes:
- src/Netclaw.Cli/Mcp/McpOAuthProbe.cs
- src/Netclaw.Cli.Tests/Mcp/McpOAuthProbeTests.cs

Refs #1772, #1773.
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.

netclaw mcp add never surfaces OAuth-required servers; permissions hint is a dead end until auth runs

1 participant