Uh oh!
There was an error while loading. Please reload this page.
feat: add type-safe elicitation schema support (#465) - #466
Conversation
bug-ops
left a comment
There was a problem hiding this comment.
Hi @ByteBaker, some adjustments need to be made to comply with the MCP specifications.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ByteBaker
commented
Oct 4, 2025
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.
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
) 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 Fixesmodelcontextprotocol#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.
ByteBaker
commented
Oct 13, 2025
@4t145 done. Please review. |
4t145
commented
Oct 14, 2025
@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.
Hi @ByteBaker@4t145 , sorry for long reply. I added a small suggestion, the rest LGTM
Uh oh!
There was an error while loading. Please reload this page.
ByteBaker
commented
Oct 14, 2025
Uh oh!
There was an error while loading. Please reload this page.
4t145
commented
Oct 15, 2025
Thanks for your patience! |
) (modelcontextprotocol#466) * feat: add type-safe elicitation schema support (modelcontextprotocol#465) 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 Fixesmodelcontextprotocol#465 * fix: fix RMCP compliance * feat: add conversion methods to ElicitationSchema 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. * chore: change `StringFormat` to enum
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