Title: feat: support logging to stderr in Jupyter Notebook environments (#156) by dgenio · Pull Request #1707 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: feat: support logging to stderr in Jupyter Notebook environments (#156) by dgenio · Pull Request #1707 · modelcontextprotocol/python-sdk
X Title: feat: support logging to stderr in Jupyter Notebook environments (#156) by dgenio · Pull Request #1707 · modelcontextprotocol/python-sdk
Description: Summary Fixes #156 - Adds support for displaying stderr output in Jupyter Notebook environments. Changes Added Jupyter/IPython detection using IPython.get_ipython() Implemented async stderr reader that reads stderr asynchronously (similar to stdout) Added IPython display integration for colored stderr output in Jupyter notebooks Updated process creation to pipe stderr instead of redirecting (enables async reading) Updated Windows process creation and fallback to support piped stderr Updated FallbackProcess to wrap stderr in async-compatible streams Design Decisions Backward compatibility: errlog parameter is kept but behavior adapts based on environment Error handling: Non-critical errors are logged but don't stop execution Performance: Matches stdout_reader behavior (line-by-line buffering) Platform support: Works on both Unix and Windows (including fallback path) Testing Added comprehensive tests for stderr capture, Jupyter detection, and display integration All existing tests pass Linting and type checking pass Behavior In Jupyter: stderr is displayed using IPython's display system with red HTML formatting Outside Jupyter: stderr is printed to the provided errlog stream (defaults to sys.stderr) Fallback: If IPython display fails, falls back to regular print This enables proper debugging of MCP servers in Jupyter notebook environments, addressing the issue where server crashes or command errors were invisible.
Open Graph Description: Summary Fixes #156 - Adds support for displaying stderr output in Jupyter Notebook environments. Changes Added Jupyter/IPython detection using IPython.get_ipython() Implemented async stderr reader...
X Description: Summary Fixes #156 - Adds support for displaying stderr output in Jupyter Notebook environments. Changes Added Jupyter/IPython detection using IPython.get_ipython() Implemented async stderr reader...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/1707
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:88ebf2e9-e35c-c4ad-d189-1b443e278575 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BF3C:C57C7:8977D9:BA0244:6A5A85E7 |
| html-safe-nonce | dfe2e913441d6b77605392af92970f9f917d6e8b72848fcc35a5d2ea2f0eba1f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjNDOkM1N0M3Ojg5NzdEOTpCQTAyNDQ6NkE1QTg1RTciLCJ2aXNpdG9yX2lkIjoiNTA3NjY2ODQ1MjUxMTA1NzM4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 96acd7f569407be4568bbbadf413fb9685171404fc314b8956d12d902b0c4db8 |
| hovercard-subject-tag | pull_request:3056203239 |
| 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/1707/files |
| twitter:image | https://avatars.githubusercontent.com/u/12731907?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/12731907?s=400&v=4 |
| og:image:alt | Summary Fixes #156 - Adds support for displaying stderr output in Jupyter Notebook environments. Changes Added Jupyter/IPython detection using IPython.get_ipython() Implemented async stderr reader... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 922bdba685ea48400234d557977f0e32d9adbae6f5125725b4f48cacc6801106 |
| 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 | 7c8a44665d760d73ead7e85d8f88b299152aa681 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width