Skip to content

Commit e468ffd

Browse files
committed
fix: OS specific PID parsing
1 parent 304d711 commit e468ffd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

crates/mcp_client/src/client.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,16 @@ impl Client<StdioTransport> {
175175
command.args(args).spawn()?
176176
};
177177
let server_process_id = child.id().ok_or(ClientError::MissingProcessId)?;
178-
let server_process_id = Pid::from_raw(server_process_id.try_into().unwrap());
178+
179+
#[cfg(windows)]
180+
let server_process_id = Pid::from_raw(server_process_id); // On Windows, child.id() returns u32 which matches Pid::from_raw
181+
#[cfg(not(windows))]
182+
let server_process_id = Pid::from_raw(
183+
server_process_id
184+
.try_into()
185+
.map_err(|_err| ClientError::MissingProcessId)?,
186+
); // On Unix, safely convert u32 to i32
187+
179188
let server_process_id = Some(server_process_id);
180189
let transport = Arc::new(transport::stdio::JsonRpcStdioTransport::client(child)?);
181190
Ok(Self {

0 commit comments

Comments
 (0)