Title: Fix child process kill error with npx based servers by surya-prakash-susarla · Pull Request #850 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Fix child process kill error with npx based servers by surya-prakash-susarla · Pull Request #850 · modelcontextprotocol/python-sdk
X Title: Fix child process kill error with npx based servers by surya-prakash-susarla · Pull Request #850 · modelcontextprotocol/python-sdk
Description: Motivation and Context When running npx based servers in stdio mode, the npx process spawns a sub-process. During exit, the main process does not propagate the SIGTERM to the child process which leads to a failed kill signal and the stdin & stdout of the root process getting mangled. The current change creates a new process group when launching the fork for the server and ensures that a kill signal is sent for the process group is the process does not shutdown cleanly. This would ensure that the process group (which includes all the child process) would be killed successfully to avoid any potential issues. How Has This Been Tested? Yes, a simple script like this: from fastmcp import Client import asyncio async def test(): config = { "mcpServers": { "everything": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-everything"] } } } async with Client(config) as client: tools = await client.list_tools() print("TOOlS: {tools}".format(tools=tools)) asyncio.run(test()) The above script will currently block the stdio of the parent server when run using as: python test.py After the change the npx root & the node child process die succesfully allowing the control to flow back to the parent process ensuring a clean shutdown. Breaking Changes No, this should not be a breaking change since the process group flag is ignored in non-POSIX systems, and the cleanup via process group functionality is only applied for POSIX style launches. Types of changes [ x ] Bug fix (non-breaking change which fixes an issue) New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist [ x ] I have read the MCP Documentation [ x ] My code follows the repository's style guidelines [ x ] New and existing tests pass locally [ x ] I have added appropriate error handling [ x ] I have added or updated documentation as needed Additional context Please refer to the issue here (slightly different context): #547
Open Graph Description: Motivation and Context When running npx based servers in stdio mode, the npx process spawns a sub-process. During exit, the main process does not propagate the SIGTERM to the child process which le...
X Description: Motivation and Context When running npx based servers in stdio mode, the npx process spawns a sub-process. During exit, the main process does not propagate the SIGTERM to the child process which le...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/850
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:36d74fc0-2b9c-760f-d6d2-0adbe76a970f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B62E:1515DC:1FB9FD:2C46C3:6A5A4447 |
| html-safe-nonce | ebde4651cccea6a9a37c79d08b8f8ba9f43595c2709216a8fec962c1f441b508 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjJFOjE1MTVEQzoxRkI5RkQ6MkM0NkMzOjZBNUE0NDQ3IiwidmlzaXRvcl9pZCI6IjEzMDcyODY2OTQwNDg0NDk2MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 144269376f0ebe762efcd019b5acbd2430daac72dcfd284e03837356c1a7235d |
| hovercard-subject-tag | pull_request:2554002785 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/850/files |
| twitter:image | https://avatars.githubusercontent.com/u/26598313?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/26598313?s=400&v=4 |
| og:image:alt | Motivation and Context When running npx based servers in stdio mode, the npx process spawns a sub-process. During exit, the main process does not propagate the SIGTERM to the child process which le... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | a793cd1fa898929111edad5857ee1f24ecf4bf7702525e67357cabc9df136fc3 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5aec27bb9c4f7ebe5fbbcd1533a5509e63a570a1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width