Repository navigation
fix(server): allow exact MCP OAuth resource aliases - #23806
freeman-dcarr wants to merge 4 commits into
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Alias configuration and validation apps/server/src/config.ts, apps/server/src/cli/config.ts, apps/server/src/cli/config.test.ts |
ServerConfig adds mcpResourceAliases. The environment parser reads comma-separated values, trims entries, omits empty entries, and rejects URLs that do not meet the canonical HTTPS requirements. Tests cover parsing and rejection cases. |
OAuth authorization and token exchange apps/server/src/auth/McpOAuth.ts, apps/server/src/auth/McpOAuth.test.ts, docs/user/outside-agents.md |
OAuth authorization accepts an exact configured alias and stores the resolved resource. Token exchange defaults an omitted resource to the stored resource and requires a match. Tests cover alias authorization, resource mismatches, spent codes, discovery metadata, and browser-session approval. The setup instructions describe configuring secure MCP tunnel URLs. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Sequence Diagram(s)
sequenceDiagram
participant MCPClient
participant McpOAuth
participant ServerConfig
MCPClient->>McpOAuth: Send authorization request with resource
McpOAuth->>ServerConfig: Read mcpResourceAliases
ServerConfig-->>McpOAuth: Return configured aliases
McpOAuth-->>MCPClient: Return authorization code bound to resolved resource
MCPClient->>McpOAuth: Send token request with code and optional resource
McpOAuth-->>MCPClient: Return token when the resolved resource matches the code resource
Possibly related PRs
- pingdotgg/t3code#18417: Both changes affect MCP approval decisions and retry behavior for the same approval code.
Suggested reviewers: juliusmarminge
Merge Risk: 
Minimal · up to d085a
-
No merge-blocking issue was established. The configured aliases remain intended for addresses that reach the same environment.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title "fix(server): allow exact MCP OAuth resource aliases" follows conventional commit form and names the main change: a configurable exact-match alias list for MCP OAuth resource validation. The changeset adds T3CODE_MCP_RESOURCE_ALIASES parsing, alias matching in McpOAuth.ts, resource binding on authorization codes and CSRF tokens, and related tests and docs. The PR objectives describe the same change, so the title is fully related to the main change.
Full details: Description check
-
Explanation
The description follows the repository template. It has Problem, Change, Scope and approval, and Verification sections. The Problem section explains the failure with the tunnel resource and the invalid_target response. The Change section describes the new option, exact matching, code and CSRF binding, and the docs. The Scope section cites the focused-configuration exception and explains why no prior issue exists. The Verification section lists the tests run, results, negative controls, and items not run. The description is thorough and specific, so it is mostly complete.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
4c7beb6 to
79c1166
Compare
…unnel An OpenAI secure MCP tunnel rewrites protected-resource metadata to its own address, and ChatGPT sends that address as the RFC 8707 resource on both the authorization and token requests, so T3 refused every sign-in with invalid_target. T3CODE_MCP_RESOURCE_ALIASES lists exact https URLs that MCP OAuth also issues tokens for. The accepted resource is bound to the authorization code and must match at token exchange. Nothing changes when the variable is unset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With resource aliases, the same session, client, redirect and PKCE challenge can be approved for more than one resource, so the approval CSRF token now covers the resource too. The user guide notes that removing an alias does not end sign-ins already approved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79c1166 to
d085a93
Compare
Problem
A hosted MCP client can discover and register with T3 through an OpenAI secure MCP tunnel, but the tunnel can advertise its own resource URL, such as
/v1/mcp/<id>. The client sends that resource to/oauth/mcp/authorize; T3 accepts only its native${origin}/mcpresource and returnsinvalid_targetbefore token issuance. This is an observed resource-validation failure, not a demonstrated token-audience rejection.Change
Adds
T3CODE_MCP_RESOURCE_ALIASES, a comma-separated list of trusted alternative resource URLs for the same environment. Unset configuration retains the existing behavior.resourceparameter, browser reachability of the advertised authorization server, configuration rollback, existing-session revocation, and the public authenticated route retained when T3 Connect remains enabled alongside a private tunnel.Aliases only make a rewritten OAuth resource acceptable; they do not provide a general tunnel router or make an unreachable authorization-server address reachable.
Base and head
main, snapshot fetched at 2026-10-26 15:18:05 UTC.3f9448747bb8848050dc2cacf83affa6f94a66a1.d085a93a02282cc247db8b2f34a9b5a2f213d120.The three original patch commits retain identical patch IDs after rebasing. The follow-up adds regression coverage and documentation; the final documentation clarification does not change server code or tests.
Validation
Run in an isolated Windows x64 checkout with Node 26.12.1, pnpm 12.14.0, Vite+ 1.4.0, and a frozen-lockfile dependency installation with lifecycle scripts disabled. No installed T3 instance or live profile was used.
vp test run apps/server/src/auth/McpOAuth.test.ts apps/server/src/cli/config.test.ts: 26 tests passed in 2 files, including native sign-in with aliases configured, exact alias refusals, code/resource binding and single use, cross-origin alias exchange within the same environment, native-origin mismatch refusal, approval CSRF binding, discovery/callback issuer consistency, and alias configuration validation.t3and@t3tools/scripts: passed.knip:checkpasses: passed.git diff --check: passed.Negative controls ran in a separate isolated checkout with the candidate tests:
McpOAuth.tsmakes the alias regression fail atinvalid_targetinstead of the expected approval handoff.The
check:changedwrapper was attempted but stopped during prolonged Git input enumeration, before its checks ran. The selected constituent checks listed above were run directly; this is not a claim that the wrapper completed.Not run: full test suites, full build, or a deployed end-to-end ChatGPT/OpenAI-tunnel sign-in. No deployment was performed. Live sign-in still requires the browser to reach the advertised authorization-server address.
Scope
This is a focused configuration option for the established hosted-agent MCP OAuth capability (#16336, #16718). It changes which exact resource URLs an operator may explicitly trust for that environment, without a new workflow or changed default. No prior issue or discussion preceded this PR; this is the rationale under the focused configuration exception.
Original implementation: Claude Opus 5.5 in Claude Code. Rebase, regression coverage and documentation updates: GPT-6 in Codex, with Claude adversarial review.