Title: feat: support stderr logging in Jupyter notebook environments by BabyChrist666 · Pull Request #2020 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: feat: support stderr logging in Jupyter notebook environments by BabyChrist666 · Pull Request #2020 · modelcontextprotocol/python-sdk
X Title: feat: support stderr logging in Jupyter notebook environments by BabyChrist666 · Pull Request #2020 · modelcontextprotocol/python-sdk
Description: Summary Fixes #156 In Jupyter notebook environments, passing sys.stderr directly to subprocess doesn't work as expected - the stderr output is lost and users have no visibility into server errors or crashes. This makes debugging extremely difficult as the notebook cell just hangs with no feedback. Changes Added _is_jupyter_environment() function to detect Jupyter/IPython notebook environments In Jupyter mode, stderr is captured as a pipe and read asynchronously Stderr output is printed with red ANSI color for visibility in notebooks In non-Jupyter environments, behavior remains completely unchanged (direct stderr passthrough) How It Works On client initialization, we detect if running in Jupyter/IPython If in Jupyter, we set capture_stderr=True which pipes stderr instead of redirecting An async stderr_reader task reads the pipe and prints to the notebook output Red ANSI coloring makes errors stand out in the notebook Technical Details Detection checks for IPKernelApp in config or ZMQInteractiveShell class name Falls back gracefully if IPython is not installed Windows compatibility maintained via FallbackProcess stderr wrapping Test plan Added TestJupyterStderrSupport test class with 4 tests Test Jupyter detection returns False in normal Python Test graceful handling when IPython not installed Test stderr capture doesn't block the client Test continuous stderr output is handled properly All existing stdio tests pass 🤖 Generated with Claude Code
Open Graph Description: Summary Fixes #156 In Jupyter notebook environments, passing sys.stderr directly to subprocess doesn't work as expected - the stderr output is lost and users have no visibility into server erro...
X Description: Summary Fixes #156 In Jupyter notebook environments, passing sys.stderr directly to subprocess doesn't work as expected - the stderr output is lost and users have no visibility into server ...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2020
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:55a40a8c-7297-7359-0ff5-6603784d5248 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E2F2:1580BD:24B2657:341DC00:6A58FDBB |
| html-safe-nonce | ef4aedd842b3e4a69decba7994162a9151886c2b168be0350a82c75f161dd1ac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkYyOjE1ODBCRDoyNEIyNjU3OjM0MURDMDA6NkE1OEZEQkIiLCJ2aXNpdG9yX2lkIjoiNzQyNTEzMTgzNTI0NzA5OTMyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6b1de7ec0a67821ae1fdd61c0f3a052c8a52e61cd56d8860f585ead89a0de3bd |
| hovercard-subject-tag | pull_request:3260762884 |
| 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/2020/files |
| twitter:image | https://avatars.githubusercontent.com/u/251679698?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/251679698?s=400&v=4 |
| og:image:alt | Summary Fixes #156 In Jupyter notebook environments, passing sys.stderr directly to subprocess doesn't work as expected - the stderr output is lost and users have no visibility into server erro... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9842457e8d7e3b2e1635a63af28da35614845510 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width