Skip to content
Open
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
8 changes: 4 additions & 4 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions rig/rig-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down Expand Up @@ -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
Expand Down
37 changes: 15 additions & 22 deletions rig/rig-core/examples/rmcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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",
Expand Down Expand Up @@ -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();
Expand Down
37 changes: 12 additions & 25 deletions rig/rig-core/src/tool/rmcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")))?;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down
Loading