Skip to content

Commit 85e0322

Browse files
authored
Merge pull request #12 from tidewave-ai/sd-update-sdk
update sdk to latest
2 parents e0cef8d + e979408 commit 85e0322

File tree

7 files changed

+145
-45
lines changed

7 files changed

+145
-45
lines changed

Cargo.lock

Lines changed: 74 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ version = "0.2.2"
44
edition = "2024"
55

66
[dependencies]
7-
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk.git", rev = "4c34b64b7f8dcabf94d52a9c6518c6b49c1f0451", features = [
7+
rmcp = { version = "0.6.1", features = [
88
"server",
99
"client",
1010
"reqwest",
1111
"client-side-sse",
12-
"transport-sse-client",
13-
"transport-streamable-http-client",
12+
"transport-sse-client-reqwest",
13+
"transport-streamable-http-client-reqwest",
1414
"transport-worker",
1515
"transport-child-process"
1616
] }
@@ -29,12 +29,12 @@ version = "0.9"
2929
features = ["vendored"]
3030

3131
[dev-dependencies]
32-
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk.git", rev = "4c34b64b7f8dcabf94d52a9c6518c6b49c1f0451", features = [
32+
rmcp = { version = "0.6.1", features = [
3333
"server",
3434
"client",
3535
"reqwest",
3636
"client-side-sse",
37-
"transport-sse-client",
37+
"transport-sse-client-reqwest",
3838
"transport-sse-server",
3939
"transport-child-process",
4040
"transport-streamable-http-server",

examples/echo.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,34 @@ use rmcp::transport::SseServer;
44
use tracing_subscriber::FmtSubscriber;
55

66
use rmcp::{
7-
ServerHandler,
8-
model::{ServerCapabilities, ServerInfo},
9-
schemars, tool,
7+
ErrorData as McpError,
8+
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
9+
model::*,
10+
tool, tool_handler, tool_router,
1011
};
12+
1113
#[derive(Debug, Clone, Default)]
12-
pub struct Echo;
13-
#[tool(tool_box)]
14+
pub struct Echo {
15+
tool_router: ToolRouter<Echo>,
16+
}
17+
#[tool_router]
1418
impl Echo {
19+
fn new() -> Self {
20+
Self {
21+
tool_router: Self::tool_router(),
22+
}
23+
}
24+
1525
#[tool(description = "Echo a message")]
16-
fn echo(&self, #[tool(param)] message: String) -> String {
17-
message
26+
fn echo(&self, Parameters(object): Parameters<JsonObject>) -> Result<CallToolResult, McpError> {
27+
Ok(CallToolResult::success(vec![Content::text(
28+
serde_json::Value::Object(object).to_string(),
29+
)]))
1830
}
1931
}
2032

21-
#[tool(tool_box)]
22-
impl ServerHandler for Echo {
33+
#[tool_handler]
34+
impl rmcp::ServerHandler for Echo {
2335
fn get_info(&self) -> ServerInfo {
2436
ServerInfo {
2537
instructions: Some("A simple echo server".into()),
@@ -51,7 +63,7 @@ async fn main() -> anyhow::Result<()> {
5163

5264
let ct = SseServer::serve(args.address)
5365
.await?
54-
.with_service(Echo::default);
66+
.with_service_directly(Echo::new);
5567

5668
tokio::signal::ctrl_c().await?;
5769
ct.cancel();

examples/echo_streamable.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,34 @@ use rmcp::transport::streamable_http_server::{
66
use tracing_subscriber::FmtSubscriber;
77

88
use rmcp::{
9-
ServerHandler,
10-
model::{ServerCapabilities, ServerInfo},
11-
schemars, tool,
9+
ErrorData as McpError,
10+
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
11+
model::*,
12+
tool, tool_handler, tool_router,
1213
};
14+
1315
#[derive(Debug, Clone, Default)]
14-
pub struct Echo;
15-
#[tool(tool_box)]
16+
pub struct Echo {
17+
tool_router: ToolRouter<Echo>,
18+
}
19+
#[tool_router]
1620
impl Echo {
17-
pub fn new() -> Self {
18-
Self {}
21+
fn new() -> Self {
22+
Self {
23+
tool_router: Self::tool_router(),
24+
}
1925
}
2026

2127
#[tool(description = "Echo a message")]
22-
fn echo(&self, #[tool(param)] message: String) -> String {
23-
message
28+
fn echo(&self, Parameters(object): Parameters<JsonObject>) -> Result<CallToolResult, McpError> {
29+
Ok(CallToolResult::success(vec![Content::text(
30+
serde_json::Value::Object(object).to_string(),
31+
)]))
2432
}
2533
}
2634

27-
#[tool(tool_box)]
28-
impl ServerHandler for Echo {
35+
#[tool_handler]
36+
impl rmcp::ServerHandler for Echo {
2937
fn get_info(&self) -> ServerInfo {
3038
ServerInfo {
3139
instructions: Some("A simple echo server".into()),

src/core.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub(crate) async fn connect_with_streamable(app_state: &AppState) -> Result<SseC
6565
uri: app_state.url.clone().into(),
6666
// we don't want the sdk to perform any retries
6767
retry_config: std::sync::Arc::new(rmcp::transport::common::client_side_sse::NeverRetry),
68+
auth_header: None,
6869
channel_buffer_capacity: 16,
6970
allow_stateless: true,
7071
},

tests/basic_test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
mod echo;
2+
use echo::Echo;
23
use rmcp::{
34
ServiceExt,
45
transport::{ConfigureCommandExt, SseServer, TokioChildProcess},
@@ -11,7 +12,7 @@ const TEST_SERVER_URL: &str = "http://localhost:8099/sse";
1112
async fn test_proxy_connects_to_real_server() -> anyhow::Result<()> {
1213
let ct = SseServer::serve(BIND_ADDRESS.parse()?)
1314
.await?
14-
.with_service(echo::Echo::default);
15+
.with_service_directly(Echo::new);
1516

1617
let transport = TokioChildProcess::new(
1718
tokio::process::Command::new("./target/debug/mcp-proxy").configure(|cmd| {

tests/echo/mod.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
use rmcp::{
2-
ServerHandler,
3-
model::{ServerCapabilities, ServerInfo},
4-
schemars, tool,
2+
ErrorData as McpError,
3+
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
4+
model::*,
5+
tool, tool_handler, tool_router,
56
};
7+
68
#[derive(Debug, Clone, Default)]
7-
pub struct Echo;
8-
#[tool(tool_box)]
9+
pub struct Echo {
10+
tool_router: ToolRouter<Echo>,
11+
}
12+
#[tool_router]
913
impl Echo {
14+
#[allow(dead_code)]
15+
pub fn new() -> Self {
16+
Self {
17+
tool_router: Self::tool_router(),
18+
}
19+
}
20+
1021
#[tool(description = "Echo a message")]
11-
fn echo(&self, #[tool(param)] message: String) -> String {
12-
message
22+
fn echo(&self, Parameters(object): Parameters<JsonObject>) -> Result<CallToolResult, McpError> {
23+
Ok(CallToolResult::success(vec![Content::text(
24+
serde_json::Value::Object(object).to_string(),
25+
)]))
1326
}
1427
}
1528

16-
#[tool(tool_box)]
17-
impl ServerHandler for Echo {
29+
#[tool_handler]
30+
impl rmcp::ServerHandler for Echo {
1831
fn get_info(&self) -> ServerInfo {
1932
ServerInfo {
2033
instructions: Some("A simple echo server".into()),

0 commit comments

Comments
 (0)