Skip to content

Conversation

@cbcoutinho
Copy link
Contributor

@cbcoutinho cbcoutinho commented Nov 5, 2025

Summary

This PR implements SEP-1036 (URL mode elicitation) as specified in modelcontextprotocol/specification#887, adding support for secure out-of-band interactions that bypass the MCP client.

Note

SEP 1036 is currently Pending, so this feature should be considered experimental

Key Changes

Type System (src/mcp/types.py):

  • Added ELICITATION_REQUIRED error code (-32000)
  • Updated ElicitationCapability to support both form and url modes
  • Added ElicitTrackRequest and ElicitTrackResult for progress tracking
  • Added UrlElicitationInfo and ElicitationRequiredErrorData types
  • Enhanced ElicitRequestParams with mode field and URL mode parameters

Server Implementation (src/mcp/server/):

  • Added elicit_url() helper function for URL mode elicitation
  • Added elicit_form() and elicit_url() methods to ServerSession
  • Maintained backward compatibility with existing elicit() method

Client Implementation (src/mcp/client/session.py):

  • Updated capability negotiation to declare form and URL mode support
  • Added track_elicitation() method for monitoring URL mode progress

Tests (tests/server/fastmcp/test_url_elicitation.py):

  • Comprehensive test coverage for URL mode elicitation
  • Tests for accept, decline, and cancel actions
  • Verification of backward compatibility with form mode
  • All 311 existing tests continue to pass

Use Cases Enabled

This implementation enables servers to:

  • Direct users to OAuth authorization flows with third-party services
  • Collect sensitive credentials (API keys, passwords) securely
  • Handle payment and subscription flows
  • Manage any sensitive interaction requiring out-of-band processing

Breaking Changes

  • ElicitRequestParams now requires a mode field ("form" or "url")
  • Clients must declare which elicitation modes they support during initialization

Testing

  • ✅ 6 new URL elicitation tests pass
  • ✅ 5 existing elicitation tests pass
  • ✅ All 311 server and client tests pass
  • ✅ Type checking passes (pyright)
  • ✅ Linting passes (ruff)

Related

cbcoutinho and others added 5 commits November 5, 2025 15:39
…actions

This commit adds support for URL mode elicitation as specified in SEP-1036,
enabling servers to direct users to external URLs for sensitive interactions
that must not pass through the MCP client.

Key changes:

Types (src/mcp/types.py):
- Add ELICITATION_REQUIRED error code (-32000)
- Update ElicitationCapability to support form and url modes
- Add ElicitTrackRequest and ElicitTrackResult for progress tracking
- Add UrlElicitationInfo and ElicitationRequiredErrorData types
- Update ElicitRequestParams with mode field and URL mode parameters

Server (src/mcp/server/):
- Add elicit_url() helper function in elicitation.py
- Add elicit_form() and elicit_url() methods to ServerSession
- Maintain backward compatibility with existing elicit() method

Client (src/mcp/client/session.py):
- Update capability negotiation for form and URL modes
- Add track_elicitation() method for progress monitoring

Tests:
- Comprehensive test coverage for URL mode elicitation
- Verify backward compatibility with form mode
- All 311 existing tests pass

Use cases enabled:
- OAuth authorization flows with third-party services
- Secure credential collection (API keys, passwords)
- Payment and subscription flows
- Any sensitive interaction requiring out-of-band handling

Breaking changes:
- ElicitRequestParams now requires mode field ("form" or "url")
- Clients must declare which elicitation modes they support

Closes: modelcontextprotocol/modelcontextprotocol#887
Remove unnecessary isinstance check for CancelledElicitation since type
narrowing makes it redundant, and remove the unused import.
Add None check for requestedSchema before accessing properties to fix
type narrowing error that was blocking CI.
@maxisbey maxisbey added spec Specification compliance pending SEP approval When a PR is attached as an implementation detail to a SEP, we mark it as such for triage. labels Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending SEP approval When a PR is attached as an implementation detail to a SEP, we mark it as such for triage. spec Specification compliance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants