Skip to content

feat: interactive elicitation (MRTR + legacy) and OAuth 2026-07-28 hardening - #256

Merged
steipete merged 3 commits into
mainfrom
steipete/mcp2-mrtr-auth
Aug 2, 2026
Merged

feat: interactive elicitation (MRTR + legacy) and OAuth 2026-07-28 hardening#256
steipete merged 3 commits into
mainfrom
steipete/mcp2-mrtr-auth

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Completes the two capability gaps left after the SDK v2 migration (#255):

Elicitation / MRTR interactive input

  • One handler serves both protocol eras: legacy server-initiated elicitation/create and the 2026-07-28 MRTR input_required auto-fulfilment path.
  • Interactive TTY responder prompts per-field from the requested schema (form mode) and prints the URL prominently for URL mode; clean decline on Ctrl-C/EOF.
  • Non-interactive contexts (pipes, CI, daemon, replay) decline immediately with an actionable hint instead of hanging. The serve bridge declines with a log (faithful passthrough across pooled upstream clients is a documented follow-up).
  • Library API: createRuntime accepts an elicitationHandler override for programmatic use.

OAuth hardening (2026-07-28 authorization requirements)

  • RFC 9207: the loopback callback captures iss and validates it via the SDK before the code is redeemed; mismatches abort with expected-vs-received issuer named.
  • Credentials are issuer-bound: mismatched stored credentials are discarded instead of cross-reused; legacy unstamped records stay usable and are stamped on next save (no forced re-auth).
  • Discovery state persists through directory/vault schema v2 (v1 records readable).
  • CIMD: new oauthClientMetadataUrl per-server config exposes a URL-based client identity where supported (SDK falls back to DCR). Verified the SDK already derives application_type: native for loopback redirects.

Proof: pnpm check clean; 927 passed / 3 skipped; autoreview clean (0.98) incl. TruffleHog. Part 3 of the MCP 2.0 series (#254, #255). Next: committed dual-era fixture servers + e2e.

🤖 Generated with Claude Code

@steipete
steipete merged commit c42bd76 into main Aug 2, 2026
5 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71b374ad4f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/runtime/oauth.ts
serverName?: string
): Promise<void> {
try {
await transport.finishAuth?.(response.code, response.iss);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Forward callback issuer through recording transport

When MCPORTER_RECORD is set, HTTP transports are wrapped in RecordTransport, whose finishAuth forwarder still accepts only authorizationCode and calls the inner transport with one argument. This new call therefore loses response.iss before it reaches the SDK in recorded OAuth flows, so 2026-07-28 callback issuer validation either fails as missing or is skipped depending on the transport; forward the second argument through the recorder.

Useful? React with 👍 / 👎.

Comment thread src/oauth.ts
this.redirectUrlValue = redirectUrl;
this.logger = logger;
this.persistence = persistence;
validateClientMetadataUrl(definition.oauthClientMetadataUrl);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Close the callback server on metadata URL validation failure

At this point create() has already bound the callback server with server.listen(...); if a user configures a malformed oauthClientMetadataUrl, this validation throws out of the constructor and the already-listening callback server is never closed, leaving a live handle/port after createOAuthSession rejects. Move this validation before binding or close the server on constructor failure.

Useful? React with 👍 / 👎.

Comment on lines +166 to +169
const invalid = values.find((value) => !choices.includes(value));
return invalid
? { ok: false, message: `Choose comma-separated values from: ${choices.join(', ')}.` }
: { ok: true, value: values };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce multi-select min/max item bounds

For multi-select elicitation schemas that declare minItems or maxItems, this branch accepts whatever number of comma-separated values survived filtering as long as each choice is valid. A user can submit zero selections to a minItems: 1 prompt (for example by typing only commas) or too many selections for maxItems, and the server receives content that violates its requested schema instead of being re-prompted.

Useful? React with 👍 / 👎.

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