Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
2306fb8
feat(oauth): opt-in switch and default-off gate for browser login (Sp…
Dumbris Nov 22, 2026
e0dc9b9
fix(oauth): refuse browser login in every server-edition build (Spec …
Dumbris Nov 22, 2026
bfcc550
feat(oauth): protocol logic for browser login (Spec 132 PR-1b)
Dumbris Nov 22, 2026
1251d0a
fix(oauth): tighten redirect matching and bound in-memory state (Spec…
Dumbris Nov 22, 2026
fb7d861
fix(oauth): align code and request expiry, make limiter admission ato…
Dumbris Nov 22, 2026
8f51f22
feat(oauth): storage for browser logins and one binding writer (Spec …
Dumbris Nov 22, 2026
6d74c98
test(oauth): scope the no-storage check to browser-login state (Spec …
Dumbris Nov 22, 2026
143494c
fix(oauth): harden browser-login storage after review (Spec 132 PR-1c)
Dumbris Nov 22, 2026
8ecda0a
fix(oauth): validate bindings only where a browser-login copy exists …
Dumbris Nov 22, 2026
5716d19
fix(oauth): restore pins by binding incarnation, keep connect snapsho…
Dumbris Nov 22, 2026
3bd6cdd
Merge remote-tracking branch 'origin/feat/client-oauth-login-switch' …
Dumbris Nov 22, 2026
f51b746
feat(oauth): browser-login service, client views and guard (Spec 132 …
Dumbris Nov 22, 2026
a592315
fix(oauth): close cancellation, token-endpoint and client-view gaps (…
Dumbris Nov 22, 2026
4981623
fix(oauth): close exchange/approve races and rollback guard gap (Spec…
Dumbris Nov 22, 2026
17c9397
fix(oauth): fence the exchange with config commits, atomic key creati…
Dumbris Nov 22, 2026
0761328
fix(oauth): fence refresh with config commits, complete key-file fall…
Dumbris Nov 22, 2026
dc01d1a
feat(oauth): browser-login endpoints and access-token auth (Spec 132 …
Dumbris Nov 22, 2026
6c66382
fix(oauth): close stream, cross-site and contract gaps after review (…
Dumbris Nov 23, 2026
f08df21
fix(oauth): end blocked streams on revoke, cancel across quick off/on…
Dumbris Nov 23, 2026
b89b95d
fix(oauth): order the disable epoch, per-run stream tracking (Spec 13…
Dumbris Nov 23, 2026
3f8eacb
fix(oauth): bump the disable epoch only on publish, bind streams to a…
Dumbris Nov 23, 2026
ff2b6e7
test(oauth): end-to-end script, docs and real-client record for brows…
Dumbris Nov 23, 2026
b62f508
test(oauth): harden the browser-login e2e script, correct docs (Spec …
Dumbris Nov 23, 2026
133210d
test(oauth): real-shaped forged tokens, isolate the manual check (Spe…
Dumbris Nov 23, 2026
44ac406
docs(oauth): qualify the server-edition 404 (Spec 132 PR-1f)
Dumbris Nov 23, 2026
5c0b698
docs(oauth): record the Claude Code real-client check (Spec 132 PR-1f)
Dumbris Nov 23, 2026
f118305
feat(oauth): consent page for browser login (Spec 132 PR-2a)
Dumbris Nov 23, 2026
60723ab
fix(oauth): consent page review round 1, backend (Spec 132 PR-2a)
Dumbris Nov 23, 2026
94fb487
fix(oauth): consent page review round 1, page and replace ownership (…
Dumbris Nov 23, 2026
db9a666
fix(oauth): consent page review round 2 (Spec 132 PR-2a)
Dumbris Nov 23, 2026
313f261
fix(oauth): consent page review round 3 (Spec 132 PR-2a)
Dumbris Nov 23, 2026
fef8406
fix(oauth): consent page review round 4 (Spec 132 PR-2a)
Dumbris Nov 23, 2026
0a0cd93
fix(oauth): consent page review round 5 (Spec 132 PR-2a)
Dumbris Nov 23, 2026
09b8281
test(oauth): Playwright spec for the consent page (Spec 132 PR-2a, T061)
Dumbris Nov 23, 2026
a0a84a8
fix(oauth): consent page security review fixes (Spec 132 PR-2a)
Dumbris Nov 23, 2026
4a2f24e
fix(oauth): normalise the initialize name like the registered name (S…
Dumbris Nov 23, 2026
ee47435
feat(oauth): manage browser logins in Clients hub, CLI and MCP (Spec …
Dumbris Nov 23, 2026
8a407ea
fix(oauth): refuse blank login ids and lock the revoke dialog while i…
Dumbris Nov 23, 2026
5bba11c
Merge origin/main into feat/client-oauth-login-storage
Dumbris Nov 23, 2026
2f17cd2
Merge storage slice and main into feat/client-oauth-login-runtime
Dumbris Nov 23, 2026
7c19092
test(oauth): fixture credential expiry follows the real clock (Spec 1…
Dumbris Nov 23, 2026
4f99a0f
feat(tray): approve browser sign-in requests from the tray (Spec 132 …
Dumbris Nov 23, 2026
97a6068
fix(tray): sign-in requests survive neither stale reloads nor reconne…
Dumbris Nov 23, 2026
6aaa317
fix(tray): a decision for an unknown request still invalidates an in-…
Dumbris Nov 23, 2026
20d1abd
feat(connect): browser-login choice for supported clients (Spec 132 P…
Dumbris Nov 23, 2026
22acde5
fix(connect): address, reconcile, payload and stale-preview fixes for…
Dumbris Nov 23, 2026
34659a1
fix(connect): browser-login entries survive a tls or listener change …
Dumbris Nov 23, 2026
1b8fab8
fix(connect): Undo never takes the browser-login address from the fil…
Dumbris Nov 23, 2026
22b68be
fix(connect): only clients that support browser login can own an oaut…
Dumbris Nov 23, 2026
889e356
fix(connect): browser-login candidates come only from the normalised …
Dumbris Nov 23, 2026
5b20ad1
Merge origin/main into feat/client-oauth-login-runtime
Dumbris Nov 23, 2026
a133327
Merge runtime slice and main into feat/client-oauth-login-http
Dumbris Nov 23, 2026
70d7794
fix(connect): Undo trusts a digest recorded at write time, not a repl…
Dumbris Nov 23, 2026
05e5080
test(auth): skip the key-file mode check on Windows (Spec 132 PR-1d)
Dumbris Nov 23, 2026
92aa00a
fix(connect): only browser-login connects write an undo record (Spec …
Dumbris Nov 23, 2026
576fed7
fix(connect): atomic undo record, one record per created-file connect…
Dumbris Nov 23, 2026
b90a6f8
test(storage): repin order test no longer depends on hash luck (Spec …
Dumbris Nov 23, 2026
265558e
fix(connect): a created-file connect retires the stale records of its…
Dumbris Nov 23, 2026
868a20d
fix(connect): every connect retires stale undo records; records are f…
Dumbris Nov 23, 2026
4aaa453
fix(connect): foreign records are never retired; unlistable directori…
Dumbris Nov 23, 2026
c92f031
fix(connect): a failed connect changes no undo record (Spec 132 PR-3)
Dumbris Nov 23, 2026
54653b3
Merge runtime slice into feat/client-oauth-login-http
Dumbris Nov 23, 2026
41a51a6
Merge origin/main into feat/client-oauth-login-http
Dumbris Nov 23, 2026
fed24cd
Merge http slice into feat/client-oauth-login-e2e
Dumbris Nov 23, 2026
db811ed
Merge e2e slice into feat/client-oauth-login-consent
Dumbris Nov 23, 2026
9abd1c1
chore: drop review scratch files committed by mistake (Spec 132 PR-2b)
Dumbris Nov 23, 2026
9e6e6f7
Merge consent slice into feat/client-oauth-login-hub
Dumbris Nov 23, 2026
8251402
Merge hub slice into feat/client-oauth-login-tray
Dumbris Nov 23, 2026
d9a8fe3
Merge tray slice into feat/client-oauth-login-connect
Dumbris Nov 23, 2026
1c10156
fix(server): a stopped run no longer stops or unmarks the next run (S…
Dumbris Nov 23, 2026
bc5ae6f
fix(server): a stop in progress leaves a newly started run alone (Spe…
Dumbris Nov 23, 2026
c247595
Merge remote-tracking branch 'origin/feat/client-oauth-login-http' in…
Dumbris Nov 23, 2026
82da502
Merge remote-tracking branch 'origin/main' into feat/client-oauth-log…
Dumbris Nov 23, 2026
88bb54d
Merge remote-tracking branch 'origin/feat/client-oauth-login-e2e' int…
Dumbris Nov 23, 2026
34994a6
docs: trim the oldest Recent Changes entries from CLAUDE.md
Dumbris Nov 23, 2026
9811711
Merge remote-tracking branch 'origin/feat/client-oauth-login-e2e' int…
Dumbris Nov 23, 2026
6abbf43
Merge remote-tracking branch 'origin/main' into feat/client-oauth-log…
Dumbris Nov 23, 2026
e44f61b
Merge remote-tracking branch 'origin/feat/client-oauth-login-consent'…
Dumbris Nov 23, 2026
6d31703
test(oauth): run the consent spec in the Web UI sweep (Spec 132 PR-2a)
Dumbris Nov 23, 2026
16a09f5
Merge remote-tracking branch 'origin/feat/client-oauth-login-consent'…
Dumbris Nov 23, 2026
a72e91a
Merge remote-tracking branch 'origin/main' into feat/client-oauth-log…
Dumbris Nov 23, 2026
99c3659
Merge remote-tracking branch 'origin/feat/client-oauth-login-hub' int…
Dumbris Nov 23, 2026
e7b5b0b
Merge remote-tracking branch 'origin/main' into feat/client-oauth-log…
Dumbris Nov 24, 2026
301b978
Merge remote-tracking branch 'origin/feat/client-oauth-login-tray' in…
Dumbris Nov 24, 2026
833f590
Merge remote-tracking branch 'origin/main' into feat/client-oauth-log…
Dumbris Nov 24, 2026
1895181
fix(connect): supersede undo records by config generation, not time (…
Dumbris Nov 24, 2026
948918c
fix(connect): serialise undo-state writers and make the state durable…
Dumbris Nov 24, 2026
ff1d06f
fix(connect): lock the config directory across processes for undo sta…
Dumbris Nov 24, 2026
d688a15
docs: note undo state and config lock for Connect browser login (Spec…
Dumbris Nov 24, 2026
e863621
test(connect): strip Vue comment placeholders until stable (Spec 132 …
Dumbris Nov 24, 2026
af0d13b
test(connect): run the feature-off golden on macOS only (Spec 132 PR-3)
Dumbris Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ tail -f ~/Library/Logs/mcpproxy/main.log # main log (macOS; Linux: ~/.mcpproxy/
- **Windows installer**: [docs/github-actions-windows-wix-research.md](docs/github-actions-windows-wix-research.md). **Prerelease** (`next` branch + `v*-rc.*` tags, opt-in, off stable channels): [docs/prerelease-builds.md](docs/prerelease-builds.md).

## Recent Changes
- 132-client-oauth-login (PR-3): Go 1.26, Vue 3 Web UI, Swift macOS app, docs — Connect can write a client's browser sign-in address. `connect.ClientDef.SupportsBrowserLogin` is true only for `claude-code` (the one real-client check that passed; add a client only after a recorded check in `specs/132-client-oauth-login/verification/real-clients.md`). `CredentialIntent.Auth` / `ConnectOptions.Auth` = `key` (default) | `oauth`: `oauth` writes `<base>/oauth/<client-id>` with no header/credential, never calls the minter, masks nothing, is refused (`*connect.AuthChoiceError`, HTTP 400, CLI exit 1) when `mcp_oauth_enabled` is off (`Service.WithMCPOAuthEnabled`), the client is unsupported, the build is the server edition (`browserLoginEditionSupported`) or with keyless/profile/mode; `urlPointsHere` lets status, Disconnect and Undo recognise it; Connect never revokes the API key (`auth_note`). Undo of an `oauth` connect is authorised by a record beside the config (`internal/connect/undo_record.go`) plus `<config>.undo.state` (`undo_state.go`: a created-file record counts only while the state is settled and names its generation); every config writer runs under `lockConfig` (process mutex + directory flock on Unix, `dirlock_*.go`); a config that never had an `oauth` connect gets no extra file. Payload: `supports_browser_login`, `browser_login_available` (client list/status/preview), `auth` (result, preview, status). CLI `mcpproxy connect <client> --auth key|oauth`; Web UI choice in `ClientConnectList.vue` and macOS `ConnectClientView` only when `browser_login_available`. Docs: `docs/features/client-oauth-login.md` "Connecting a client to browser login". **No new dependencies.**
- 132-client-oauth-login (PR-1): Go 1.26, backend + docs — opt-in (`mcp_oauth_enabled`, default off, env `MCPPROXY_MCP_OAUTH_ENABLED`) OAuth 2.1 authorization server so MCP clients can sign in through the browser beside API keys: public clients, PKCE S256, DCR, RFC 9728/8414 metadata, RFC 8707 `resource`; loopback peers and Hosts only; personal edition only. Addresses `/mcp/oauth` and `/mcp/oauth/<client-id>` (`internal/server/oauth_login_*.go`, access token `mcp_oat_`, refresh `mcp_ort_`, replay of a rotated refresh token revokes the login), admin REST `/api/v1/oauth/authorizations/{id}/approve|deny|preview` and logins on `/clients` (`internal/httpapi/oauth_login.go`, `clients_logins.go`), runtime in `internal/runtime/oauth_login_*.go`, wire rules in `internal/mcplogin/`, lazy buckets (off and never used: nothing stored; a client registration already persists a row, approval writes only an audit activity row, the login is stored at token exchange). No consent page yet (PR-2). Gate: `scripts/test-client-oauth-e2e.sh`. Docs: `docs/features/client-oauth-login.md`. **No new dependencies.**
- 125-skills-over-mcp (PR-5): Go 1.26, backend + docs — native skills extension on `/mcp/s/<server>` only (`internal/server/skills_native.go`): with `enable_skills` on and the server not excluded the instance is built with `WithExtensions`+`WithResourceCapabilities`; an interceptor (inside `singleServerSessionGuard`, in front of the transport) answers `skills/list`, `skills/get`, `resources/read` from `ListAvailableSkills`/`AvailableSkillFile`, byte for byte (a mutating output policy withholds instead of rewriting), one `skill_access` row each (tool = method). Transport checks are reused, not copied: the request is first sent through the transport with its method replaced by `ping`, and a refusal is replayed unchanged. Endpoint lifecycle (`mcp_single_server.go`): instance, transport and generation acquired together under `singleServersMu` (`acquireSingleServerEndpoint`), retirement detaches all three and advances the generation baked into session ids (`newSingleServerSessionIDs(server, gen)`), retired GET streams end, the upstream name rides on the request (`withSingleServerEndpoint`, `singleServerNameFor(ctx, srv)`); retired from `RefreshSkillsAvailability` and lazily on acquisition. Docs: `docs/features/skills.md` "Native skills on single-server endpoints". **No new dependencies.**
- 126-day-two-activation (PR-A): Go 1.26, backend + docs — telemetry schema 17, instrumentation only (no onboarding, UI or API change). Install anchor: `storage.EnsureInstallAnchor` (own bucket `install_anchor`, written once in `runtime.New` after the Spec 080 shutdown marker and Spec 123 OAuth boot sweep, before any other startup write, only when `config.db` held no record other than `meta/schema_version` at open, `BoltDB.WasEmptyAtOpen`; never from onboarding writes; recorded with telemetry off; read once per process for both `day_two` and `window_age`). `upstream_outcomes {succeeded, unusable, succeeded_non_starter, coverage, window_age}` (`internal/telemetry/upstream_outcomes.go`): one outcome per LOGICAL call that dispatched (dispatch counts requests), begun right after `noteUpstreamDispatched` and deferred (`upstreamOutcome` in `internal/server/mcp_upstream_telemetry.go`) on the wrapper, direct routing and `code_execution` sub-calls, guarded by an AST test; part of the drained window (retries byte-identical); `coverage` from the persisted `outcome_window_undelivered` marker (`outcome_window.go`: set by the first outcome after start or a Drain, cleared after a 2xx only if nothing was counted since that drain, both under the outcome window's own mutex, never `deliveryMu`), `window_age` = install age when the window opened (start or Drain), `install_origin: fresh` personal only. `day_two {install_origin, install_age, success_scope_ever}` personal only (`day_two.go`: UTC calendar-date buckets; `success_scope.go` forward-only ordinal in the activation bucket). `runtime.StarterClassifier` (default false, `SetStarterClassifier` for PR-B) + `Runtime.RecordUpstreamOutcome`. `ScanForPII` closed-object rule `day_two_field_invalid`. Docs: `docs/features/telemetry.md` "Schema v17". **No new dependencies.**
Expand Down
161 changes: 161 additions & 0 deletions cmd/mcpproxy/connect_auth_flag_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
//go:build !server

package main

import (
"encoding/json"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"

"github.com/spf13/cobra"
"github.com/stretchr/testify/require"

clioutput "github.com/smart-mcp-proxy/mcpproxy-go/internal/cli/output"
"github.com/smart-mcp-proxy/mcpproxy-go/internal/config"
"github.com/smart-mcp-proxy/mcpproxy-go/internal/connect"
)

// Spec 132 PR-3: `mcpproxy connect <client> --auth key|oauth`.

func seedClaudeCode(t *testing.T, home string) string {
t.Helper()
path := filepath.Join(home, ".claude.json")
require.NoError(t, os.WriteFile(path, []byte("{}\n"), 0o644))
return path
}

// connectAuthEnv is connectTestEnv with browser login switched on or off in the
// CLI's config file.
func connectAuthEnv(t *testing.T, oauthOn bool) (home string) {
t.Helper()
home, cfg := connectTestEnv(t, true)
cfg.MCPOAuthEnabled = oauthOn
require.NoError(t, config.SaveConfig(cfg, configFile))
return home
}

func TestConnectAuthFlag_HelpJSONListsIt(t *testing.T) {
if os.Getenv("MCPPROXY_CONNECT_AUTH_HELP_JSON_HELPER") == "1" {
root := &cobra.Command{Use: "mcpproxy"}
root.AddCommand(GetConnectCommand())
clioutput.SetupHelpJSON(root)
root.SetArgs([]string{"connect", "--help-json"})
require.NoError(t, root.Execute())
return
}
cmd := exec.Command(os.Args[0], "-test.run=^TestConnectAuthFlag_HelpJSONListsIt$")
cmd.Env = append(os.Environ(), "MCPPROXY_CONNECT_AUTH_HELP_JSON_HELPER=1")
out, err := cmd.CombinedOutput()
require.NoError(t, err, string(out))
var payload struct {
Flags []struct {
Name string `json:"name"`
Default string `json:"default"`
} `json:"flags"`
}
require.NoError(t, json.Unmarshal(out, &payload), string(out))
found := false
for _, f := range payload.Flags {
if f.Name == "auth" {
found = true
require.Equal(t, "key", f.Default)
}
}
require.True(t, found, "--help-json must list --auth: %s", out)
}

func TestConnectAuthFlag_OAuthWritesOnlyTheAddress(t *testing.T) {
home := connectAuthEnv(t, true)
path := seedClaudeCode(t, home)

out, err := runConnectArgs(t, "claude-code", "--auth", "oauth")
require.NoError(t, err, out)

raw, err := os.ReadFile(path)
require.NoError(t, err)
body := string(raw)
require.Contains(t, body, "/mcp/oauth/claude-code")
for _, bad := range []string{"headers", "X-API-Key", "mcp_cli_", "mcp_oat_", "cli-test-admin-key"} {
require.NotContains(t, body, bad)
}
require.NotContains(t, out, "Credential:", "no credential line for a browser login")
require.Contains(t, out, "Sign-in: browser")
require.Contains(t, out, "does not revoke")
require.Contains(t, out, "Next: ")
}

func TestConnectAuthFlag_KeyIsTheDefault(t *testing.T) {
home := connectAuthEnv(t, true)
path := seedClaudeCode(t, home)
out, err := runConnectArgs(t, "claude-code", "--auth", "key")
require.NoError(t, err, out)
require.Contains(t, out, "Credential: mcp_cli_••••")
require.NotContains(t, out, "Sign-in:")
raw, _ := os.ReadFile(path)
require.NotContains(t, string(raw), "/mcp/oauth")
}

func TestConnectAuthFlag_Refusals(t *testing.T) {
t.Run("feature off", func(t *testing.T) {
home := connectAuthEnv(t, false)
path := seedClaudeCode(t, home)
out, err := runConnectArgs(t, "claude-code", "--auth", "oauth")
require.Error(t, err, out)
require.Contains(t, err.Error(), "mcp_oauth_enabled")
require.Equal(t, ExitCodeGeneralError, classifyError(err))
raw, _ := os.ReadFile(path)
require.Equal(t, "{}\n", string(raw))
})
t.Run("unsupported client", func(t *testing.T) {
home := connectAuthEnv(t, true)
path := seedCursor(t, home)
out, err := runConnectArgs(t, "cursor", "--auth", "oauth")
require.Error(t, err, out)
require.Contains(t, err.Error(), "does not support browser login")
require.Equal(t, ExitCodeGeneralError, classifyError(err))
raw, _ := os.ReadFile(path)
require.Equal(t, "{}\n", string(raw))
})
t.Run("unknown value", func(t *testing.T) {
connectAuthEnv(t, true)
_, err := runConnectArgs(t, "claude-code", "--auth", "magic")
require.Error(t, err)
require.Contains(t, err.Error(), "--auth must be key or oauth")
require.Equal(t, ExitCodeGeneralError, classifyError(err))
})
t.Run("combined with a binding", func(t *testing.T) {
connectAuthEnv(t, true)
for _, extra := range [][]string{{"--keyless"}, {"--profile", "ro"}, {"--lock", "--profile", "ro"}, {"--switchable"}} {
_, err := runConnectArgs(t, append([]string{"claude-code", "--auth", "oauth"}, extra...)...)
require.Error(t, err, strings.Join(extra, " "))
require.Contains(t, err.Error(), "--auth oauth cannot be combined")
}
})
}

// A daemon refusal (HTTP 400) of an oauth write exits 1 and prints its text.
func TestConnectAuthFlag_DaemonSendsAuthAndPrintsRefusal(t *testing.T) {
connectAuthEnv(t, true)
var body map[string]any
fakeConnectDaemon(t, 400, `{"success":false,"error":"browser login is off: set mcp_oauth_enabled to true first"}`, &body)
_, err := runConnectArgs(t, "cursor", "--auth", "oauth")
require.Error(t, err)
require.Equal(t, "oauth", body["auth"])
require.Contains(t, err.Error(), "mcp_oauth_enabled")
require.Equal(t, ExitCodeGeneralError, classifyError(err))

// The default sends no auth at all.
body = nil
fakeConnectDaemon(t, 200, `{"success":true,"data":{"success":true,"client":"cursor","action":"created","message":"ok","credential":"mcp_cli_••••","token_name":"client-cursor","mode":"switchable"}}`, &body)
_, err = runConnectArgs(t, "cursor")
require.NoError(t, err)
require.NotContains(t, body, "auth")
}

func TestConnectAuthLine(t *testing.T) {
require.Equal(t, "", connectAuthLine(&connect.ConnectResult{}))
require.Contains(t, connectAuthLine(&connect.ConnectResult{Auth: "oauth"}), "Sign-in: browser")
}
43 changes: 43 additions & 0 deletions cmd/mcpproxy/connect_auth_reconcile_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//go:build !server

package main

import (
"os"
"testing"

"github.com/stretchr/testify/require"

"github.com/smart-mcp-proxy/mcpproxy-go/internal/connect"
)

// A browser-login connect, refused or not, never finalises a staged key
// rotation in the offline path either.
func TestConnectAuthFlag_OfflineOAuthDoesNotReconcileAKeyRotation(t *testing.T) {
for _, featureOn := range []bool{false, true} {
home := connectAuthEnv(t, featureOn)
path := seedClaudeCode(t, home)
cfg, err := loadConnectConfig()
require.NoError(t, err)
backend, err := newOfflineConnectBackend(cfg)
require.NoError(t, err)

first, err := backend.connect("claude-code", "", false, connect.CredentialIntent{})
require.NoError(t, err)
require.True(t, first.Success)
m := backend.clients.ConnectMinter()
issued, err := m.Issue("claude-code", connect.CredentialIntent{})
require.NoError(t, err)
m.Release("claude-code", issued)
require.NoError(t, os.WriteFile(path, []byte(`{"mcpServers":{"mcpproxy":{"type":"http","url":"http://127.0.0.1:1/mcp","headers":{"X-API-Key":"`+issued.Secret+`"}}}}`), 0o644))
view, err := backend.clients.Get("claude-code")
require.NoError(t, err)
require.True(t, view.RotationPending)

_, _ = backend.connect("claude-code", "", true, connect.CredentialIntent{Auth: connect.AuthOAuth})
view, err = backend.clients.Get("claude-code")
require.NoError(t, err)
require.True(t, view.RotationPending, "featureOn=%v: the staged rotation must survive an oauth connect", featureOn)
backend.close()
}
}
22 changes: 21 additions & 1 deletion cmd/mcpproxy/connect_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@ existing binding unless you pass --profile. With require_mcp_auth off, a named
binding is refused unless an anonymous caller could not reach more than the
client (the refusal lists the fixes); --keyless writes no credential.

--auth oauth (Spec 132, experimental) writes only the client's browser sign-in
address, <mcp-url>/oauth/<client-id>, with no header and no credential; the
client signs in through the browser and you approve it on the consent page.
It is refused while mcp_oauth_enabled is off, for a client that has not passed a
real-client check (today only claude-code), in the server edition, and together
with --profile, --lock, --switchable or --keyless. Connect never revokes the
client's existing API key. To switch an existing entry, add --force.

Examples:
mcpproxy connect --list # Show all clients and their status
mcpproxy connect claude-code # Register in Claude Code
mcpproxy connect cursor --profile ro # Bind Cursor to profile "ro" (locked)
mcpproxy connect cursor --profile work --switchable
mcpproxy connect claude-code --auth oauth # Browser sign-in address only, no credential (needs mcp_oauth_enabled)
mcpproxy connect cursor --force # Overwrite existing entry
mcpproxy connect codex --name my-proxy # Custom server name
mcpproxy connect opencode # Register in OpenCode
Expand Down Expand Up @@ -94,7 +103,9 @@ func runConnect(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to load config: %w", err)
}

svc := connect.NewService(cfg.Listen, cfg.APIKey).WithRequireMCPAuth(cfg.RequireMCPAuth)
svc := connect.NewService(cfg.Listen, cfg.APIKey).WithRequireMCPAuth(cfg.RequireMCPAuth).
WithMCPOAuthEnabled(func() bool { return cfg.MCPOAuthEnabled }).
WithTLSEnabled(func() bool { return cfg.TLS != nil && cfg.TLS.Enabled })

format := clioutput.ResolveFormat(globalOutputFormat, globalJSONOutput)
formatter, err := clioutput.NewFormatter(format)
Expand Down Expand Up @@ -344,9 +355,18 @@ func printConnectResult(result *connect.ConnectResult, formatter clioutput.Outpu
if line := connectCredentialLine(result); line != "" {
fmt.Println(line)
}
if line := connectAuthLine(result); line != "" {
fmt.Println(line)
if result.AuthNote != "" {
fmt.Printf("Note: %s\n", result.AuthNote)
}
}
if line := disconnectCredentialLine(result); line != "" {
fmt.Println(line)
}
if result.CleanupError != "" {
fmt.Printf("Cleanup: the entry was removed but its undo records could not be removed (%s)\n", result.CleanupError)
}
// FR-037: Config shows the home-shortened display_path; the full
// path is still available via -o json's config_path.
fmt.Printf("Config: %s\n", connectResultDisplayPath(result))
Expand Down
Loading
Loading