Skip to content

Commit a5ba501

Browse files
authored
feat!: add support for MCP Schema Version 2025-06-18 (#77)
* feat: supporting new mcp version 2025_06_18 * chore: update test and examples * docs: update readme * chore: fix clippy warnings
1 parent 16451ff commit a5ba501

19 files changed

+12706
-639
lines changed

Cargo.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,29 @@ json5 = { version = "0.4" }
2424

2525

2626
[package.metadata.docs.rs]
27-
features = ["2025_03_26", "schema_utils"]
27+
features = ["2025_06_18", "schema_utils"]
2828
rustdoc-args = ["--generate-link-to-definition"]
2929

3030
[package.metadata.playground]
31-
features = ["2025_03_26", "schema_utils"]
31+
features = ["2025_06_18", "schema_utils"]
3232

3333
### FEATURES #################################################################
3434

3535
# Features to enable different schema versions and associated schema_utils
3636
[features]
3737

38-
# defalt features
39-
default = ["latest", "schema_utils"] # Default features
38+
# default features
39+
default = ["2025_06_18", "schema_utils"] # Default features
4040

4141
# activates the latest MCP schema version, this will be updated once a new version of schema is published
42-
latest = ["2025_03_26"]
42+
latest = ["2025_06_18"]
43+
# enabled mcp schema version 2025_06_18
44+
2025_06_18 = ["latest"]
4345
# enabled mcp schema version 2025_03_26
44-
2025_03_26 = ["latest"]
46+
2025_03_26 = []
4547
# enabled mcp schema version 2024_11_05
4648
2024_11_05 = []
4749
# enabled draft mcp schema
4850
draft = []
49-
# Enables `schema_utils`, which provides utility types that simplify communication with MCP messages, improving ease of use while reducing potential mistakes ane errors when constructing messages.
51+
# Enables `schema_utils`, which provides utility types that simplify communication with MCP messages, improving ease of use while reducing potential mistakes and errors when constructing messages.
5052
schema_utils = []

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/rust-mcp-stack/rust-mcp-schema/ci.yml?style=for-the-badge" height="22">
1010
](https://github.com/rust-mcp-stack/rust-mcp-schema/actions/workflows/ci.yml)
1111

12-
A type-safe Rust implementation of the official Model Context Protocol (MCP) schema, supporting all official released versions including `2024_11_05`, `2025_03_26`, and `draft` version for early adoption.
12+
A type-safe Rust implementation of the official Model Context Protocol (MCP) schema, supporting all official released versions including `2025_06_18`, `2025_03_26`, `2024_11_05` and `draft` version for early adoption.
1313

1414
The MCP schemas in this repository are [automatically generated](#how-are-schemas-generated) from the official Model Context Protocol, ensuring they are always up-to-date and aligned with the latest official specifications.
1515

@@ -46,7 +46,7 @@ Focus on your app's logic while [rust-mcp-sdk](https://crates.io/crates/rust-mcp
4646

4747
- 🧩 Type-safe implementation of the MCP protocol specification.
4848
- 💎 Auto-generated schemas are always synchronized with the official schema specifications.
49-
- 📜 Includes all official released versions : `2024_11_05` and `2025_03_26` and `draft` version for early adoption.
49+
- 📜 Includes all official released versions : `2025_06_18`, `2025_03_26`, `2024_11_05` and `draft` version for early adoption.
5050
- 🛠 Complimentary schema utility module (schema_utils) to boost productivity and ensure development integrity.
5151

5252
## How can this crate be used?
@@ -70,8 +70,9 @@ For more information on the MCP architecture, refer to the [official documentati
7070

7171
This repository provides all official released versions the schema , including draft version, enabling you to prepare and adapt your applications ahead of upcoming official schema releases.
7272

73-
- [2024_11_05](src/generated_schema/2024_11_05)
73+
- [2025_06_18](src/generated_schema/2025_06_18)
7474
- [2025_03_26](src/generated_schema/2025_03_26)
75+
- [2024_11_05](src/generated_schema/2024_11_05)
7576
- [draft](src/generated_schema/draft)
7677

7778
### How to switch between different schema versions?

examples/mcp_client_handle_message.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
#[cfg(feature = "latest")]
2-
use rust_mcp_schema::schema_utils::*;
3-
#[cfg(feature = "latest")]
4-
use rust_mcp_schema::*;
2+
mod schema {
3+
pub use rust_mcp_schema::schema_utils::*;
4+
pub use rust_mcp_schema::*;
5+
}
56

67
#[cfg(feature = "2024_11_05")]
7-
use rust_mcp_schema::mcp_2024_11_05::schema_utils::*;
8-
#[cfg(feature = "2024_11_05")]
9-
use rust_mcp_schema::mcp_2024_11_05::*;
8+
mod schema {
9+
pub use rust_mcp_schema::mcp_2024_11_05::schema_utils::*;
10+
pub use rust_mcp_schema::mcp_2024_11_05::*;
11+
}
12+
13+
#[cfg(feature = "2025_03_26")]
14+
mod schema {
15+
pub use rust_mcp_schema::mcp_2025_03_26::schema_utils::*;
16+
pub use rust_mcp_schema::mcp_2025_03_26::*;
17+
}
1018

1119
#[cfg(feature = "draft")]
12-
use rust_mcp_schema::mcp_draft::schema_utils::*;
13-
#[cfg(feature = "draft")]
14-
use rust_mcp_schema::mcp_draft::*;
20+
mod schema {
21+
pub use rust_mcp_schema::mcp_draft::schema_utils::*;
22+
pub use rust_mcp_schema::mcp_draft::*;
23+
}
24+
25+
use schema::*;
1526

1627
use std::str::FromStr;
1728

@@ -66,6 +77,10 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> {
6677
ServerRequest::ListRootsRequest(list_roots_request) => {
6778
dbg!(list_roots_request);
6879
}
80+
#[cfg(any(feature = "2025_06_18", feature = "draft"))]
81+
ServerRequest::ElicitRequest(elicit_request) => {
82+
dbg!(elicit_request);
83+
}
6984
}
7085
}
7186
// Check if it's a CustomRequest; the value can be deserialized into your own custom types.

examples/mcp_server_handle_message.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
#[cfg(feature = "latest")]
2-
use rust_mcp_schema::schema_utils::*;
3-
#[cfg(feature = "latest")]
4-
use rust_mcp_schema::*;
2+
mod schema {
3+
pub use rust_mcp_schema::schema_utils::*;
4+
pub use rust_mcp_schema::*;
5+
}
56

67
#[cfg(feature = "2024_11_05")]
7-
use rust_mcp_schema::mcp_2024_11_05::schema_utils::*;
8-
#[cfg(feature = "2024_11_05")]
9-
use rust_mcp_schema::mcp_2024_11_05::*;
8+
mod schema {
9+
pub use rust_mcp_schema::mcp_2024_11_05::schema_utils::*;
10+
pub use rust_mcp_schema::mcp_2024_11_05::*;
11+
}
12+
13+
#[cfg(feature = "2025_03_26")]
14+
mod schema {
15+
pub use rust_mcp_schema::mcp_2025_03_26::schema_utils::*;
16+
pub use rust_mcp_schema::mcp_2025_03_26::*;
17+
}
1018

1119
#[cfg(feature = "draft")]
12-
use rust_mcp_schema::mcp_draft::schema_utils::*;
13-
#[cfg(feature = "draft")]
14-
use rust_mcp_schema::mcp_draft::*;
20+
mod schema {
21+
pub use rust_mcp_schema::mcp_draft::schema_utils::*;
22+
pub use rust_mcp_schema::mcp_draft::*;
23+
}
24+
25+
use schema::*;
1526

1627
use std::str::FromStr;
1728

@@ -149,14 +160,16 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> {
149160
ClientResult::Result(_) => {
150161
dbg!(client_result);
151162
}
152-
153163
ClientResult::CreateMessageResult(create_message_result) => {
154164
dbg!(create_message_result);
155165
}
156-
157166
ClientResult::ListRootsResult(list_roots_result) => {
158167
dbg!(list_roots_result);
159168
}
169+
#[cfg(any(feature = "2025_06_18", feature = "draft"))]
170+
ClientResult::ElicitResult(elicit_result) => {
171+
dbg!(elicit_result);
172+
}
160173
},
161174

162175
// Check if it's a CustomResult; the value can be deserialized into your custom types.

scripts/run_clippy.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
22

33
# common features
4-
COMMON_FEATURES=("schema_utils")
4+
COMMON_FEATURES=("schema_utils")
55

66
# schema versions features (passed to clippy one at a time)
7-
SCHEMA_VERSION_FEATURES=("2025_03_26", "2024_11_05", "draft")
7+
SCHEMA_VERSION_FEATURES=("2025_06_18", "2025_03_26", "2024_11_05", "draft")
88

9-
# space-separated string
9+
# space-separated string
1010
COMMON_FEATURES_STR="${COMMON_FEATURES[*]}"
1111

1212
for FEATURE in "${SCHEMA_VERSION_FEATURES[@]}"; do
@@ -20,4 +20,4 @@ for FEATURE in "${SCHEMA_VERSION_FEATURES[@]}"; do
2020
fi
2121
done
2222

23-
echo "✅ All Clippy lints have passed!"
23+
echo "✅ All Clippy lints have passed!"

scripts/run_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
COMMON_FEATURES=("schema_utils")
55

66
# schema versions features (tested one at a time)
7-
SCHEMA_VERSION_FEATURES=("2025_03_26", "2024_11_05", "draft")
7+
SCHEMA_VERSION_FEATURES=("2025_06_18", "2025_03_26", "2024_11_05", "draft")
88

99
# space-separated string
1010
COMMON_FEATURES_STR="${COMMON_FEATURES[*]}"

src/generated_schema.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,19 @@ macro_rules! define_schema_version {
2727
};
2828
}
2929

30-
/// Latest MCP Protocol 2025_03_26
31-
#[cfg(feature = "2025_03_26")]
32-
pub use mcp_2025_03_26::*;
30+
/// Latest MCP Protocol 2025_06_18
31+
#[cfg(feature = "2025_06_18")]
32+
pub use mcp_2025_06_18::*;
33+
34+
#[cfg(feature = "2025_06_18")]
35+
define_schema_version!(
36+
"2025_06_18",
37+
mcp_2025_06_18,
38+
"generated_schema/2025_06_18/mcp_schema.rs",
39+
"generated_schema/2025_06_18/schema_utils.rs",
40+
__int_2025_06_18,
41+
__int_utils_2025_06_18
42+
);
3343

3444
#[cfg(feature = "2025_03_26")]
3545
define_schema_version!(

src/generated_schema/2024_11_05/mcp_schema.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// ----------------------------------------------------------------------------
2-
/// This file is auto-generated by mcp-schema-gen v0.3.0.
2+
/// This file is auto-generated by mcp-schema-gen v0.4.1.
33
/// WARNING:
44
/// It is not recommended to modify this file directly. You are free to
55
/// modify or extend the implementations as needed, but please do so at your own risk.
66
///
77
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
8-
/// Hash : UNKNOWN
9-
/// Generated at : 2025-05-26 21:28:07
8+
/// Hash : 169021c2e1332eb9197a6f47fb6ec30e0a70b1d0
9+
/// Generated at : 2025-06-28 14:42:12
1010
/// ----------------------------------------------------------------------------
1111
///
1212
/// MCP Protocol Version

src/generated_schema/2024_11_05/schema_utils.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::generated_schema::mcp_2024_11_05::*;
2+
23
use serde::ser::SerializeStruct;
34
use serde_json::{json, Value};
45
use std::hash::{Hash, Hasher};
@@ -318,7 +319,7 @@ impl Display for ClientJsonrpcRequest {
318319
write!(
319320
f,
320321
"{}",
321-
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
322+
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
322323
)
323324
}
324325
}
@@ -446,7 +447,7 @@ impl Display for ClientJsonrpcNotification {
446447
write!(
447448
f,
448449
"{}",
449-
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
450+
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
450451
)
451452
}
452453
}
@@ -548,7 +549,7 @@ impl Display for ClientJsonrpcResponse {
548549
write!(
549550
f,
550551
"{}",
551-
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
552+
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
552553
)
553554
}
554555
}
@@ -632,7 +633,7 @@ impl Display for ClientMessage {
632633
write!(
633634
f,
634635
"{}",
635-
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
636+
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
636637
)
637638
}
638639
}
@@ -814,7 +815,7 @@ impl Display for ServerMessage {
814815
write!(
815816
f,
816817
"{}",
817-
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
818+
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
818819
)
819820
}
820821
}
@@ -853,7 +854,7 @@ impl Display for ServerJsonrpcRequest {
853854
write!(
854855
f,
855856
"{}",
856-
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
857+
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
857858
)
858859
}
859860
}
@@ -959,7 +960,7 @@ impl Display for ServerJsonrpcNotification {
959960
write!(
960961
f,
961962
"{}",
962-
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
963+
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
963964
)
964965
}
965966
}
@@ -1052,7 +1053,7 @@ impl Display for ServerJsonrpcResponse {
10521053
write!(
10531054
f,
10541055
"{}",
1055-
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
1056+
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
10561057
)
10571058
}
10581059
}
@@ -1129,7 +1130,7 @@ impl Display for JsonrpcError {
11291130
write!(
11301131
f,
11311132
"{}",
1132-
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
1133+
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
11331134
)
11341135
}
11351136
}
@@ -2346,7 +2347,7 @@ impl Display for RpcError {
23462347
write!(
23472348
f,
23482349
"{}",
2349-
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
2350+
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
23502351
)
23512352
}
23522353
}
@@ -3639,7 +3640,7 @@ impl CallToolResultContentItem {
36393640
) -> Self {
36403641
EmbeddedResource::new(resource, annotations).into()
36413642
}
3642-
/// Returns the content type as a string based on the variant of `CallToolResultContentItem`.
3643+
///Returns the content type as a string based on the variant of `CallToolResultContentItem`
36433644
pub fn content_type(&self) -> &str {
36443645
match self {
36453646
CallToolResultContentItem::TextContent(text_content) => text_content.type_(),
@@ -3721,7 +3722,7 @@ impl CallToolResult {
37213722
meta: None,
37223723
}
37233724
}
3724-
/// Adds metadata to the `CallToolResult`, allowing additional context or information to be included
3725+
/// Assigns metadata to the CallToolResult, enabling the inclusion of extra context or details.
37253726
pub fn with_meta(mut self, meta: Option<serde_json::Map<String, Value>>) -> Self {
37263727
self.meta = meta;
37273728
self

src/generated_schema/2025_03_26/mcp_schema.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// ----------------------------------------------------------------------------
2-
/// This file is auto-generated by mcp-schema-gen v0.3.0.
2+
/// This file is auto-generated by mcp-schema-gen v0.4.1.
33
/// WARNING:
44
/// It is not recommended to modify this file directly. You are free to
55
/// modify or extend the implementations as needed, but please do so at your own risk.
66
///
77
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
8-
/// Hash : UNKNOWN
9-
/// Generated at : 2025-05-26 21:28:07
8+
/// Hash : 169021c2e1332eb9197a6f47fb6ec30e0a70b1d0
9+
/// Generated at : 2025-06-28 14:42:13
1010
/// ----------------------------------------------------------------------------
1111
///
1212
/// MCP Protocol Version

0 commit comments

Comments
 (0)