Merge pull request #455 from XiaofuHuang/xiaofhua/pid-StdioClientTransport
fix: Expose the MCP child process PID as an accessible property in StdioClientTransport
This commit is contained in:
commit
a1a486de1c
2 changed files with 18 additions and 0 deletions
|
|
@ -59,3 +59,12 @@ test("should read messages", async () => {
|
|||
|
||||
await client.close();
|
||||
});
|
||||
|
||||
test("should return child process pid", async () => {
|
||||
const client = new StdioClientTransport(serverParameters);
|
||||
|
||||
await client.start();
|
||||
expect(client.pid).not.toBeNull();
|
||||
await client.close();
|
||||
expect(client.pid).toBeNull();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -185,6 +185,15 @@ export class StdioClientTransport implements Transport {
|
|||
return this._process?.stderr ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The child process pid spawned by this transport.
|
||||
*
|
||||
* This is only available after the transport has been started.
|
||||
*/
|
||||
get pid(): number | null {
|
||||
return this._process?.pid ?? null;
|
||||
}
|
||||
|
||||
private processReadBuffer() {
|
||||
while (true) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue