Skip to content

feat: upgrade to rust-mcp-schema v0.4.0 #21

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 2 commits into from
Apr 26, 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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

# External crates
rust-mcp-schema = { version = "0.3" }
rust-mcp-schema = { version = "0.4" }
futures = { version = "0.3" }
tokio = { version = "1.4", features = ["full"] }
serde = { version = "1.0", features = ["derive", "serde_derive"] }
Expand Down
3 changes: 2 additions & 1 deletion crates/rust-mcp-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/rust-mcp-stack/rust-mcp-sdk/ci.yml?style=for-the-badge" height="22">
](https://github.com/rust-mcp-stack/rust-mcp-sdk/actions/workflows/ci.yml)
[<img alt="Hello World MCP Server" src="https://img.shields.io/badge/Example-Hello%20World%20MCP-0286ba?style=for-the-badge&logo=rust" height="22">
](examples/hello-world-mcp-server)
](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server#hello-world-mcp-server)


A high-performance, asynchronous toolkit for building MCP servers and clients.
Focus on your app's logic while **rust-mcp-sdk** takes care of the rest!
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-mcp-sdk/src/mcp_traits/mcp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use async_trait::async_trait;
use rust_mcp_schema::{
schema_utils::{
self, MCPMessage, MessageFromClient, NotificationFromClient, RequestFromClient,
self, McpMessage, MessageFromClient, NotificationFromClient, RequestFromClient,
ResultFromServer, ServerMessage,
},
CallToolRequest, CallToolRequestParams, CallToolResult, CompleteRequest, CompleteRequestParams,
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-mcp-sdk/src/mcp_traits/mcp_server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use async_trait::async_trait;
use rust_mcp_schema::{
schema_utils::{
ClientMessage, MCPMessage, MessageFromServer, NotificationFromServer, RequestFromServer,
ClientMessage, McpMessage, MessageFromServer, NotificationFromServer, RequestFromServer,
ResultFromClient,
},
CallToolRequest, CreateMessageRequest, CreateMessageRequestParams, CreateMessageResult,
Expand Down
6 changes: 3 additions & 3 deletions crates/rust-mcp-transport/src/mcp_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
IoStream,
};
use futures::Stream;
use rust_mcp_schema::{schema_utils::RPCMessage, RequestId, RpcError};
use rust_mcp_schema::{schema_utils::RpcMessage, RequestId, RpcError};
use std::{
collections::HashMap,
pin::Pin,
Expand Down Expand Up @@ -42,7 +42,7 @@ impl MCPStream {
IoStream,
)
where
R: RPCMessage + Clone + Send + Sync + serde::de::DeserializeOwned + 'static,
R: RpcMessage + Clone + Send + Sync + serde::de::DeserializeOwned + 'static,
{
let (tx, rx) = tokio::sync::broadcast::channel::<R>(CHANNEL_CAPACITY);

Expand Down Expand Up @@ -79,7 +79,7 @@ impl MCPStream {
mut shutdown_rx: Receiver<bool>,
) -> JoinHandle<Result<(), TransportError>>
where
R: RPCMessage + Clone + Send + Sync + serde::de::DeserializeOwned + 'static,
R: RpcMessage + Clone + Send + Sync + serde::de::DeserializeOwned + 'static,
{
tokio::spawn(async move {
let mut lines_stream = BufReader::new(readable).lines();
Expand Down
4 changes: 2 additions & 2 deletions crates/rust-mcp-transport/src/message_dispatcher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use async_trait::async_trait;
use rust_mcp_schema::schema_utils::{
self, ClientMessage, FromMessage, MCPMessage, MessageFromClient, MessageFromServer,
self, ClientMessage, FromMessage, McpMessage, MessageFromClient, MessageFromServer,
ServerMessage,
};
use rust_mcp_schema::{RequestId, RpcError};
Expand Down Expand Up @@ -69,7 +69,7 @@ impl<R> MessageDispatcher<R> {
/// An `Option<RequestId>`: `Some` for requests or responses/errors, `None` for notifications.
fn request_id_for_message(
&self,
message: &impl MCPMessage,
message: &impl McpMessage,
request_id: Option<RequestId>,
) -> Option<RequestId> {
// we need to produce next request_id for requests
Expand Down
6 changes: 3 additions & 3 deletions crates/rust-mcp-transport/src/stdio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use async_trait::async_trait;
use futures::Stream;
use rust_mcp_schema::schema_utils::{MCPMessage, RPCMessage};
use rust_mcp_schema::schema_utils::{McpMessage, RpcMessage};
use rust_mcp_schema::RequestId;
use std::collections::HashMap;
use std::pin::Pin;
Expand Down Expand Up @@ -114,8 +114,8 @@ impl StdioTransport {
#[async_trait]
impl<R, S> Transport<R, S> for StdioTransport
where
R: RPCMessage + Clone + Send + Sync + serde::de::DeserializeOwned + 'static,
S: MCPMessage + Clone + Send + Sync + serde::Serialize + 'static,
R: RpcMessage + Clone + Send + Sync + serde::de::DeserializeOwned + 'static,
S: McpMessage + Clone + Send + Sync + serde::Serialize + 'static,
{
/// Starts the transport, initializing streams and the message dispatcher.
///
Expand Down
12 changes: 6 additions & 6 deletions crates/rust-mcp-transport/src/transport.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::pin::Pin;

use async_trait::async_trait;
use rust_mcp_schema::{schema_utils::MCPMessage, RequestId};
use rust_mcp_schema::{schema_utils::McpMessage, RequestId};

use futures::Stream;

Expand Down Expand Up @@ -44,15 +44,15 @@ impl Default for TransportOptions {
///It is intended to be implemented by types that send messages in the MCP protocol, such as servers or clients.
///
/// The `McpDispatch` trait requires two associated types:
/// - `R`: The type of the response, which must implement the `MCPMessage` trait and be capable of deserialization.
/// - `R`: The type of the response, which must implement the `McpMessage` trait and be capable of deserialization.
/// - `S`: The type of the message to send, which must be serializable and cloneable.
///
/// Both associated types `R` and `S` must be `Send`, `Sync`, and `'static` to ensure they can be used
/// safely in an asynchronous context and across threads.
///
/// # Associated Types
///
/// - `R`: The response type, which must implement the `MCPMessage` trait, be `Clone`, `Send`, `Sync`, and
/// - `R`: The response type, which must implement the `McpMessage` trait, be `Clone`, `Send`, `Sync`, and
/// be deserializable (`DeserializeOwned`).
/// - `S`: The type of the message to send, which must be `Clone`, `Send`, `Sync`, and serializable (`Serialize`).
///
Expand All @@ -78,7 +78,7 @@ impl Default for TransportOptions {
#[async_trait]
pub trait McpDispatch<R, S>: Send + Sync + 'static
where
R: MCPMessage + Clone + Send + Sync + serde::de::DeserializeOwned + 'static,
R: McpMessage + Clone + Send + Sync + serde::de::DeserializeOwned + 'static,
S: Clone + Send + Sync + serde::Serialize + 'static,
{
/// Sends a raw message represented by type `S` and optionally includes a `request_id`.
Expand All @@ -94,14 +94,14 @@ where
/// and handling I/O operations.
///
/// The `Transport` trait requires three associated types:
/// - `R`: The message type to send, which must implement the `MCPMessage` trait.
/// - `R`: The message type to send, which must implement the `McpMessage` trait.
/// - `S`: The message type to send.
/// - `M`: The type of message that we expect to receive as a response to the sent message.
///
#[async_trait]
pub trait Transport<R, S>: Send + Sync + 'static
where
R: MCPMessage + Clone + Send + Sync + serde::de::DeserializeOwned + 'static,
R: McpMessage + Clone + Send + Sync + serde::de::DeserializeOwned + 'static,
S: Clone + Send + Sync + serde::Serialize + 'static,
{
async fn start(
Expand Down