Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat!: add support for MCP Schema Version 2025年06月18日 #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
hashemix merged 4 commits into main from feat/issue-76-supporting-protocol-version-2025_06_18
Jun 28, 2025
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
16 changes: 9 additions & 7 deletions Cargo.toml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,29 @@ json5 = { version = "0.4" }


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

[package.metadata.playground]
features = ["2025_03_26", "schema_utils"]
features = ["2025_06_18", "schema_utils"]

### FEATURES #################################################################

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

# defalt features
default = ["latest", "schema_utils"] # Default features
# default features
default = ["2025_06_18", "schema_utils"] # Default features

# activates the latest MCP schema version, this will be updated once a new version of schema is published
latest = ["2025_03_26"]
latest = ["2025_06_18"]
# enabled mcp schema version 2025_06_18
2025_06_18 = ["latest"]
# enabled mcp schema version 2025_03_26
2025_03_26 = ["latest"]
2025_03_26 = []
# enabled mcp schema version 2024_11_05
2024_11_05 = []
# enabled draft mcp schema
draft = []
# 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.
# 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.
schema_utils = []
7 changes: 4 additions & 3 deletions README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[<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">
](https://github.com/rust-mcp-stack/rust-mcp-schema/actions/workflows/ci.yml)

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.
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.

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.

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

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

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

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.

- [2024_11_05](src/generated_schema/2024_11_05)
- [2025_06_18](src/generated_schema/2025_06_18)
- [2025_03_26](src/generated_schema/2025_03_26)
- [2024_11_05](src/generated_schema/2024_11_05)
- [draft](src/generated_schema/draft)

### How to switch between different schema versions?
Expand Down
33 changes: 24 additions & 9 deletions examples/mcp_client_handle_message.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
#[cfg(feature = "latest")]
use rust_mcp_schema::schema_utils::*;
#[cfg(feature = "latest")]
use rust_mcp_schema::*;
mod schema {
pub use rust_mcp_schema::schema_utils::*;
pub use rust_mcp_schema::*;
}

#[cfg(feature = "2024_11_05")]
use rust_mcp_schema::mcp_2024_11_05::schema_utils::*;
#[cfg(feature = "2024_11_05")]
use rust_mcp_schema::mcp_2024_11_05::*;
mod schema {
pub use rust_mcp_schema::mcp_2024_11_05::schema_utils::*;
pub use rust_mcp_schema::mcp_2024_11_05::*;
}

#[cfg(feature = "2025_03_26")]
mod schema {
pub use rust_mcp_schema::mcp_2025_03_26::schema_utils::*;
pub use rust_mcp_schema::mcp_2025_03_26::*;
}

#[cfg(feature = "draft")]
use rust_mcp_schema::mcp_draft::schema_utils::*;
#[cfg(feature = "draft")]
use rust_mcp_schema::mcp_draft::*;
mod schema {
pub use rust_mcp_schema::mcp_draft::schema_utils::*;
pub use rust_mcp_schema::mcp_draft::*;
}

use schema::*;

use std::str::FromStr;

Expand Down Expand Up @@ -66,6 +77,10 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> {
ServerRequest::ListRootsRequest(list_roots_request) => {
dbg!(list_roots_request);
}
#[cfg(any(feature = "2025_06_18", feature = "draft"))]
ServerRequest::ElicitRequest(elicit_request) => {
dbg!(elicit_request);
}
}
}
// Check if it's a CustomRequest; the value can be deserialized into your own custom types.
Expand Down
35 changes: 24 additions & 11 deletions examples/mcp_server_handle_message.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
#[cfg(feature = "latest")]
use rust_mcp_schema::schema_utils::*;
#[cfg(feature = "latest")]
use rust_mcp_schema::*;
mod schema {
pub use rust_mcp_schema::schema_utils::*;
pub use rust_mcp_schema::*;
}

#[cfg(feature = "2024_11_05")]
use rust_mcp_schema::mcp_2024_11_05::schema_utils::*;
#[cfg(feature = "2024_11_05")]
use rust_mcp_schema::mcp_2024_11_05::*;
mod schema {
pub use rust_mcp_schema::mcp_2024_11_05::schema_utils::*;
pub use rust_mcp_schema::mcp_2024_11_05::*;
}

#[cfg(feature = "2025_03_26")]
mod schema {
pub use rust_mcp_schema::mcp_2025_03_26::schema_utils::*;
pub use rust_mcp_schema::mcp_2025_03_26::*;
}

#[cfg(feature = "draft")]
use rust_mcp_schema::mcp_draft::schema_utils::*;
#[cfg(feature = "draft")]
use rust_mcp_schema::mcp_draft::*;
mod schema {
pub use rust_mcp_schema::mcp_draft::schema_utils::*;
pub use rust_mcp_schema::mcp_draft::*;
}

use schema::*;

use std::str::FromStr;

Expand Down Expand Up @@ -149,14 +160,16 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> {
ClientResult::Result(_) => {
dbg!(client_result);
}

ClientResult::CreateMessageResult(create_message_result) => {
dbg!(create_message_result);
}

ClientResult::ListRootsResult(list_roots_result) => {
dbg!(list_roots_result);
}
#[cfg(any(feature = "2025_06_18", feature = "draft"))]
ClientResult::ElicitResult(elicit_result) => {
dbg!(elicit_result);
}
},

// Check if it's a CustomResult; the value can be deserialized into your custom types.
Expand Down
8 changes: 4 additions & 4 deletions scripts/run_clippy.sh
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

# common features
COMMON_FEATURES=("schema_utils")
COMMON_FEATURES=("schema_utils")

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

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

