diff --git a/Cargo.lock b/Cargo.lock index b09dd03..a06b960 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -330,9 +330,9 @@ dependencies = [ [[package]] name = "rust-mcp-schema" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ec89fb6e23c83d24643baa0002dd1f465f6951d46322e18c6f8e41aac270327" +checksum = "868d31d0ae0376ba45786eac9058771da06839e83bb961ac7e5997ab3910f086" dependencies = [ "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 53e2337..beb7b62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] } diff --git a/crates/rust-mcp-sdk/README.md b/crates/rust-mcp-sdk/README.md index a0ff77d..af81e6f 100644 --- a/crates/rust-mcp-sdk/README.md +++ b/crates/rust-mcp-sdk/README.md @@ -9,7 +9,8 @@ [build status ](https://github.com/rust-mcp-stack/rust-mcp-sdk/actions/workflows/ci.yml) [Hello World MCP Server -](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! diff --git a/crates/rust-mcp-sdk/src/mcp_traits/mcp_client.rs b/crates/rust-mcp-sdk/src/mcp_traits/mcp_client.rs index e6ad976..00af015 100644 --- a/crates/rust-mcp-sdk/src/mcp_traits/mcp_client.rs +++ b/crates/rust-mcp-sdk/src/mcp_traits/mcp_client.rs @@ -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, diff --git a/crates/rust-mcp-sdk/src/mcp_traits/mcp_server.rs b/crates/rust-mcp-sdk/src/mcp_traits/mcp_server.rs index e406023..c80df0e 100644 --- a/crates/rust-mcp-sdk/src/mcp_traits/mcp_server.rs +++ b/crates/rust-mcp-sdk/src/mcp_traits/mcp_server.rs @@ -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, diff --git a/crates/rust-mcp-transport/src/mcp_stream.rs b/crates/rust-mcp-transport/src/mcp_stream.rs index 127bfab..754e307 100644 --- a/crates/rust-mcp-transport/src/mcp_stream.rs +++ b/crates/rust-mcp-transport/src/mcp_stream.rs @@ -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, @@ -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::(CHANNEL_CAPACITY); @@ -79,7 +79,7 @@ impl MCPStream { mut shutdown_rx: Receiver, ) -> JoinHandle> 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(); diff --git a/crates/rust-mcp-transport/src/message_dispatcher.rs b/crates/rust-mcp-transport/src/message_dispatcher.rs index 0a9fa89..8ae5cdd 100644 --- a/crates/rust-mcp-transport/src/message_dispatcher.rs +++ b/crates/rust-mcp-transport/src/message_dispatcher.rs @@ -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}; @@ -69,7 +69,7 @@ impl MessageDispatcher { /// An `Option`: `Some` for requests or responses/errors, `None` for notifications. fn request_id_for_message( &self, - message: &impl MCPMessage, + message: &impl McpMessage, request_id: Option, ) -> Option { // we need to produce next request_id for requests diff --git a/crates/rust-mcp-transport/src/stdio.rs b/crates/rust-mcp-transport/src/stdio.rs index 52c52dd..6f2eb62 100644 --- a/crates/rust-mcp-transport/src/stdio.rs +++ b/crates/rust-mcp-transport/src/stdio.rs @@ -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; @@ -114,8 +114,8 @@ impl StdioTransport { #[async_trait] impl Transport 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. /// diff --git a/crates/rust-mcp-transport/src/transport.rs b/crates/rust-mcp-transport/src/transport.rs index 768f24f..06710f0 100644 --- a/crates/rust-mcp-transport/src/transport.rs +++ b/crates/rust-mcp-transport/src/transport.rs @@ -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; @@ -44,7 +44,7 @@ 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 @@ -52,7 +52,7 @@ impl Default for TransportOptions { /// /// # 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`). /// @@ -78,7 +78,7 @@ impl Default for TransportOptions { #[async_trait] pub trait McpDispatch: 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`. @@ -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: 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(