diff --git a/Cargo.lock b/Cargo.lock index 389d04bc3..681db0c45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9758,9 +9758,9 @@ dependencies = [ [[package]] name = "rmcp" -version = "0.16.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4c9c94680f75470ee8083a0667988b5d7b5beb70b9f998a8e51de7c682ce60" +checksum = "d2cb14cb9278a12eae884c9f3c0cfeca2cc28f361211206424a1d7abed95f090" dependencies = [ "async-trait", "base64 0.22.1", @@ -9790,9 +9790,9 @@ dependencies = [ [[package]] name = "rmcp-macros" -version = "0.16.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90c23c8f26cae4da838fbc3eadfaecf2d549d97c04b558e7bd90526a9c28b42a" +checksum = "6a02ea81d9482b07e1fe156ac7cf98b6823d51fb84531936a5e1cbb4eec31ad5" dependencies = [ "darling 0.23.0", "proc-macro2", diff --git a/rig/rig-core/Cargo.toml b/rig/rig-core/Cargo.toml index d107d5102..d5faed82c 100644 --- a/rig/rig-core/Cargo.toml +++ b/rig/rig-core/Cargo.toml @@ -40,7 +40,7 @@ serde_json = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true } url = { workspace = true } -rmcp = { version = "0.16", optional = true, features = ["client"] } +rmcp = { version = "1", optional = true, features = ["client"] } tokio = { workspace = true, features = ["rt", "sync"] } http = "1.3.1" tracing-futures = { version = "0.2.5", features = ["futures-03"] } @@ -79,7 +79,7 @@ reqwest-middleware = { version = "0.5", features = [ # Required for `rmcp` example hyper-util = { version = "0.1.14", features = ["service", "server"] } -rmcp = { version = "0.16", features = [ +rmcp = { version = "1", features = [ "client", "macros", "reqwest", # required for some strange reason diff --git a/rig/rig-core/examples/rmcp.rs b/rig/rig-core/examples/rmcp.rs index 0087c73ce..7e1bdb320 100644 --- a/rig/rig-core/examples/rmcp.rs +++ b/rig/rig-core/examples/rmcp.rs @@ -116,15 +116,14 @@ impl Counter { #[tool_handler] impl ServerHandler for Counter { fn get_info(&self) -> ServerInfo { - ServerInfo { - protocol_version: ProtocolVersion::V_2024_11_05, - capabilities: ServerCapabilities::builder() + ServerInfo::new( + ServerCapabilities::builder() .enable_resources() .enable_tools() .build(), - server_info: Implementation::from_build_env(), - instructions: Some("This server provides a counter tool that can increment and decrement values. The counter starts at 0 and can be modified using the 'increment' and 'decrement' tools. Use 'get_value' to check the current count.".to_string()), - } + ) + .with_protocol_version(ProtocolVersion::V_2024_11_05) + .with_instructions("This server provides a counter tool that can increment and decrement values. The counter starts at 0 and can be modified using the 'increment' and 'decrement' tools. Use 'get_value' to check the current count.") } async fn list_resources( @@ -150,15 +149,15 @@ impl ServerHandler for Counter { match uri.as_str() { "str:////Users/to/some/path/" => { let cwd = "/Users/to/some/path/"; - Ok(ReadResourceResult { - contents: vec![ResourceContents::text(cwd, uri)], - }) + Ok(ReadResourceResult::new(vec![ResourceContents::text( + cwd, uri, + )])) } "memo://insights" => { let memo = "Business Intelligence Memo\n\nAnalysis has revealed 5 key insights ..."; - Ok(ReadResourceResult { - contents: vec![ResourceContents::text(memo, uri)], - }) + Ok(ReadResourceResult::new(vec![ResourceContents::text( + memo, uri, + )])) } _ => Err(ErrorData::resource_not_found( "resource_not_found", @@ -240,16 +239,10 @@ async fn main() -> anyhow::Result<()> { } }); - let client_info = ClientInfo { - protocol_version: Default::default(), - capabilities: ClientCapabilities::default(), - client_info: Implementation { - name: "rig-core".to_string(), - version: "0.13.0".to_string(), - ..Default::default() - }, - meta: None, - }; + let client_info = ClientInfo::new( + ClientCapabilities::default(), + Implementation::new("rig-core", "0.13.0"), + ); // Create a shared ToolServer so the MCP handler can update tools at runtime. let tool_server_handle = ToolServer::new().run(); diff --git a/rig/rig-core/src/tool/rmcp.rs b/rig/rig-core/src/tool/rmcp.rs index 710ef76da..26dda610f 100644 --- a/rig/rig-core/src/tool/rmcp.rs +++ b/rig/rig-core/src/tool/rmcp.rs @@ -119,11 +119,12 @@ impl ToolDyn for McpTool { Box::pin(async move { let result = self .client - .call_tool(rmcp::model::CallToolRequestParams { - name, - arguments, - meta: None, - task: None, + .call_tool({ + let mut params = rmcp::model::CallToolRequestParams::new(name); + if let Some(args) = arguments { + params = params.with_arguments(args); + } + params }) .await .map_err(|e| McpToolError(format!("Tool returned an error: {e}")))?; @@ -371,16 +372,8 @@ mod tests { impl ServerHandler for DynamicToolServer { fn get_info(&self) -> ServerInfo { - ServerInfo { - protocol_version: ProtocolVersion::V_2024_11_05, - capabilities: ServerCapabilities::builder().enable_tools().build(), - server_info: Implementation { - name: "test-dynamic-server".to_string(), - version: "0.1.0".to_string(), - ..Default::default() - }, - instructions: None, - } + ServerInfo::new(ServerCapabilities::builder().enable_tools().build()) + .with_server_info(Implementation::new("test-dynamic-server", "0.1.0")) } async fn list_tools( @@ -520,16 +513,10 @@ mod tests { #[tokio::test] async fn test_mcp_client_handler_get_info_delegates() { - let client_info = ClientInfo { - protocol_version: Default::default(), - capabilities: ClientCapabilities::default(), - client_info: Implementation { - name: "test-client".to_string(), - version: "1.0.0".to_string(), - ..Default::default() - }, - meta: None, - }; + let client_info = ClientInfo::new( + ClientCapabilities::default(), + Implementation::new("test-client", "1.0.0"), + ); let tool_server_handle = ToolServer::new().run(); let handler = McpClientHandler::new(client_info.clone(), tool_server_handle);