-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
When using the Stdio transport, server processes don't terminate after requests complete. Each new request spawns another process, causing resource leaks.
We patched the vendor files with a cleanup routine that forcibly kills the subprocess:
Added getter to "/vendor/php-mcp/client/src/Client.php":
public function getTransport(): ?TransportInterface {
return $this->transport;
}
Added getter to "/vendor/php-mcp/client/src/Transport/Stdio/StdioClientTransport.php":
public function getProcess(): ?Process {
return $this->process;
}
Used SIGKILL in the finally block of our request wrapper:
finally {
if (isset($stdioClient)) {
$transport = $stdioClient->getTransport();
if ($transport instanceof \PhpMcp\Client\Transport\Stdio\StdioClientTransport) {
$process = $transport->getProcess();
if ($process && $process->isRunning()) {
$process->terminate(SIGKILL); // Forcibly terminate
}
}
$stdioClient->disconnect();
return $response;
}
}
Metadata
Metadata
Assignees
Labels
No labels