FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(rmcp): preserve elicitation requestedSchema $schema dialect by latent-9 · Pull Request #1176 · modelcontextprotocol/rust-sdk · GitHub

fix(rmcp): preserve elicitation requestedSchema $schema dialect - #1176

Merged
DaleSeo merged 3 commits into
modelcontextprotocol:mainfrom
latent-9:fix/elicitation-schema-dialect
Aug 18, 2026
Merged

fix(rmcp): preserve elicitation requestedSchema $schema dialect#1176
DaleSeo merged 3 commits into
modelcontextprotocol:mainfrom
latent-9:fix/elicitation-schema-dialect

Conversation

Copy link
Copy Markdown
Contributor

What

ElicitationSchema (de)serializes through an internal ElicitationSchemaWire
bridge. The bridge had no field for the top-level $schema keyword, so a
dialect declared on an incoming requestedSchema was accepted but silently
dropped when the schema was re-serialized.

The 2025-11-25 protocol revision allows a requestedSchema to carry a
$schema dialect identifier, and ElicitationSchema::from_type already emits
one (schemars draft-07), so the value was being lost on any round-trip.

Change

  • Add a schema: Option<Cow<'static, str>> field (serde rename = "$schema")
    to both ElicitationSchema and the ElicitationSchemaWire bridge.
  • Thread it through the two From conversions.
  • Add a with_schema setter, matching the existing with_title and
    with_description builders. The struct is #[non_exhaustive], so an
    external caller needs a setter to populate the field.

The field uses skip_serializing_if = "Option::is_none", so a schema without a
dialect serializes exactly as before. Adding a field to a #[non_exhaustive]
struct is semver compatible.

Tests

Three unit tests in elicitation_schema.rs:

  • a $schema value survives a deserialize then serialize round-trip,
  • a schema without a dialect emits no $schema key,
  • the with_schema setter serializes the dialect.

Scope

This handles the $schema half of #1168. The other half (preserving unknown
property-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

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 #1168
latent-9 requested a review from a team as a code owner August 14, 2026 13:54
github-actions Bot added T-core Core library changes T-model Model/data structure changes T-test Testing related changes T-config Configuration file changes labels Aug 14, 2026
… $schema

The $schema dialect field added to ElicitationSchema changes the
schemars-generated ServerJsonRpcMessage schema. Regenerate the golden
snapshot so test_server_json_rpc_message_schema passes.
latent-9 force-pushed the fix/elicitation-schema-dialect branch from 3d774d8 to 312afb0 Compare August 15, 2026 08:01
DaleSeo previously approved these changes Aug 18, 2026

DaleSeo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for the fix, @latent-9. I have a small suggestion to make the generated schema more precise.

Use schemars(with = "String") on ElicitationSchema::$schema so
schemars generates "type": "string" instead of ["string", "null"].
latent-9 force-pushed the fix/elicitation-schema-dialect branch from bb180d0 to 0dafbd3 Compare August 18, 2026 14:34
DaleSeo merged commit 6f8dcde into modelcontextprotocol:main Aug 18, 2026
22 checks passed
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

Labels

T-config Configuration file changes T-core Core library changes T-model Model/data structure changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Elicitation requestedSchema silently drops $schema and unknown property keywords

2 participants


Back | FazBrowse Home | New Git URL