-
Notifications
You must be signed in to change notification settings - Fork 274
feat: Add MCP Elicitation support #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adds comprehensive elicitation functionality according to MCP 2025-06-18 specification: Core Features: - ElicitationAction enum (Accept, Decline, Cancel) - CreateElicitationRequestParam and CreateElicitationResult structures - Protocol version V_2025_06_18 with elicitation methods - Full JSON-RPC integration with method constants Capabilities Integration: - ElicitationCapability with schema validation support - ClientCapabilities builder pattern integration - enable_elicitation() and enable_elicitation_schema_validation() methods Handler Support: - create_elicitation method in ClientHandler and ServerHandler traits - Integration with existing request/response union types - Async/await compatible implementation Service Layer: - Basic create_elicitation method via macro expansion - Four convenience methods for common scenarios: * elicit_confirmation() - yes/no questions * elicit_text_input() - string input with optional requirements * elicit_choice() - selection from multiple options * elicit_structured_input() - complex data via JSON Schema Comprehensive Testing: - 11 test cases covering all functionality aspects - JSON serialization/deserialization validation - MCP specification compliance verification - Error handling and edge cases - Performance benchmarks - Capabilities integration tests All tests pass and code follows project standards.
- Add new 'elicitation' feature that depends on 'client' and 'schemars' - Implement elicit<T>() method for type-safe elicitation with automatic schema generation - Remove convenience methods (elicit_confirmation, elicit_text_input, elicit_choice) - Add ElicitationError enum with detailed error variants: - Service: underlying service errors - UserDeclined: user cancelled or declined request - ParseError: response parsing failed with context - NoContent: no response content provided - Update documentation with comprehensive examples and error handling - Add comprehensive tests for typed elicitation and error handling
- Remove CreateElicitationRequest from ClientRequest - clients cannot initiate elicitation - Move elicit methods from client to server - servers now request user input - Add comprehensive direction tests verifying Server→Client→Server flow - Maintain CreateElicitationResult in ClientResult for proper responses - Update handlers to reflect correct message routing - Add elicitation feature flag for typed schema generation Fixes elicitation direction to match specification where servers request interactive user input from clients, not the reverse.
- Add supports_elicitation() method to check client capabilities - Add CapabilityNotSupported error variant to ElicitationError - Update elicit_structured_input() to check capabilities before execution - Update elicit<T>() method to check capabilities before execution - Add comprehensive tests for capability checking functionality - Tests verify that servers check client capabilities before sending elicitation requests - Ensures compliance with MCP 2025-06-18 specification requirement
…RoleServer - Move elicitation methods (supports_elicitation, elicit_structured_input, elicit) to separate impl block - Move ElicitationError definition to elicitation methods section - Keep base methods (create_message, list_roots, notify_*) in main impl block with macro - Add section comments to distinguish general and elicitation-specific methods
I think we might want to consider implementing different request options (including timeouts) depending on the request type. For elicitation calls, they could potentially require longer timeouts and would benefit from being configurable. |
pub const V_2025_03_26: Self = Self(Cow::Borrowed("2025-03-26")); | ||
pub const V_2024_11_05: Self = Self(Cow::Borrowed("2024-11-05")); | ||
pub const LATEST: Self = Self::V_2025_03_26; | ||
pub const LATEST: Self = Self::V_2025_06_18; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change it to 20250618 now, since we haven't implment all the new features
Sorry for late response, it looks good to me. |
This PR implements comprehensive MCP Elicitation support according to the MCP 2025-06-18 specification, enabling servers to request interactive user input during tool execution with full JSON Schema validation and type-safe convenience methods.
Closes #304
Motivation and Context
Elicitation functionality introduced in the MCP 2025-06-18 specification. This allows servers to create interactive workflows that require user input during tool execution.
Solution: This change adds complete elicitation support, enabling:
Context: Based on MCP PR #382 which introduced elicitation to the MCP specification. This implementation ensures rust-sdk maintains full feature parity with the latest MCP standards.
How Has This Been Tested?
Comprehensive Test Suite (11 test cases):
Quality Assurance:
cargo check
- No compilation errorscargo clippy
- No linting warningscargo test
- All 11 elicitation tests passcargo fmt
- Code properly formattedScenarios Tested:
Breaking Changes
No breaking changes - This is a purely additive implementation:
Types of changes
Checklist
Additional context
Implementation Highlights:
Core Architecture:
Accept
,Decline
,Cancel
actionsCreateElicitationRequestParam
,CreateElicitationResult
Developer Experience:
elicit_structured_input()
- Complex JSON Schema validationelicit<T>()
- Typed data request with JSON auto generationCapabilities System:
enable_elicitation()
,enable_elicitation_schema_validation()
This implementation makes rust-sdk compatible with MCP 2025-06-18 and enables interactive workflows while maintaining full backward compatibility.