Skip to content

Commit a1a486d

Browse files
authored
Merge pull request #455 from XiaofuHuang/xiaofhua/pid-StdioClientTransport
fix: Expose the MCP child process PID as an accessible property in StdioClientTransport
2 parents 7682c4c + 0db4407 commit a1a486d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/client/stdio.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ test("should read messages", async () => {
5959

6060
await client.close();
6161
});
62+
63+
test("should return child process pid", async () => {
64+
const client = new StdioClientTransport(serverParameters);
65+
66+
await client.start();
67+
expect(client.pid).not.toBeNull();
68+
await client.close();
69+
expect(client.pid).toBeNull();
70+
});

src/client/stdio.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ export class StdioClientTransport implements Transport {
185185
return this._process?.stderr ?? null;
186186
}
187187

188+
/**
189+
* The child process pid spawned by this transport.
190+
*
191+
* This is only available after the transport has been started.
192+
*/
193+
get pid(): number | null {
194+
return this._process?.pid ?? null;
195+
}
196+
188197
private processReadBuffer() {
189198
while (true) {
190199
try {

0 commit comments

Comments
 (0)