Repository navigation
Enforce the RFC 8707 resource indicator at the OAuth endpoints - #127
Conversation
There was a problem hiding this comment.
Pull request overview
Enforces RFC 8707 resource indicators so OAuth tokens target the current MCP instance.
Changes:
- Validates resources at authorization and token endpoints.
- Adds URL normalization and rejection tests.
- Preserves compatibility when
resourceis absent.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (3)
src/auth.rs:915
- The userinfo check misses an empty userinfo component:
Url::parse("https://@mcp.test/mcp")has an empty username and no password, so this value passes even though it is userinfo-bearing and not the advertised identifier. Detect the@delimiter in the authority (and add this case to the rejection test) rather than relying only on username/password values.
if got.fragment().is_some() || !got.username().is_empty() || got.password().is_some() {
src/auth.rs:1851
- The token endpoint has the same repeated-parameter gap: RFC 8707 allows multiple
resourcefields, whileOption<String>causes form extraction to fail beforetoken_authorization_codecan returninvalid_targetor preserve the code under the documented validation path. Parse all values and validate them, or map unsupported multiplicity to an OAuthinvalid_targetresponse explicitly.
#[serde(default)]
resource: Option<String>,
src/auth.rs:892
- RFC 8707 permits multiple
resourceparameters, but a scalar field makes Serde reject duplicates beforeauthorizeruns. A request containing this issuer plus a foreign resource therefore gets an extractor/deserialization error instead of the promised OAuthinvalid_target. Parse all resource values, then either validate each one or deliberately reject unsupported multiplicity withinvalid_target.
This issue also appears on line 1850 of the same file.
#[serde(default)]
resource: Option<String>,
|
Added strict RFC 8707 mode (38dc04c). Previously the checks refused a foreign
Trade-off: strict turns away any client too old to send |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
src/main.rs:51
- The PR description explicitly promises that an omitted
resourceremains accepted for legacy clients and says requiring it is a possible follow-up. With the environment variable unset, this instead enables strict mode and rejects those clients at both endpoints. This is a user-visible compatibility change; either default to lenient mode as described or update the PR contract to make the breaking strict default explicit.
Err(_) => true,
src/lib.rs:138
- Adding this required public field makes every existing
McpConfigstruct literal fail to compile. The copyable example inREADME.md:42-48is already stale because it omitsrequire_resource; update that example (and any external migration guidance) with the intended policy value.
pub require_resource: bool,
The MCP authorization spec requires the authorization server to bind an access token to the resource the client requested (RFC 8707 Resource Indicators). This server parsed the `resource` parameter at `/oauth/authorize` but left it unused (`#[allow(dead_code)]`), and the token endpoint did not parse it at all, so the audience the client asked for had no effect on the token that was issued. Enforce it at both legs: a `resource` that does not name this instance's own issuer is refused with `invalid_target`, so a token is only ever issued for this resource. Validation is per-leg against the instance issuer; with exactly one valid resource per instance that is equivalent to binding it into the authorization code and re-checking, without the extra state. A MISSING `resource` is still accepted, for clients that predate RFC 8707. The token-endpoint check runs before the code is consumed, so a spurious request cannot burn a valid pending code. Adds unit coverage for the normalized issuer match (case, default port, trailing slash, fragment, sibling-instance path) and end-to-end checks that both endpoints refuse a foreign resource while a canonical or absent one still completes. Co-Authored-By: Claude Opus 5 <[email protected]>
Address review feedback on `resource_matches_issuer`: the normalization was looser than "exactly the published resource". It now refuses a userinfo component and a fragment outright, compares the query (RFC 8707 treats it as part of the identifier, and the issuer carries none), and strips at most one trailing slash so a doubled slash stays a distinct path. None of these affected the cross-host case the check already caught, but the matcher is now limited to the exact advertised resource. Adds reject coverage for userinfo, a differing query, and a doubled trailing slash. Co-Authored-By: Claude Opus 5 <[email protected]>
The resource check refused a foreign `resource` but tolerated a missing one, which left the confused-deputy token-theft path open for any client that never sends `resource` at all. Add a `require_resource` policy that, when set, makes both OAuth legs REQUIRE a `resource` naming this instance — a missing one is refused with `invalid_request`, a foreign one still with `invalid_target`. Injected via `McpConfig::require_resource` and driven from the `OAUTH_REQUIRE_RESOURCE` env in the binary, defaulting to strict (on). Set the env to a falsey value to fall back to lenient for clients predating RFC 8707; a rejected missing-`resource` request is logged so operators can see whether any real client is affected before/after the flip. Router and e2e tests stay lenient (their flows carry no resource); strict is covered by new authorize/token unit tests. Co-Authored-By: Claude Opus 5 <[email protected]>
38dc04c to
76b6318
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/lib.rs:138
- Adding this required public field makes the README quick-start
McpConfigliteral at README.md:42-48 fail to compile because it does not initializerequire_resource. Update that public example alongside the API change so users can build the documented integration.
pub require_resource: bool,
src/main.rs:51
- The implementation defaults to rejecting a missing
resource, but the PR description explicitly says a missing value remains accepted to preserve pre-RFC-8707 clients. With the variable unset, those clients now fail both OAuth legs, so either make lenient mode the default (and align the README) or update the stated compatibility contract.
Err(_) => true,
`url` normalizes an empty userinfo away (`https://@host` and `https://:@host` both parse to `https://host`), so the `username()`/`password()` guard couldn't see it and such a value compared equal to the issuer — contrary to the doc, which states userinfo is refused. Scan the raw authority for `@` so every userinfo form is rejected before `url` erases it. Not a security bypass (the host is unchanged either way), but it makes the matcher match its contract. Adds `https://@mcp.test/mcp` and `https://:@mcp.test/mcp` to the reject cases. Co-Authored-By: Claude Opus 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
src/main.rs:52
- The PR description explicitly promises that a missing
resourceremains accepted for compatibility, but the bundled server defaults this flag totrue, so existing clients that omit it now fail at both OAuth legs unless operators discover and set the opt-out. Please reconcile the rollout contract: either make the unset default lenient as described, or update the PR description to call out this breaking default and its migration requirement.
fn require_resource() -> bool {
match std::env::var("OAUTH_REQUIRE_RESOURCE") {
Ok(v) => !matches!(v.trim().to_ascii_lowercase().as_str(), "0" | "false" | "no" | "off"),
Err(_) => true,
}
src/lib.rs:138
- Adding this required public field makes the README quick-start at
README.md:42-48fail to compile because itsMcpConfigliteral still omitsrequire_resource. Update that user-facing example (and document which policy embedded callers should choose) alongside the API change.
/// Strict RFC 8707 resource indicators: when `true`, both OAuth legs REQUIRE
/// a `resource` naming this instance, refusing a request that omits it (not
/// just one that names a foreign server). This closes the confused-deputy
/// token-theft path even for clients that never send `resource`, at the cost
/// of turning away any client predating RFC 8707. When `false`, a missing
/// `resource` is tolerated (a present one must still match).
pub require_resource: bool,
My previous commit replaced the parsed username/password checks with only a raw-authority scan for `@`. But `url` strips ASCII tab/newline/CR from anywhere in the input before parsing (WHATWG URL), so `https:\t//[email protected]/mcp` parses WITH userinfo while the literal `://` scan never fires — and with the parsed checks gone, nothing caught it (same host, so not a cross-origin bypass, but it violated the matcher's contract). Reject raw `\t`/`\n`/`\r` up front so stripping can't desync the raw scan, and keep BOTH the parsed username/password checks (authoritative for any non-empty userinfo) and the raw scan (for the empty userinfo url erases). Adds tab- and newline-smuggling reject cases. Co-Authored-By: Claude Opus 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (3)
src/auth.rs:946
url::Urlalso strips leading and trailing WHATWG C0 controls/spaces before parsing. Consequently a decoded value such asresource=%20https%3A%2F%2Fmcp.test%2Fmcp%20compares equal to the issuer even though it is not an RFC 3986 absolute URI and is outside the documented tolerated variants. Reject this parser preprocessing in the raw input as well, and add the case to the rejection test.
if got.fragment().is_some()
|| resource.contains(['\t', '\n', '\r'])
|| !got.username().is_empty()
|| got.password().is_some()
|| raw_authority_has_userinfo(resource)
src/main.rs:51
- The PR description explicitly promises that a missing
resourceremains accepted for pre-RFC-8707 clients, but an unset environment variable selects strict mode here, so the default deployment rejects those clients at both OAuth legs. This is a material compatibility change beyond the stated rollout. Either default to lenient behavior or update the PR contract and all user-facing configuration guidance to make the breaking default explicit.
Err(_) => true,
src/auth.rs:929
- This matcher documentation is attached by Rustdoc to
raw_authority_has_userinfo, because that helper is the next item;resource_matches_issueritself receives no documentation. Move the helper and its focused docs before this block so each function is documented with the behavior it implements.
/// Whether a client-supplied RFC 8707 `resource` indicator names THIS instance's
/// own MCP resource — its AS issuer, `{public_url}{mcp_path}` (e.g.
/// `https://mcp.internetcomputer.org/mcp`), which is exactly the value published
/// as `resource` in the protected-resource metadata.
///
Re-verify every claim and file:line reference against the rebased tree and absorb what main already did or changed: - The five vestigial deps (ed25519-dalek, p256, ic-signature-verification, ic-representation-independent-hash, schemars 0.8) were already removed on main (#100) — reframe that stripping work as done. - Account for the new hosted-only surfaces the local split must gate: prometheus + src/metrics.rs (/metrics, #124) and McpConfig's state_dir/require_resource (#144/#127); note the local binary needs no state directory at all. pocket-ic (e2e-only, #76) never enters any closure. - Rewrite §10: production II now serves at /mcp by default (#92), CI probes it (#113), and the PocketIC e2e harness verifies the full connect contract — the remaining unknowns are the local binary's http://127.0.0.1 mixed-content and CORS behavior, and the harness is the plan for testing the local flow. - Prod-instance env overrides are II_URL_PROD/II_CANISTER_ID_PROD (#92); registration chains are also verified client-side against the agent's root key (new_with_root_key); registration_pubkey_b64 is now fallible; AuthStore's dropped fields now include mcp_path and require_resource, and the dropped OAuth side grew RFC 8707/9207 and the bounded DCR store. - Note the crates.io publishing dimension (v0.2.0, tag-guarded trusted publishing, docs/ excluded from the .crate) and re-stamp every stale file:line reference (auth.rs shifted ~500-650 lines; the 13 call-site list and all evidence-index anchors updated). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK
…148) * Add scoping doc for a local-deployment MCP instance Analyze the current beta/prod composition and scope a secondary server instance that bridges the MCP tools to a local dfx replica instead of mainnet. Documents the mainnet assumptions that would break locally (root-key fetch, hard-coded IC_URL, the discovery SSRF/https guard, target_origin canonicalization, and the CMC/ledger management path), a proposed local run-profile design, the security guardrails, a phased work breakdown, and open decisions. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Rescope: minimal stdio local binary, no OAuth, prod II Rewrite the scoping doc for the intended model: a separate, minimal run-it-yourself binary that speaks MCP over stdio and talks to mainnet IC + production Internet Identity — not a local dfx replica. It drops the entire OAuth 2.1 authorization-server layer (the local client is co-located, so the stdio process boundary replaces bearer-token auth) while keeping Internet Identity: login runs as a built-in browser handshake and per-app account delegations work as today. Adds a verified dependency-stripping analysis (four unreferenced crates plus a vestigial schemars drop; rmcp swaps to the stdio transport and drops auth), the auth.rs OAuth-drop/II-connect-keep partition, the tool/session singleton seam, a 3-crate workspace layout, the security model, and the production-II verification risks. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Keep the crate named imcp2 in the layout The shared library crate stays imcp2 (its existing embeddable identity) and the hosted binary stays named imcp2, so the Dockerfile, systemd unit, and deploy scripts that build/run an imcp2 binary are unchanged. The hosted server + OAuth layer move behind a default-on `hosted` feature (optional axum/tower-http); the new minimal stdio binary is a separate imcp2-local crate depending on imcp2 with default-features off, so it never compiles the OAuth/HTTP deps. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Add "Working with AI tool clients" section Cover how imcp2-local integrates with Claude (Desktop/Code + the cloud surfaces), Codex, Cursor, Perplexity, and Antigravity, verified against each client's current MCP docs. Key findings: a stdio server is reachable only by clients that spawn a local subprocess (Claude Desktop/Code, Codex CLI/IDE/desktop, Cursor, Antigravity, and the Perplexity macOS app via its PerplexityXPC helper); cloud/remote-only surfaces (claude.ai web/mobile, Perplexity web/Windows, Codex Cloud) can't reach localhost and need the hosted imcp2 server — the reason the OAuth layer stays in imcp2. Host-driven OAuth never applies to stdio, and stderr is invisible in chat on every client, so the II login URL is surfaced in-band via an authenticate tool (lazy, non-blocking) plus a best-effort browser auto-open. Adds a capability matrix, per-client registration snippets, the login invariants, and the Perplexity remote OAuth/discovery caveats; updates the login section and open decisions to match. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Update the scoping doc for the 63-commit rebase onto v0.2.0 Re-verify every claim and file:line reference against the rebased tree and absorb what main already did or changed: - The five vestigial deps (ed25519-dalek, p256, ic-signature-verification, ic-representation-independent-hash, schemars 0.8) were already removed on main (#100) — reframe that stripping work as done. - Account for the new hosted-only surfaces the local split must gate: prometheus + src/metrics.rs (/metrics, #124) and McpConfig's state_dir/require_resource (#144/#127); note the local binary needs no state directory at all. pocket-ic (e2e-only, #76) never enters any closure. - Rewrite §10: production II now serves at /mcp by default (#92), CI probes it (#113), and the PocketIC e2e harness verifies the full connect contract — the remaining unknowns are the local binary's http://127.0.0.1 mixed-content and CORS behavior, and the harness is the plan for testing the local flow. - Prod-instance env overrides are II_URL_PROD/II_CANISTER_ID_PROD (#92); registration chains are also verified client-side against the agent's root key (new_with_root_key); registration_pubkey_b64 is now fallible; AuthStore's dropped fields now include mcp_path and require_resource, and the dropped OAuth side grew RFC 8707/9207 and the bounded DCR store. - Note the crates.io publishing dimension (v0.2.0, tag-guarded trusted publishing, docs/ excluded from the .crate) and re-stamp every stale file:line reference (auth.rs shifted ~500-650 lines; the 13 call-site list and all evidence-index anchors updated). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Restructure the design doc to the standard feature-doc shape Reorganize into Summary -> Problem -> Non-goals -> Approach -> Design components -> Implementation Stages (with the verification plan and open decisions under the stages, and the code-evidence index as an appendix). Content is unchanged apart from the connective text: the same components, client matrix, security model, and file:line evidence, now in the house design-doc structure. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Add a concise high-level companion to the local-deployment design docs/local-deployment.md is the short, stakeholder-facing overview (same Summary -> Problem -> Non-goals -> Approach -> Design components -> Implementation Stages shape, one altitude up: no file:line evidence or dependency minutiae); the full doc keeps the detail and both docs cross-link. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Refer to ICP CLI-spawned local replicas, not dfx Local replicas are spawned by the ICP CLI now; drop the dfx naming from both design docs' non-goals. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Make the local-replica mode a test configuration, not a non-goal Talking to an ICP CLI-spawned local replica is a nice-to-have rather than something we rule out: a test build enables it with an explicit IC-endpoint override plus a loopback-guarded fetch_root_key, and the integration tests run imcp2-local in exactly that configuration (against an ICP CLI-spawned replica or PocketIC carrying a deployed II canister). Chains are already verified against the injected agent's root key, so the flow works on a test network. The shipped binary still targets mainnet + production II only. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * State the no-listening-socket claim precisely "The server has no listening socket" overclaimed: it is true of the MCP tool surface (stdio), but the login handshake necessarily binds a transient loopback listener — II navigates the browser to the callback and fetches the #4091 well-known from the callback's origin, both of which require a real HTTP origin (a custom URI scheme has no origin and II offers no device-grant alternative; this is the RFC 8252 loopback redirect). Scope the trust-boundary claim to the tool surface, note that reaching the login listener confers nothing (static pages; /redeem is state-correlated and only accepts a chain targeting the in-process X), and add the rationale to the login component. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Recommend an imcp2-core crate over the hosted feature flag Make the shared components a new imcp2-core library that both binaries build on: imcp2 (unchanged name, lib + hosted binary, OAuth AS, routers, metrics, e2e harness) and imcp2-local depend on it, and imcp2 re-exports core's public items so existing embedders keep compiling. The default-on `hosted` cargo feature is demoted to a rejected alternative: features unify additively, so any crate enabling imcp2/hosted would switch the OAuth/axum closure on for the whole build graph, leaving the minimal-closure claim invocation-dependent; it also needs cfg gates scattered through the code, where the crate boundary states the component split structurally — with the core split the session seam needs no #[cfg] at all (AuthedSession lives in core and the Bearer arm reads http::request::Parts). Cost accepted: imcp2-core becomes a second published crate (family-internal, 0.x, published before imcp2). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Make the session-handling component self-contained in the overview The overview's "session seam" bullet leaned on the full doc's jargon (seam, bearer-token lookup, singleton). State the motivation instead: every tool call acts as the user's II session, the hosted server resolves it per request from the OAuth bearer token, the single-user local server reads the one in-memory session from login, and the tool implementations are identical in both. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Make the design docs self-contained State the final design plainly instead of narrating how it evolved: drop the rejected-alternative paragraphs and every contrast with superseded drafts ("not a cargo feature", "originally proposed", "since this design's first draft", "the original concern is resolved"), recast the dependency profile per crate as final state, and remove the settled layout item from the open decisions. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Drop the local-replica bullet from Non-goals The local-replica test configuration is covered where it belongs (the II wiring component and the verification plan), and the mainnet + production II targeting is already stated in the Approach, so the non-goal bullet added nothing but a hedge. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Resolve the login-flow choices like the ICP CLI; add end-user setup UX The login listener is axum and the browser opens via open::that, matching the ICP CLI's web-identity flow (icp identity link web: an axum Router on 127.0.0.1:0 with graceful shutdown; open = "5"), so the two tools behave the same way. Session persistence stays in-memory. With all three choices settled, the open-decisions sections are gone. Add component 9, end-user setup (UX): per-client steps with no JSON or config editing — the double-click .mcpb bundle for Claude Desktop, an Add-to-Cursor install link, one pasted command for Claude Code and Codex, connector UIs for Perplexity (macOS) and Antigravity, an `imcp2-local setup` command that detects installed clients and writes their configs, and the signing/notarization packaging that makes double-click installs work. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Add the upgrade story to the end-user setup UX Client registrations point at a stable install path, so an upgrade is an in-place binary swap picked up on the next server start — nothing to re-register and no state to migrate (sessions are in-memory). Distribution and updates follow the ICP CLI: cargo-dist installers with the axoupdater updater shipped alongside, and channel detection that surfaces the right upgrade command (axoupdater receipt / Homebrew / npm). The Claude Desktop bundle upgrades on its own channel by installing the new .mcpb version. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Add signing and provenance to the end-user setup component Two layers for two verifiers. OS execution gates: macOS Developer ID + notarization (Gatekeeper is the verifier for browser-downloaded files — including binaries spawned as MCP subprocesses — and accepts only Apple-issued signatures; a bare signed+notarized binary passes, no installer artifact needed) and Windows Authenticode via Azure Trusted Signing or an EV cert. Supply-chain provenance: keyless GitHub artifact attestations on every artifact, verifiable with gh attestation verify. The .mcpb's substance is the signed binary inside (the format specifies no bundle-level signing), with directory listing as the trusted distribution path. Notes which channels bypass the gates (installer script, Homebrew, npm), where the steps hook into the cargo-dist pipeline, and what DFINITY must acquire with lead time. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Promote signing and provenance to its own design component Give the signing content top-level visibility as component 10 instead of a block inside the end-user setup component, and mirror it in the overview's component list. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Commit to PocketIC as the integration-test dependency Integration tests run imcp2-local's local-replica test configuration against PocketIC carrying a deployed II canister (the pocket-ic dev dependency, reusing the e2e harness's real-II setup). The endpoint override still lets a developer point a test build at any other local replica, but the test plan names one vehicle. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * Reconcile the dependency and AuthStore claims with the axum decision The login-listener decision (axum, matching the ICP CLI) left three stale claims behind: imcp2-local does depend on axum for its three transient login routes, so say so in the crate-layout bullet, the net dependency list, and the overview, scoping the absence claim to tower-http/prometheus/OAuth and the hosted MCP transport. Also state the AuthStore reality under the crate split: it stays intact in imcp2 (the retained OAuth routes need all of its state), the extracted primitives carry none of it, and the local binary replaces it with a minimal pending-connect state rather than a slimmed copy. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * docs: address second review round on the local-deployment design - Component 6: rmcp's #[tool_router] is type-level per impl block, so construction mode alone cannot hide tools. Specify that the local-only authenticate/auth_status tools live in their own router that only the local binary composes, with a hosted-side tools/list exclusion test. - Component 7: the Singleton session source holds a shared, replaceable slot rather than a fixed String — the II contract requires a fresh session key after Unauthorized, so re-login must be a same-process step with no client restart. - Sessions wording (both docs): replace the misleading "re-login per run" with the actual lifetime — sign in again after a restart, on grant expiry, or on revocation; note the one-hour grant requested today and the user's consent-time choice of effective TTL. - Verification: PocketIC exercises the protocol, not browser policy, so add a real-browser compatibility gate (automated Chromium/Firefox login run plus a manual Safari/enterprise-policy pass) to Stage 2's login exit criterion. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * docs: address third review round on the local-deployment design - Component 6: the login tools cannot be an impl block in imcp2-core — they drive the loopback listener and browser opener, which live in imcp2-local, and core cannot call back into its dependent crate. They now live on a small wrapper handler in imcp2-local that merges tools/list and dispatches tools/call to its own router before forwarding to the inner IcTools handler (RequestContext<RoleServer> is handler-independent). Hosted stays login-free by construction, with the tools/list test kept as a regression guard. - Component 1: the crate split is not visibility-neutral — workspace packages share no crate-private access, so the composition API (IcTools/IcTools::new with SessionSource, the Identities registration/redeem entry points, the iiconnect builders) graduates from pub(crate) to core's deliberate public API, re-exported by imcp2; dropped the "kept verbatim" phrasing. - Component 4/5: dropping the redeem's redirect tail breaks the callback page's only success arm (it treats a JSON redirect as success, error otherwise). Specify the second success arm: the local redeem answers {"done": true} and the shared page renders "Signed in — you can close this tab" in place; hosted keeps answering redirect. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK * docs: address fourth review round on the local-deployment design - Dependency isolation: distinguish direct dependencies and linked code from unavoidable transitives. prometheus and the OAuth modules are structurally absent from imcp2-local's graph (it never depends on imcp2), but tower-http still appears deep in the graph as an rmcp/reqwest internal — the guarantee is that the hosted CORS layer is not a dependency, not that the crate name vanishes. Scope the Stage 1 exit criterion the same way. - Versioning: an "internal" 0.x label on imcp2-core cannot exempt items imcp2 re-exports — those are imcp2 public API and breaking them is a breaking change for imcp2 embedders under imcp2's own semver. State that the label relaxes stability only for core-only surface, with the re-export set curated to the pre-split imcp2 API. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AqNkpMQiQHzYxC2djTfvBK --------- Co-authored-by: Claude <[email protected]>
What
Enforce the RFC 8707 Resource Indicator at both OAuth legs, so an access token is only ever issued for this instance's own MCP resource.
The MCP authorization spec requires the authorization server to bind a token to the resource the client requested. Today
resourceis parsed at/oauth/authorizebut unused (#[allow(dead_code)]), and/oauth/tokendoesn't parse it at all — so the audience a client asks for has no effect on the token it receives.Change
/oauth/authorizeand/oauth/tokennow refuse aresourcethat doesn't name this instance's issuer ({public_url}{mcp_path}), returninginvalid_target.:443, one trailing slash all tolerated; a fragment or a sibling instance's path —/mcpvs/mcp-beta— is not).resourceis still accepted, for clients predating RFC 8707. This keeps existing MCP clients working; tightening to reject a missing value is a possible follow-up once client behaviour is known.AuthzPending/CodeGrant/TokenInfo. The token-leg check runs before the code is consumed, so a spurious request can't burn a valid pending code.Notes
resource, every issued token already corresponds to this instance, so a gate-side check would be tautological. Worth revisiting only if multi-audience tokens are ever introduced.Tests
resource_matches_issuer_accepts_only_this_instance— canonical + trivial-variance accepted; foreign host, sibling path, non-default port, fragment, scheme downgrade, unparseable all refused.authorize_rejects_foreign_resource_indicator—/oauth/authorizerefuses a foreign resource (invalid_target); canonical / trailing-slash / absent still redirect to II.token_endpoint_enforces_resource_indicator—/oauth/tokenrefuses a foreign resource (and doesn't consume the code); canonical mints a token accepted by the protected/mcp; absent still works.Full suite green (169 tests), no new clippy warnings.