Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "mai
Basic dependencies:
- [tokio required](https://github.com/tokio-rs/tokio)
- [serde required](https://github.com/serde-rs/serde)

Json Schema generation(Must follow the 2020-12 version):
- [shemars required](https://github.com/GREsau/schemars)
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Typo in "shemars" - should be "schemars".

Suggested change
- [shemars required](https://github.com/GREsau/schemars)
- [schemars required](https://github.com/GREsau/schemars)

Copilot uses AI. Check for mistakes.


### Build a Client
Expand Down
2 changes: 1 addition & 1 deletion crates/rmcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ schemars = ["dep:schemars"]

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
schemars = { version = "1.0", features = ["chrono04"] }
schemars = { version = "1.1.0", features = ["chrono04"] }
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

The dev-dependency for schemars is being updated to version 1.1.0, but the main dependency at line 32 remains at version 1.0. This creates a version mismatch that could lead to compilation issues or unexpected behavior. Since draft2020_12() requires schemars 1.1.0+, the main dependency should also be updated to match.

Consider updating the main dependency to:

schemars = { version = "1.1.0", optional = true, features = ["chrono04"] }

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

@jokemanfire Looks like something to look at if we need the bump across the board?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Trace it in #182 , there should still be some work to be done here, and we may introduce some broken change.


anyhow = "1.0"
tracing-subscriber = { version = "0.3", features = [
Expand Down
5 changes: 2 additions & 3 deletions crates/rmcp/src/handler/server/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ use crate::{
/// A shortcut for generating a JSON schema for a type.
pub fn schema_for_type<T: JsonSchema>() -> JsonObject {
// explicitly to align json schema version to official specifications.
// https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2025-03-26/schema.json
// TODO: update to 2020-12 waiting for the mcp spec update
let mut settings = SchemaSettings::draft07();
// refer to https://github.com/modelcontextprotocol/modelcontextprotocol/pull/655 for details.
let mut settings = SchemaSettings::draft2020_12();
settings.transforms = vec![Box::new(schemars::transform::AddNullable::default())];
let generator = settings.into_generator();
let schema = generator.into_root_schema_for::<T>();
Expand Down
68 changes: 52 additions & 16 deletions crates/rmcp/tests/test_complex_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,60 @@ impl Demo {
}
}

fn expected_schema() -> serde_json::Value {
serde_json::json!({
"$defs": {
"ChatMessage": {
"properties": {
"content": {
"type": "string"
},
"role": {
"$ref": "#/$defs/ChatRole"
}
},
"required": [
"role",
"content"
],
"type": "object"
},
"ChatRole": {
"enum": [
"System",
"User",
"Assistant",
"Tool"
],
"type": "string"
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"messages": {
"items": {
"$ref": "#/$defs/ChatMessage"
},
"type": "array"
},
"system": {
"nullable": true,
"type": "string"
}
},
"required": [
"messages"
],
"title": "ChatRequest",
"type": "object"
})
}

#[test]
fn test_complex_schema() {
let attr = Demo::chat_tool_attr();
let input_schema = attr.input_schema;
let enum_number = input_schema
.get("definitions")
.unwrap()
.as_object()
.unwrap()
.get("ChatRole")
.unwrap()
.as_object()
.unwrap()
.get("enum")
.unwrap()
.as_array()
.unwrap()
.len();
assert_eq!(enum_number, 4);
println!("{}", serde_json::to_string_pretty(&input_schema).unwrap());
let expected = expected_schema();
let produced = serde_json::Value::Object(input_schema.as_ref().clone());
assert_eq!(produced, expected, "schema mismatch");
}