Skip to content

feat!: implement support for the MCP protocol version 2025-06-18 #73

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
merged 8 commits into from
Jul 3, 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
182 changes: 94 additions & 88 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ rust-mcp-sdk = { path = "crates/rust-mcp-sdk", default-features = false }
rust-mcp-macros = { version = "0.4.2", path = "crates/rust-mcp-macros", default-features = false }

# External crates
rust-mcp-schema = { version = "0.6", default-features = false }
rust-mcp-schema = { version = "0.7", default-features = false }


futures = { version = "0.3" }
tokio = { version = "1.4", features = ["full"] }
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Focus on your app's logic while **rust-mcp-sdk** takes care of the rest!
**rust-mcp-sdk** provides the necessary components for developing both servers and clients in the MCP ecosystem.
Leveraging the [rust-mcp-schema](https://github.com/rust-mcp-stack/rust-mcp-schema) crate simplifies the process of building robust and reliable MCP servers and clients, ensuring consistency and minimizing errors in data handling and message processing.


**rust-mcp-sdk** supports all three official versions of the MCP protocol.
By default, it uses the **2025-06-18** version, but earlier versions can be enabled via Cargo features.



This project currently supports following transports:
- **stdio** (Standard Input/Output)
- **sse** (Server-Sent Events).
Expand Down Expand Up @@ -63,6 +69,7 @@ async fn main() -> SdkResult<()> {
server_info: Implementation {
name: "Hello World MCP Server".to_string(),
version: "0.1.0".to_string(),
title: Some("Hello World MCP Server".to_string()),
},
capabilities: ServerCapabilities {
// indicates that server support mcp tools
Expand Down Expand Up @@ -106,6 +113,7 @@ let server_details = InitializeResult {
server_info: Implementation {
name: "Hello World MCP Server".to_string(),
version: "0.1.0".to_string(),
title: Some("Hello World MCP Server".to_string()),
},
capabilities: ServerCapabilities {
// indicates that server support mcp tools
Expand Down Expand Up @@ -167,10 +175,7 @@ impl ServerHandler for MyServerHandler {
async fn handle_call_tool_request( &self, request: CallToolRequest, runtime: &dyn McpServer, ) -> Result<CallToolResult, CallToolError> {

if request.tool_name() == SayHelloTool::tool_name() {
Ok(CallToolResult::text_content(
"Hello World!".to_string(),
None,
))
Ok( CallToolResult::text_content( vec![TextContent::from("Hello World!".to_string())] ))
} else {
Err(CallToolError::unknown_tool(request.tool_name().to_string()))
}
Expand Down Expand Up @@ -301,7 +306,8 @@ The `rust-mcp-sdk` crate provides several features that can be enabled or disabl

#### MCP Protocol Versions with Corresponding Features

- `2025_03_26` : Activates MCP Protocol version 2025-03-26 (enabled by default)
- `2025_06_18` : Activates MCP Protocol version 2025-06-18 (enabled by default)
- `2025_03_26` : Activates MCP Protocol version 2025-03-26
- `2024_11_05` : Activates MCP Protocol version 2024-11-05

> Note: MCP protocol versions are mutually exclusiveβ€”only one can be active at any given time.
Expand Down
32 changes: 25 additions & 7 deletions crates/rust-mcp-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ proc-macro2 = "1.0"

[dev-dependencies]
rust-mcp-schema = { workspace = true, default-features = false }
rust-mcp-sdk = { workspace = true, default-features = false, features = [
"server",
"client",
] }

[lints]
workspace = true
Expand All @@ -33,13 +37,27 @@ proc-macro = true

[features]
# defalt features
default = ["2025_03_26"] # Default features
default = ["2025_06_18"] # Default features

# activates the latest MCP schema version, this will be updated once a new version of schema is published
latest = ["2025_03_26"]

# enabled mcp schema version 2025_03_26
2025_03_26 = ["rust-mcp-schema/2025_03_26","rust-mcp-schema/schema_utils"]
# enabled mcp schema version 2024_11_05
2024_11_05 = ["rust-mcp-schema/2024_11_05","rust-mcp-schema/schema_utils"]
latest = ["2025_06_18"]

# enables mcp schema version 2025_06_18
2025_06_18 = [
"rust-mcp-schema/2025_06_18",
"rust-mcp-schema/schema_utils",
"rust-mcp-sdk/2025_06_18",
]
# enables mcp schema version 2025_03_26
2025_03_26 = [
"rust-mcp-schema/2025_03_26",
"rust-mcp-schema/schema_utils",
"rust-mcp-sdk/2025_03_26",
]
# enables mcp schema version 2024_11_05
2024_11_05 = [
"rust-mcp-schema/2024_11_05",
"rust-mcp-schema/schema_utils",
"rust-mcp-sdk/2024_11_05",
]
sdk = []
21 changes: 21 additions & 0 deletions crates/rust-mcp-macros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,31 @@ The `mcp_tool` macro generates an implementation for the annotated struct that i

- `name` - The name of the tool (required, non-empty string).
- `description` - A description of the tool (required, non-empty string).
- `title` - An optional human-readable and easily understood title.
- `meta` - An optional JSON string that provides additional metadata for the tool.
- `destructive_hint` – Optional boolean, indicates whether the tool may make destructive changes to its environment.
- `idempotent_hint` – Optional boolean, indicates whether repeated calls with the same input have the same effect.
- `open_world_hint` – Optional boolean, indicates whether the tool can interact with external or unknown entities.
- `read_only_hint` – Optional boolean, indicates whether the tool makes no modifications to its environment.



## Usage Example

```rust
#[mcp_tool(
name = "write_file",
title = "Write File Tool"
description = "Create a new file or completely overwrite an existing file with new content."
destructive_hint = false
idempotent_hint = false
open_world_hint = false
read_only_hint = false
meta = r#"{
"key" : "value",
"string_meta" : "meta value",
"numeric_meta" : 15
}"#
)]
#[derive(rust_mcp_macros::JsonSchema)]
pub struct WriteFileTool {
Expand All @@ -38,8 +52,15 @@ fn main() {

let tool: rust_mcp_schema::Tool = WriteFileTool::tool();
assert_eq!(tool.name, "write_file");
assert_eq!(tool.title.as_ref().unwrap(), "Write File Tool");
assert_eq!( tool.description.unwrap(),"Create a new file or completely overwrite an existing file with new content.");

let meta: &Map<String, Value> = tool.meta.as_ref().unwrap();
assert_eq!(
meta.get("key").unwrap(),
&Value::String("value".to_string())
);

let schema_properties = tool.input_schema.properties.unwrap();
assert_eq!(schema_properties.len(), 2);
assert!(schema_properties.contains_key("path"));
Expand Down
Loading