Skip to content

Commit 9262657

Browse files
committed
only install extra dep if feature is on, update examples to take command entirely
1 parent e8e92f6 commit 9262657

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

crates/rmcp/Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ serde_json = "1.0"
1818
thiserror = "2"
1919
chrono = { version = "0.4.38", features = ["serde"] }
2020
tokio = { version = "1", features = ["sync", "macros", "rt", "time"] }
21-
process-wrap = { version = "8.2", features = ["tokio1"] }
2221
futures = "0.3"
2322
tracing = { version = "0.1" }
2423
tokio-util = { version = "0.7" }
@@ -46,6 +45,8 @@ url = { version = "2.4", optional = true }
4645
# For tower compatibility
4746
tower-service = { version = "0.3", optional = true }
4847

48+
# for child process transport
49+
process-wrap = { version = "8.2", features = ["tokio1"], optional = true}
4950

5051
# for ws transport
5152
# tokio-tungstenite ={ version = "0.26", optional = true }
@@ -66,7 +67,11 @@ macros = ["dep:rmcp-macros", "dep:paste"]
6667
transport-sse = ["dep:reqwest", "dep:sse-stream", "dep:url"]
6768
transport-async-rw = ["tokio/io-util", "tokio-util/codec"]
6869
transport-io = ["transport-async-rw", "tokio/io-std"]
69-
transport-child-process = ["transport-async-rw", "tokio/process"]
70+
transport-child-process = [
71+
"transport-async-rw",
72+
"tokio/process",
73+
"dep:process-wrap",
74+
]
7075
transport-sse-server = [
7176
"transport-async-rw",
7277
"dep:axum",

crates/rmcp/tests/test_with_js.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ async fn test_with_js_server() -> anyhow::Result<()> {
5353
.spawn()?
5454
.wait()
5555
.await?;
56-
let transport = TokioChildProcess::new(
57-
tokio::process::Command::new("node").arg("tests/test_with_js/server.js"),
58-
)?;
56+
let mut cmd = tokio::process::Command::new("node");
57+
cmd.arg("tests/test_with_js/server.js");
58+
let transport = TokioChildProcess::new(cmd)?;
5959

6060
let client = ().serve(transport).await?;
6161
let resources = client.list_all_resources().await?;

crates/rmcp/tests/test_with_python.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ async fn test_with_python_server() -> anyhow::Result<()> {
5454
.spawn()?
5555
.wait()
5656
.await?;
57-
let transport = TokioChildProcess::new(
58-
tokio::process::Command::new("uv")
59-
.arg("run")
60-
.arg("tests/test_with_python/server.py"),
61-
)?;
57+
let mut cmd = tokio::process::Command::new("uv");
58+
cmd.arg("run");
59+
cmd.arg("tests/test_with_python/server.py");
60+
let transport = TokioChildProcess::new(cmd)?;
6261

6362
let client = ().serve(transport).await?;
6463
let resources = client.list_all_resources().await?;

examples/clients/src/collection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ async fn main() -> Result<()> {
1818

1919
let mut client_list = HashMap::new();
2020
for idx in 0..10 {
21+
let mut cmd = Command::new("uvx");
22+
cmd.arg("mcp-client-git");
2123
let service = ()
2224
.into_dyn()
23-
.serve(TokioChildProcess::new(
24-
Command::new("uvx").arg("mcp-server-git"),
25-
)?)
25+
.serve(TokioChildProcess::new(cmd)?)
2626
.await?;
2727
client_list.insert(idx, service);
2828
}

examples/clients/src/everything_stdio.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ async fn main() -> Result<()> {
2020
.init();
2121

2222
// Start server
23-
let service = ()
24-
.serve(TokioChildProcess::new(
25-
Command::new("npx")
26-
.arg("-y")
27-
.arg("@modelcontextprotocol/server-everything"),
28-
)?)
29-
.await?;
23+
let mut cmd = Command::new("npx");
24+
cmd.arg("-y");
25+
cmd.arg("@modelcontextprotocol/server-everything");
26+
let service = ().serve(TokioChildProcess::new(cmd)?).await?;
3027

3128
// Initialize
3229
let server_info = service.peer_info();

examples/clients/src/std_io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ async fn main() -> Result<()> {
1313
)
1414
.with(tracing_subscriber::fmt::layer())
1515
.init();
16+
let mut cmd = Command::new("uvx");
17+
cmd.arg("mcp-server-git");
1618
let service = ()
17-
.serve(TokioChildProcess::new(
18-
Command::new("uvx").arg("mcp-server-git"),
19-
)?)
19+
.serve(TokioChildProcess::new(cmd)?)
2020
.await?;
2121

2222
// or

examples/rig-integration/src/config/mcp.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,11 @@ impl McpServerTransportConfig {
6969
args,
7070
envs,
7171
} => {
72-
let transport = rmcp::transport::TokioChildProcess::new(
73-
tokio::process::Command::new(command)
74-
.args(args)
75-
.envs(envs)
76-
.stderr(Stdio::null()),
77-
)?;
72+
let mut cmd = tokio::process::Command::new(command);
73+
cmd.args(args);
74+
cmd.envs(envs);
75+
cmd.stderr(Stdio::null());
76+
let transport = rmcp::transport::TokioChildProcess::new(cmd)?;
7877
().serve(transport).await?
7978
}
8079
};

0 commit comments

Comments
 (0)