for FEATURE in "${SCHEMA_VERSION_FEATURES[@]}"; do
Expand All @@ -20,4 +20,4 @@ for FEATURE in "${SCHEMA_VERSION_FEATURES[@]}"; do
fi
done

echo "✅ All Clippy lints have passed!"
echo "✅ All Clippy lints have passed!"
2 changes: 1 addition & 1 deletion scripts/run_test.sh
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
COMMON_FEATURES=("schema_utils")

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

# space-separated string
COMMON_FEATURES_STR="${COMMON_FEATURES[*]}"
Expand Down
16 changes: 13 additions & 3 deletions src/generated_schema.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,19 @@ macro_rules! define_schema_version {
};
}

/// Latest MCP Protocol 2025_03_26
#[cfg(feature = "2025_03_26")]
pub use mcp_2025_03_26::*;
/// Latest MCP Protocol 2025_06_18
#[cfg(feature = "2025_06_18")]
pub use mcp_2025_06_18::*;

#[cfg(feature = "2025_06_18")]
define_schema_version!(
"2025_06_18",
mcp_2025_06_18,
"generated_schema/2025_06_18/mcp_schema.rs",
"generated_schema/2025_06_18/schema_utils.rs",
__int_2025_06_18,
__int_utils_2025_06_18
);

#[cfg(feature = "2025_03_26")]
define_schema_version!(
Expand Down
6 changes: 3 additions & 3 deletions src/generated_schema/2024_11_05/mcp_schema.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/// ----------------------------------------------------------------------------
/// This file is auto-generated by mcp-schema-gen v0.3.0.
/// This file is auto-generated by mcp-schema-gen v0.4.1.
/// WARNING:
/// It is not recommended to modify this file directly. You are free to
/// modify or extend the implementations as needed, but please do so at your own risk.
///
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
/// Hash : UNKNOWN
/// Generated at : 2025-05-26 21:28:07
/// Hash : 169021c2e1332eb9197a6f47fb6ec30e0a70b1d0
/// Generated at : 2025-06-28 14:42:12
/// ----------------------------------------------------------------------------
///
/// MCP Protocol Version
Expand Down
25 changes: 13 additions & 12 deletions src/generated_schema/2024_11_05/schema_utils.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::generated_schema::mcp_2024_11_05::*;

use serde::ser::SerializeStruct;
use serde_json::{json, Value};
use std::hash::{Hash, Hasher};
Expand Down Expand Up @@ -318,7 +319,7 @@ impl Display for ClientJsonrpcRequest {
write!(
f,
"{}",
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
)
}
}
Expand Down Expand Up @@ -446,7 +447,7 @@ impl Display for ClientJsonrpcNotification {
write!(
f,
"{}",
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
)
}
}
Expand Down Expand Up @@ -548,7 +549,7 @@ impl Display for ClientJsonrpcResponse {
write!(
f,
"{}",
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
)
}
}
Expand Down Expand Up @@ -632,7 +633,7 @@ impl Display for ClientMessage {
write!(
f,
"{}",
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
)
}
}
Expand Down Expand Up @@ -814,7 +815,7 @@ impl Display for ServerMessage {
write!(
f,
"{}",
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
)
}
}
Expand Down Expand Up @@ -853,7 +854,7 @@ impl Display for ServerJsonrpcRequest {
write!(
f,
"{}",
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
)
}
}
Expand Down Expand Up @@ -959,7 +960,7 @@ impl Display for ServerJsonrpcNotification {
write!(
f,
"{}",
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
)
}
}
Expand Down Expand Up @@ -1052,7 +1053,7 @@ impl Display for ServerJsonrpcResponse {
write!(
f,
"{}",
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
)
}
}
Expand Down Expand Up @@ -1129,7 +1130,7 @@ impl Display for JsonrpcError {
write!(
f,
"{}",
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
)
}
}
Expand Down Expand Up @@ -2346,7 +2347,7 @@ impl Display for RpcError {
write!(
f,
"{}",
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {}", err))
serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}"))
)
}
}
Expand Down Expand Up @@ -3639,7 +3640,7 @@ impl CallToolResultContentItem {
) -> Self {
EmbeddedResource::new(resource, annotations).into()
}
///Returns the content type as a string based on the variant of `CallToolResultContentItem`.
///Returns the content type as a string based on the variant of `CallToolResultContentItem`
pub fn content_type(&self) -> &str {
match self {
CallToolResultContentItem::TextContent(text_content) => text_content.type_(),
Expand Down Expand Up @@ -3721,7 +3722,7 @@ impl CallToolResult {
meta: None,
}
}
/// Adds metadata to the `CallToolResult`, allowing additional context or information to be included
/// Assigns metadata to the CallToolResult, enabling the inclusion of extra context or details.
pub fn with_meta(mut self, meta: Option<serde_json::Map<String, Value>>) -> Self {
self.meta = meta;
self
Expand Down
6 changes: 3 additions & 3 deletions src/generated_schema/2025_03_26/mcp_schema.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/// ----------------------------------------------------------------------------
/// This file is auto-generated by mcp-schema-gen v0.3.0.
/// This file is auto-generated by mcp-schema-gen v0.4.1.
/// WARNING:
/// It is not recommended to modify this file directly. You are free to
/// modify or extend the implementations as needed, but please do so at your own risk.
///
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
/// Hash : UNKNOWN
/// Generated at : 2025-05-26 21:28:07
/// Hash : 169021c2e1332eb9197a6f47fb6ec30e0a70b1d0
/// Generated at : 2025-06-28 14:42:13
/// ----------------------------------------------------------------------------
///
/// MCP Protocol Version
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /