tftsr-devops_investigation/src-tauri/src/mcp/transport/stdio.rs
Shaun Arman a779756e48
Some checks failed
PR Review Automation / review (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Successful in 1m46s
Test / frontend-typecheck (pull_request) Successful in 1m39s
Test / frontend-tests (pull_request) Successful in 1m39s
Test / rust-clippy (pull_request) Successful in 3m26s
Test / rust-tests (pull_request) Successful in 4m54s
style(mcp): apply rustfmt formatting
2026-05-23 16:48:26 -05:00

19 lines
626 B
Rust

use rmcp::transport::TokioChildProcess;
use std::path::Path;
use tokio::process::Command;
/// Build a stdio transport from a command path and argument list.
/// Rejects relative paths to prevent path traversal.
pub fn build_stdio_transport(command: &str, args: &[String]) -> Result<TokioChildProcess, String> {
if !Path::new(command).is_absolute() {
return Err(format!(
"stdio command must be an absolute path, got: {command}"
));
}
let mut cmd = Command::new(command);
cmd.args(args);
TokioChildProcess::new(cmd).map_err(|e| format!("Failed to spawn stdio process: {e}"))
}