-
Notifications
You must be signed in to change notification settings - Fork 401
feat: add type-safe elicitation schema support (#465) #466
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
Conversation
bug-ops
left a comment
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.
Hi @ByteBaker, some adjustments need to be made to comply with the MCP specifications.
|
Hi @bug-ops, I had missed out on several points. Thanks for catching them. I've made a commit addressing the issues. I hope I've resolved them all this time around. |
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.
Pull Request Overview
This PR implements type-safe schema definitions for MCP elicitation requests, replacing the generic JsonObject type with strongly-typed primitive schemas that enforce the MCP 2025-06-18 specification requirements.
Key changes:
- Introduces type-safe schema hierarchy with primitive schema types (
StringSchema,NumberSchema,IntegerSchema,BooleanSchema,EnumSchema) - Implements fluent builder pattern with 20+ convenience methods for schema construction
- Adds build-time validation ensuring required fields exist in properties
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/servers/src/elicitation_stdio.rs | Adds a new GreetingMessage struct for demonstration |
| crates/rmcp/tests/test_message_schema/*.json | Updates JSON schema definitions to include new primitive schema types |
| crates/rmcp/tests/test_elicitation.rs | Refactors tests to use new type-safe schema API instead of raw JSON objects |
| crates/rmcp/src/service/server.rs | Updates server implementation to convert JsonObject to ElicitationSchema |
| crates/rmcp/src/model/elicitation_schema.rs | New comprehensive implementation of type-safe elicitation schemas |
| crates/rmcp/src/model.rs | Integrates the new elicitation schema module and updates CreateElicitationRequestParam |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
) Implement type-safe schema definitions for MCP elicitation requests, replacing generic `JsonObject` with strongly-typed primitive schemas per the [MCP 2025-06-18 specification](https://spec.modelcontextprotocol.io/specification/2025-06-18/server/elicitation/). Features: - Type-safe schema hierarchy (`StringSchema`, `NumberSchema`, `IntegerSchema`, `BooleanSchema`) - Builder pattern with fluent API and 20+ convenience methods - Build-time validation ensuring required fields exist in properties - Private fields enforcing invariants through validated constructors - Comprehensive validation support (range, length, format, enums) - Typed property methods for cleaner schema construction Benefits: - Compile-time type safety prevents invalid schema construction - 60-70% reduction in boilerplate through convenience methods - Enforces MCP specification requirement for primitive-only properties - Better IDE autocomplete and type inference - Runtime validation catches schema errors early Breaking changes: - `CreateElicitationRequestParam.requested_schema` changed from `JsonObject` to `ElicitationSchema` - `ElicitationSchemaBuilder::build()` now returns `Result` instead of direct value Fixes modelcontextprotocol#465
Add from_json_schema() and from_type() methods to ElicitationSchema for easier type-to-schema conversion. This addresses feedback about improving ergonomics when working with generated schemas. Also make all struct fields public for better flexibility.
|
@4t145 done. Please review. |
|
@ByteBaker It looks good to me now. Should I just merge this or wait for some review from @bug-ops? |
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.
Hi @ByteBaker @4t145 , sorry for long reply. I added a small suggestion, the rest LGTM
bug-ops
left a comment
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.
LGTM
|
Thanks for your patience! |
Implement type-safe schema definitions for MCP elicitation requests, replacing generic
JsonObjectwith strongly-typed primitive schemas per the MCP 2025-06-18 specification.Features:
StringSchema,NumberSchema,IntegerSchema,BooleanSchema)Benefits:
Fixes #465
Motivation and Context
How Has This Been Tested?
Comprehensive tests have been added and verified to be passing.
Breaking Changes
CreateElicitationRequestParam.requested_schemachanged fromJsonObjecttoElicitationSchemaElicitationSchemaBuilder::build()now returnsResultinstead of direct valueTypes of changes
Checklist
Additional context