fix: cleanup zombie processes for child process client (#156)

* feat(client): cleanup of zombie processes in child process client

Using process wrap library, Process Group for Unix and Job Object for Windows

* fix: install extra dep based on feature, update examples take owned command

Install process-wrap if transport-child-process feature is enabled. Update examples to take ownership
of the command instead of mutable reference

* fix: update other examples, comments and readme to take ownership of command

Updated more examples, comments and readme to take command instead of mutable ref.
Also small fix in cargo toml of example to use local path.

* refactor: add configure command ext

Added configure command ext to tokio process command so that
you can use .configure() to use inline commands for mcp stdio client.
Added warning if start kill process fails
This commit is contained in:
Humberto Yusta Gómez 2025-05-18 12:38:47 +02:00 • committed by GitHub
commit 64995cc40c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,12 +17,12 @@ rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "mai
### 快速上手
一行代码启动客户端:
```rust
use rmcp::{ServiceExt, transport::TokioChildProcess};
use rmcp::{ServiceExt, transport::{TokioChildProcess, ConfigureCommandExt}};
use tokio::process::Command;
let client = ().serve(
TokioChildProcess::new(Command::new("npx").arg("-y").arg("@modelcontextprotocol/server-everything"))?
).await?;
let client = ().serve(TokioChildProcess::new(Command::new("npx").configure(|cmd| {
cmd.arg("-y").arg("@modelcontextprotocol/server-everything");
}))?).await?;
```
#### 1. 构建传输层
@ -63,7 +63,7 @@ let server = service.serve(transport).await?;
一旦服务初始化完成,你可以发送请求或通知:
```rust, ignore
// 请求
// 请求
let roots = server.list_roots().await?;
// 或发送通知