Skip to content

Commit 1313534

Browse files
committed
refactor(transport): move which_command behind opt-in feature flag
Address review feedback: the `which` dependency is now gated behind a separate `which-command` feature flag instead of being bundled into `transport-child-process`. Users on Linux/macOS who don't need cross-platform executable resolution no longer pull in the extra crate. Also fixes the doc example import path to use the re-exported `rmcp::transport::which_command`.
1 parent 98ab478 commit 1313534

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

crates/rmcp/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ transport-child-process = [
136136
"transport-async-rw",
137137
"tokio/process",
138138
"dep:process-wrap",
139+
]
140+
which-command = [
141+
"transport-child-process",
139142
"dep:which",
140143
]
141144
transport-streamable-http-server = [

crates/rmcp/src/transport.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ pub use worker::WorkerTransport;
8383

8484
#[cfg(feature = "transport-child-process")]
8585
pub mod child_process;
86+
#[cfg(feature = "which-command")]
87+
pub use child_process::which_command;
8688
#[cfg(feature = "transport-child-process")]
87-
pub use child_process::{ConfigureCommandExt, TokioChildProcess, which_command};
89+
pub use child_process::{ConfigureCommandExt, TokioChildProcess};
8890

8991
#[cfg(feature = "transport-io")]
9092
pub mod io;

crates/rmcp/src/transport/child_process.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl ConfigureCommandExt for tokio::process::Command {
242242
///
243243
/// # Example
244244
/// ```rust,no_run
245-
/// use rmcp::transport::child_process::{which_command, ConfigureCommandExt};
245+
/// use rmcp::transport::{which_command, ConfigureCommandExt};
246246
///
247247
/// # fn example() -> std::io::Result<()> {
248248
/// let cmd = which_command("npx")?
@@ -252,6 +252,7 @@ impl ConfigureCommandExt for tokio::process::Command {
252252
/// # Ok(())
253253
/// # }
254254
/// ```
255+
#[cfg(feature = "which-command")]
255256
pub fn which_command(
256257
name: impl AsRef<std::ffi::OsStr>,
257258
) -> std::io::Result<tokio::process::Command> {
@@ -260,6 +261,7 @@ pub fn which_command(
260261
Ok(tokio::process::Command::new(resolved))
261262
}
262263

264+
#[cfg(feature = "which-command")]
263265
#[cfg(test)]
264266
mod tests_which {
265267
#[test]

0 commit comments

Comments
 (0)