Skip to content

feat: update to latest version of rust-mcp-schema #9

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 5, 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
24 changes: 17 additions & 7 deletions Cargo.lock

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

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ members = [

[workspace.dependencies]
# Workspace member crates
rust-mcp-transport = { version = "0.1.1", path = "crates/rust-mcp-transport" }
rust-mcp-transport = { version = "0.1", path = "crates/rust-mcp-transport" }
rust-mcp-sdk = { path = "crates/rust-mcp-sdk" }
rust-mcp-macros = { version = "0.1.2", path = "crates/rust-mcp-macros" }
rust-mcp-macros = { version = "0.1", path = "crates/rust-mcp-macros" }

# External crates
rust-mcp-schema = { version = "0.2.2" }
rust-mcp-schema = { version = "0.3" }
futures = { version = "0.3" }
tokio = { version = "1.44.1", features = ["full"] }
serde = { version = "1.0.219", features = ["derive", "serde_derive"] }
serde_json = { version = "1.0.140" }
async-trait = { version = "0.1.88" }
strum = { version = "0.27.0", features = ["derive"] }
thiserror = { version = "2.0.12" }
tokio-stream = { version = "0.1.17" }
tokio = { version = "1.4", features = ["full"] }
serde = { version = "1.0", features = ["derive", "serde_derive"] }
serde_json = { version = "1.0" }
async-trait = { version = "0.1" }
strum = { version = "0.27", features = ["derive"] }
thiserror = { version = "2.0" }
tokio-stream = { version = "0.1" }


# [workspace.dependencies.windows]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub struct MyServerHandler;
#[async_trait]
impl ServerHandler for MyServerHandler {
// Handle ListToolsRequest, return list of available tools as ListToolsResult
async fn handle_list_tools_request(&self, request: ListToolsRequest, runtime: &dyn MCPServer) -> Result<ListToolsResult, JsonrpcErrorError> {
async fn handle_list_tools_request(&self, request: ListToolsRequest, runtime: &dyn MCPServer) -> Result<ListToolsResult, RpcError> {

Ok(ListToolsResult {
tools: vec![SayHelloTool::get_tool()],
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-mcp-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub struct MyServerHandler;
#[async_trait]
impl ServerHandler for MyServerHandler {
// Handle ListToolsRequest, return list of available tools as ListToolsResult
async fn handle_list_tools_request(&self, request: ListToolsRequest, runtime: &dyn MCPServer) -> Result<ListToolsResult, JsonrpcErrorError> {
async fn handle_list_tools_request(&self, request: ListToolsRequest, runtime: &dyn MCPServer) -> Result<ListToolsResult, RpcError> {

Ok(ListToolsResult {
tools: vec![SayHelloTool::get_tool()],
Expand Down
4 changes: 2 additions & 2 deletions crates/rust-mcp-sdk/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rust_mcp_schema::JsonrpcErrorError;
use rust_mcp_schema::RpcError;
use rust_mcp_transport::error::TransportError;
use thiserror::Error;

Expand All @@ -7,7 +7,7 @@ pub type SdkResult<T> = core::result::Result<T, MCPSdkError>;
#[derive(Debug, Error)]
pub enum MCPSdkError {
#[error("{0}")]
JsonrpcErrorError(#[from] JsonrpcErrorError),
RpcError(#[from] RpcError),
#[error("{0}")]
IoError(#[from] std::io::Error),
#[error("{0}")]
Expand Down
44 changes: 22 additions & 22 deletions crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use async_trait::async_trait;
use rust_mcp_schema::{
CancelledNotification, CreateMessageRequest, CreateMessageResult, JsonrpcErrorError,
ListRootsRequest, ListRootsResult, LoggingMessageNotification, PingRequest,
ProgressNotification, PromptListChangedNotification, ResourceListChangedNotification,
ResourceUpdatedNotification, Result, ToolListChangedNotification,
CancelledNotification, CreateMessageRequest, CreateMessageResult, ListRootsRequest,
ListRootsResult, LoggingMessageNotification, PingRequest, ProgressNotification,
PromptListChangedNotification, ResourceListChangedNotification, ResourceUpdatedNotification,
Result, RpcError, ToolListChangedNotification,
};
use serde_json::Value;

Expand All @@ -22,17 +22,17 @@ pub trait ClientHandler: Send + Sync + 'static {
&self,
request: PingRequest,
runtime: &dyn MCPClient,
) -> std::result::Result<Result, JsonrpcErrorError> {
) -> std::result::Result<Result, RpcError> {
Ok(Result::default())
}

async fn handle_create_message_request(
&self,
request: CreateMessageRequest,
runtime: &dyn MCPClient,
) -> std::result::Result<CreateMessageResult, JsonrpcErrorError> {
) -> std::result::Result<CreateMessageResult, RpcError> {
runtime.assert_client_request_capabilities(request.method())?;
Err(JsonrpcErrorError::method_not_found().with_message(format!(
Err(RpcError::method_not_found().with_message(format!(
"No handler is implemented for '{}'.",
request.method(),
)))
Expand All @@ -42,9 +42,9 @@ pub trait ClientHandler: Send + Sync + 'static {
&self,
request: ListRootsRequest,
runtime: &dyn MCPClient,
) -> std::result::Result<ListRootsResult, JsonrpcErrorError> {
) -> std::result::Result<ListRootsResult, RpcError> {
runtime.assert_client_request_capabilities(request.method())?;
Err(JsonrpcErrorError::method_not_found().with_message(format!(
Err(RpcError::method_not_found().with_message(format!(
"No handler is implemented for '{}'.",
request.method(),
)))
Expand All @@ -54,8 +54,8 @@ pub trait ClientHandler: Send + Sync + 'static {
&self,
request: Value,
runtime: &dyn MCPClient,
) -> std::result::Result<ListRootsResult, JsonrpcErrorError> {
Err(JsonrpcErrorError::method_not_found()
) -> std::result::Result<ListRootsResult, RpcError> {
Err(RpcError::method_not_found()
.with_message("No handler is implemented for custom requests.".to_string()))
}

Expand All @@ -67,63 +67,63 @@ pub trait ClientHandler: Send + Sync + 'static {
&self,
notification: CancelledNotification,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
Ok(())
}

async fn handle_progress_notification(
&self,
notification: ProgressNotification,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
Ok(())
}

async fn handle_resource_list_changed_notification(
&self,
notification: ResourceListChangedNotification,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
Ok(())
}

async fn handle_resource_updated_notification(
&self,
notification: ResourceUpdatedNotification,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
Ok(())
}

async fn handle_prompt_list_changed_notification(
&self,
notification: PromptListChangedNotification,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
Ok(())
}

async fn handle_tool_list_changed_notification(
&self,
notification: ToolListChangedNotification,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
Ok(())
}

async fn handle_logging_message_notification(
&self,
notification: LoggingMessageNotification,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
Ok(())
}

async fn handle_custom_notification(
&self,
notification: Value,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
Ok(())
}

Expand All @@ -132,17 +132,17 @@ pub trait ClientHandler: Send + Sync + 'static {
//********************//
async fn handle_error(
&self,
error: JsonrpcErrorError,
error: RpcError,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
Ok(())
}

async fn handle_process_error(
&self,
error_message: String,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
if !runtime.is_shut_down().await {
eprintln!("Process error: {}", error_message);
}
Expand Down
10 changes: 5 additions & 5 deletions crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait ClientHandlerCore: Send + Sync + 'static {
&self,
request: RequestFromServer,
runtime: &dyn MCPClient,
) -> std::result::Result<ResultFromClient, JsonrpcErrorError>;
) -> std::result::Result<ResultFromClient, RpcError>;

/// Asynchronously handles an incoming notification from the server.
///
Expand All @@ -30,23 +30,23 @@ pub trait ClientHandlerCore: Send + Sync + 'static {
&self,
notification: NotificationFromServer,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError>;
) -> std::result::Result<(), RpcError>;

/// Asynchronously handles an error received from the server.
///
/// # Parameters
/// - `error` – The error data received from the MCP server.
async fn handle_error(
&self,
error: JsonrpcErrorError,
error: RpcError,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError>;
) -> std::result::Result<(), RpcError>;

async fn handle_process_error(
&self,
error_message: String,
runtime: &dyn MCPClient,
) -> std::result::Result<(), JsonrpcErrorError> {
) -> std::result::Result<(), RpcError> {
if !runtime.is_shut_down().await {
eprintln!("Process error: {}", error_message);
}
Expand Down
Loading