fix(rmcp): preserve elicitation requestedSchema $schema dialect - #1176
Open
latent-9 wants to merge 1 commit into
Open
fix(rmcp): preserve elicitation requestedSchema $schema dialect#1176latent-9 wants to merge 1 commit into
latent-9 wants to merge 1 commit into
Conversation
ElicitationSchema round-trips through ElicitationSchemaWire, which had no field for the top-level `$schema` keyword. A dialect declared on an incoming requestedSchema (allowed since protocol revision 2025-11-25) was therefore accepted but silently dropped on re-serialization. Add a `schema` field to both the public struct and the wire bridge, thread it through the two `From` conversions, and expose a `with_schema` setter. The field is `skip_serializing_if = "Option::is_none"`, so schemas without a dialect serialize unchanged. Refs modelcontextprotocol#1168
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ElicitationSchema(de)serializes through an internalElicitationSchemaWirebridge. The bridge had no field for the top-level
$schemakeyword, so adialect declared on an incoming
requestedSchemawas accepted but silentlydropped when the schema was re-serialized.
The 2025-11-25 protocol revision allows a
requestedSchemato carry a$schemadialect identifier, andElicitationSchema::from_typealready emitsone (schemars draft-07), so the value was being lost on any round-trip.
Change
schema: Option<Cow<'static, str>>field (serderename = "$schema")to both
ElicitationSchemaand theElicitationSchemaWirebridge.Fromconversions.with_schemasetter, matching the existingwith_titleandwith_descriptionbuilders. The struct is#[non_exhaustive], so anexternal caller needs a setter to populate the field.
The field uses
skip_serializing_if = "Option::is_none", so a schema without adialect serializes exactly as before. Adding a field to a
#[non_exhaustive]struct is semver compatible.
Tests
Three unit tests in
elicitation_schema.rs:$schemavalue survives a deserialize then serialize round-trip,$schemakey,with_schemasetter serializes the dialect.Scope
This handles the
$schemahalf of #1168. The other half (preserving unknownproperty-level keywords) needs a data-model decision on where arbitrary
keywords should live, so I left it out of this change and kept the issue open
for it.
Refs #1168