Skip to content

Commit db73bd1

Browse files
committed
fix(shemars): use JSON Schema 2020-12 as Default Dialect
1 parent 1d38d68 commit db73bd1

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "mai
2828
Basic dependencies:
2929
- [tokio required](https://github.com/tokio-rs/tokio)
3030
- [serde required](https://github.com/serde-rs/serde)
31-
31+
Json Schema generation(Must follow the 2020-12 verison):
32+
- [shemars required](https://github.com/GREsau/schemars)
3233

3334

3435
### Build a Client

crates/rmcp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ schemars = ["dep:schemars"]
143143

144144
[dev-dependencies]
145145
tokio = { version = "1", features = ["full"] }
146-
schemars = { version = "1.0", features = ["chrono04"] }
146+
schemars = { version = "1.1.0", features = ["chrono04"] }
147147

148148
anyhow = "1.0"
149149
tracing-subscriber = { version = "0.3", features = [

crates/rmcp/src/handler/server/common.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ use crate::{
1111
/// A shortcut for generating a JSON schema for a type.
1212
pub fn schema_for_type<T: JsonSchema>() -> JsonObject {
1313
// explicitly to align json schema version to official specifications.
14-
// https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2025-03-26/schema.json
15-
// TODO: update to 2020-12 waiting for the mcp spec update
16-
let mut settings = SchemaSettings::draft07();
17-
settings.transforms = vec![Box::new(schemars::transform::AddNullable::default())];
14+
// refer to https://github.com/modelcontextprotocol/modelcontextprotocol/pull/655 for details.
15+
let settings = SchemaSettings::draft2020_12();
1816
let generator = settings.into_generator();
1917
let schema = generator.into_root_schema_for::<T>();
2018
let object = serde_json::to_value(schema).expect("failed to serialize schema");

0 commit comments

Comments
 (0)