Skip to content

Commit bc233ea

Browse files
authored
feat!: add new draft version and update 2025_03_26 (#66)
* feat: add new draft version and update 2025_03_26 * feat: deprecate and rename RPCMessage and MCPMessage * chore: set default schema version
1 parent fdf66b4 commit bc233ea

14 files changed

+10097
-37
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,7 @@ latest = ["2025_03_26"]
4545
2025_03_26 = []
4646
# enabled mcp schema version 2024_11_05
4747
2024_11_05 = []
48+
# enabled draft mcp schema
49+
draft = []
4850
# 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.
4951
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 implementation of the official Model Context Protocol (MCP) schema in Rust, supporting both the `2024_11_05` and `2025_03_26` versions.
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.
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 both schema versions : `2024_11_05` and `2025_03_26`.
49+
- 📜 Includes all official released versions : `2024_11_05` and `2025_03_26` 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?
@@ -68,10 +68,11 @@ For more information on the MCP architecture, refer to the [official documentati
6868

6969
## Schema Versions
7070

71-
This repository provides all versions of the schema, which can be selected using Cargo features:
71+
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

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

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

examples/mcp_client_handle_message.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> {
107107
ServerResult::ListResourcesResult(list_resources_result) => {
108108
dbg!(list_resources_result);
109109
}
110-
#[cfg(feature = "2024_11_05")]
111110
ServerResult::ListResourceTemplatesResult(list_resource_templates_result) => {
112111
dbg!(list_resource_templates_result);
113112
}

examples/mcp_server_handle_message.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> {
5252
dbg!(list_resources_request);
5353
}
5454

55-
#[cfg(feature = "2024_11_05")]
5655
ClientRequest::ListResourceTemplatesRequest(list_resource_templates_request) => {
5756
dbg!(list_resource_templates_request);
5857
}

scripts/run_clippy.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 (passed to clippy one at a time)
7-
SCHEMA_VERSION_FEATURES=("2025_03_26", "2024_11_05")
7+
SCHEMA_VERSION_FEATURES=("2025_03_26", "2024_11_05", "draft")
88

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

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")
7+
SCHEMA_VERSION_FEATURES=("2025_03_26", "2024_11_05", "draft")
88

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

src/generated_schema.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#[cfg(feature = "2024_11_05")]
33
#[path = "generated_schema/2024_11_05/mcp_schema.rs"]
44
mod schema_2024_11_05;
5+
56
#[cfg(feature = "2024_11_05")]
67
pub use schema_2024_11_05::*;
78

@@ -23,3 +24,21 @@ pub use schema_2025_03_26::*;
2324
#[cfg(not(feature = "2024_11_05"))]
2425
#[path = "generated_schema/2025_03_26/schema_utils.rs"]
2526
pub mod schema_utils;
27+
28+
/// Schema Version : draft
29+
#[cfg(feature = "draft")]
30+
#[cfg(not(feature = "2024_11_05"))]
31+
#[cfg(not(feature = "2025_03_26"))]
32+
#[path = "generated_schema/draft/mcp_schema.rs"]
33+
mod schema_draft;
34+
35+
#[cfg(feature = "draft")]
36+
#[cfg(not(feature = "2024_11_05"))]
37+
#[cfg(not(feature = "2025_03_26"))]
38+
pub use schema_draft::*;
39+
40+
#[cfg(all(feature = "schema_utils", feature = "draft"))]
41+
#[cfg(not(feature = "2024_11_05"))]
42+
#[cfg(not(feature = "2025_03_26"))]
43+
#[path = "generated_schema/draft/schema_utils.rs"]
44+
pub mod schema_utils;

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.1.16.
2+
/// This file is auto-generated by mcp-schema-gen v0.2.0.
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 : 72516795d9a7aacdcf9b87624feb05229e10c950
9-
/// Generated at : 2025-04-04 20:01:25
8+
/// Hash : 5da5bac89165d68cad24a211119e4c1b61178d5a
9+
/// Generated at : 2025-04-26 18:56:03
1010
/// ----------------------------------------------------------------------------
1111
///
1212
/// MCP Protocol Version

src/generated_schema/2024_11_05/schema_utils.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ fn detect_message_type(value: &serde_json::Value) -> MessageTypes {
5959

6060
/// Represents a generic MCP (Model Context Protocol) message.
6161
/// This trait defines methods to classify and extract information from messages.
62-
pub trait RPCMessage: MCPMessage {
62+
pub trait RpcMessage: McpMessage {
6363
fn request_id(&self) -> Option<&RequestId>;
6464
fn jsonrpc(&self) -> &str;
6565
}
6666

67-
pub trait MCPMessage {
67+
pub trait McpMessage {
6868
fn is_response(&self) -> bool;
6969
fn is_request(&self) -> bool;
7070
fn is_notification(&self) -> bool;
@@ -226,7 +226,7 @@ impl ClientMessage {
226226
}
227227
}
228228

229-
impl RPCMessage for ClientMessage {
229+
impl RpcMessage for ClientMessage {
230230
// Retrieves the request ID associated with the message, if applicable
231231
fn request_id(&self) -> Option<&RequestId> {
232232
match self {
@@ -251,8 +251,8 @@ impl RPCMessage for ClientMessage {
251251
}
252252
}
253253

254-
// Implementing the `MCPMessage` trait for `ClientMessage`
255-
impl MCPMessage for ClientMessage {
254+
// Implementing the `McpMessage` trait for `ClientMessage`
255+
impl McpMessage for ClientMessage {
256256
// Returns true if the message is a response type
257257
fn is_response(&self) -> bool {
258258
matches!(self, ClientMessage::Response(_))
@@ -738,7 +738,7 @@ impl ServerMessage {
738738
}
739739
}
740740

741-
impl RPCMessage for ServerMessage {
741+
impl RpcMessage for ServerMessage {
742742
// Retrieves the request ID associated with the message, if applicable
743743
fn request_id(&self) -> Option<&RequestId> {
744744
match self {
@@ -767,8 +767,8 @@ impl RPCMessage for ServerMessage {
767767
}
768768
}
769769

770-
// Implementing the `MCPMessage` trait for `ServerMessage`
771-
impl MCPMessage for ServerMessage {
770+
// Implementing the `McpMessage` trait for `ServerMessage`
771+
impl McpMessage for ServerMessage {
772772
// Returns true if the message is a response type
773773
fn is_response(&self) -> bool {
774774
matches!(self, ServerMessage::Response(_))
@@ -1183,7 +1183,7 @@ impl From<RpcError> for MessageFromServer {
11831183
}
11841184
}
11851185

1186-
impl MCPMessage for MessageFromServer {
1186+
impl McpMessage for MessageFromServer {
11871187
fn is_response(&self) -> bool {
11881188
matches!(self, MessageFromServer::ResultFromServer(_))
11891189
}
@@ -1288,7 +1288,7 @@ impl From<RpcError> for MessageFromClient {
12881288
}
12891289
}
12901290

1291-
impl MCPMessage for MessageFromClient {
1291+
impl McpMessage for MessageFromClient {
12921292
fn is_response(&self) -> bool {
12931293
matches!(self, MessageFromClient::ResultFromClient(_))
12941294
}
@@ -1442,6 +1442,11 @@ impl CallToolRequest {
14421442
}
14431443
}
14441444

1445+
#[deprecated(since = "0.4.0", note = "This trait was renamed to RpcMessage. Use RpcMessage instead.")]
1446+
pub type RPCMessage = ();
1447+
#[deprecated(since = "0.4.0", note = "This trait was renamed to McpMessage. Use McpMessage instead.")]
1448+
pub type MCPMessage = ();
1449+
14451450
/// BEGIN AUTO GENERATED
14461451
impl ::serde::Serialize for ClientJsonrpcRequest {
14471452
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>

src/generated_schema/2025_03_26/mcp_schema.rs

Lines changed: 37 additions & 5 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.1.16.
2+
/// This file is auto-generated by mcp-schema-gen v0.2.0.
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 : 72516795d9a7aacdcf9b87624feb05229e10c950
9-
/// Generated at : 2025-04-04 20:01:26
8+
/// Hash : 5da5bac89165d68cad24a211119e4c1b61178d5a
9+
/// Generated at : 2025-04-26 18:56:03
1010
/// ----------------------------------------------------------------------------
1111
///
1212
/// MCP Protocol Version
@@ -594,6 +594,9 @@ impl ::std::convert::From<RootsListChangedNotification> for ClientNotification {
594594
/// "$ref": "#/definitions/ListResourcesRequest"
595595
/// },
596596
/// {
597+
/// "$ref": "#/definitions/ListResourceTemplatesRequest"
598+
/// },
599+
/// {
597600
/// "$ref": "#/definitions/ReadResourceRequest"
598601
/// },
599602
/// {
@@ -630,6 +633,7 @@ pub enum ClientRequest {
630633
InitializeRequest(InitializeRequest),
631634
PingRequest(PingRequest),
632635
ListResourcesRequest(ListResourcesRequest),
636+
ListResourceTemplatesRequest(ListResourceTemplatesRequest),
633637
ReadResourceRequest(ReadResourceRequest),
634638
SubscribeRequest(SubscribeRequest),
635639
UnsubscribeRequest(UnsubscribeRequest),
@@ -655,6 +659,11 @@ impl ::std::convert::From<ListResourcesRequest> for ClientRequest {
655659
Self::ListResourcesRequest(value)
656660
}
657661
}
662+
impl ::std::convert::From<ListResourceTemplatesRequest> for ClientRequest {
663+
fn from(value: ListResourceTemplatesRequest) -> Self {
664+
Self::ListResourceTemplatesRequest(value)
665+
}
666+
}
658667
impl ::std::convert::From<ReadResourceRequest> for ClientRequest {
659668
fn from(value: ReadResourceRequest) -> Self {
660669
Self::ReadResourceRequest(value)
@@ -4237,6 +4246,10 @@ pub struct RequestParamsMeta {
42374246
/// "description": "A human-readable name for this resource.\n\nThis can be used by clients to populate UI elements.",
42384247
/// "type": "string"
42394248
/// },
4249+
/// "size": {
4250+
/// "description": "The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.\n\nThis can be used by Hosts to display file sizes and estimate context window usage.",
4251+
/// "type": "integer"
4252+
/// },
42404253
/// "uri": {
42414254
/// "description": "The URI of this resource.",
42424255
/// "type": "string",
@@ -4261,6 +4274,10 @@ pub struct Resource {
42614274
/**A human-readable name for this resource.
42624275
This can be used by clients to populate UI elements.*/
42634276
pub name: ::std::string::String,
4277+
/**The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
4278+
This can be used by Hosts to display file sizes and estimate context window usage.*/
4279+
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
4280+
pub size: ::std::option::Option<i64>,
42644281
///The URI of this resource.
42654282
pub uri: ::std::string::String,
42664283
}
@@ -5143,6 +5160,9 @@ impl ::std::convert::From<ListRootsRequest> for ServerRequest {
51435160
/// "$ref": "#/definitions/ListResourcesResult"
51445161
/// },
51455162
/// {
5163+
/// "$ref": "#/definitions/ListResourceTemplatesResult"
5164+
/// },
5165+
/// {
51465166
/// "$ref": "#/definitions/ReadResourceResult"
51475167
/// },
51485168
/// {
@@ -5169,6 +5189,7 @@ impl ::std::convert::From<ListRootsRequest> for ServerRequest {
51695189
pub enum ServerResult {
51705190
InitializeResult(InitializeResult),
51715191
ListResourcesResult(ListResourcesResult),
5192+
ListResourceTemplatesResult(ListResourceTemplatesResult),
51725193
ReadResourceResult(ReadResourceResult),
51735194
ListPromptsResult(ListPromptsResult),
51745195
GetPromptResult(GetPromptResult),
@@ -5187,6 +5208,11 @@ impl ::std::convert::From<ListResourcesResult> for ServerResult {
51875208
Self::ListResourcesResult(value)
51885209
}
51895210
}
5211+
impl ::std::convert::From<ListResourceTemplatesResult> for ServerResult {
5212+
fn from(value: ListResourceTemplatesResult) -> Self {
5213+
Self::ListResourceTemplatesResult(value)
5214+
}
5215+
}
51905216
impl ::std::convert::From<ReadResourceResult> for ServerResult {
51915217
fn from(value: ReadResourceResult) -> Self {
51925218
Self::ReadResourceResult(value)
@@ -5549,15 +5575,15 @@ received from untrusted servers.*/
55495575
///
55505576
/// ```json
55515577
///{
5552-
/// "description": "Additional properties describing a Tool to clients.\n\nNOTE: all properties in ToolAnnotations are **hints**. \nThey are not guaranteed to provide a faithful description of \ntool behavior (including descriptive properties like title).\n\nClients should never make tool use decisions based on ToolAnnotations\nreceived from untrusted servers.",
5578+
/// "description": "Additional properties describing a Tool to clients.\n\nNOTE: all properties in ToolAnnotations are **hints**.\nThey are not guaranteed to provide a faithful description of\ntool behavior (including descriptive properties like title).\n\nClients should never make tool use decisions based on ToolAnnotations\nreceived from untrusted servers.",
55535579
/// "type": "object",
55545580
/// "properties": {
55555581
/// "destructiveHint": {
55565582
/// "description": "If true, the tool may perform destructive updates to its environment.\nIf false, the tool performs only additive updates.\n\n(This property is meaningful only when readOnlyHint == false)\n\nDefault: true",
55575583
/// "type": "boolean"
55585584
/// },
55595585
/// "idempotentHint": {
5560-
/// "description": "If true, calling the tool repeatedly with the same arguments \nwill have no additional effect on the its environment.\n\n(This property is meaningful only when readOnlyHint == false)\n\nDefault: false",
5586+
/// "description": "If true, calling the tool repeatedly with the same arguments\nwill have no additional effect on the its environment.\n\n(This property is meaningful only when readOnlyHint == false)\n\nDefault: false",
55615587
/// "type": "boolean"
55625588
/// },
55635589
/// "openWorldHint": {
@@ -5850,6 +5876,11 @@ impl<'de> serde::Deserialize<'de> for ClientRequest {
58505876
let req = serde_json::from_value::<ListResourcesRequest>(value).map_err(serde::de::Error::custom)?;
58515877
Ok(ClientRequest::ListResourcesRequest(req))
58525878
}
5879+
"resources/templates/list" => {
5880+
let req =
5881+
serde_json::from_value::<ListResourceTemplatesRequest>(value).map_err(serde::de::Error::custom)?;
5882+
Ok(ClientRequest::ListResourceTemplatesRequest(req))
5883+
}
58535884
"resources/read" => {
58545885
let req = serde_json::from_value::<ReadResourceRequest>(value).map_err(serde::de::Error::custom)?;
58555886
Ok(ClientRequest::ReadResourceRequest(req))
@@ -5899,6 +5930,7 @@ impl ClientRequest {
58995930
ClientRequest::InitializeRequest(request) => request.method(),
59005931
ClientRequest::PingRequest(request) => request.method(),
59015932
ClientRequest::ListResourcesRequest(request) => request.method(),
5933+
ClientRequest::ListResourceTemplatesRequest(request) => request.method(),
59025934
ClientRequest::ReadResourceRequest(request) => request.method(),
59035935
ClientRequest::SubscribeRequest(request) => request.method(),
59045936
ClientRequest::UnsubscribeRequest(request) => request.method(),

0 commit comments

Comments
 (0)