Commit 82f6f73
committed
fix: pipe stderr asynchronously to support Jupyter notebook environments
In Jupyter notebook environments, sys.stderr cannot reliably be used as
a subprocess file descriptor. This causes stdio_client to fail when
trying to start MCP servers from within Jupyter notebooks.
Changes:
- Always pipe stderr (subprocess.PIPE) instead of passing sys.stderr
directly to the subprocess
- Add async stderr_reader task that reads stderr output and forwards it
to the errlog stream (or ANSI-colored print output in Jupyter)
- Add _is_jupyter_notebook() helper to detect Jupyter environments via
isinstance check against ZMQInteractiveShell
- Remove errlog parameter from _create_platform_compatible_process and
create_windows_process since stderr is now always piped
- Update win32 utilities to always use subprocess.PIPE for stderr
Fixes #1561 parent 19fe9fa commit 82f6f73
3 files changed
Lines changed: 51 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
27 | 44 | | |
28 | 45 | | |
29 | 46 | | |
| |||
123 | 140 | | |
124 | 141 | | |
125 | 142 | | |
126 | | - | |
127 | 143 | | |
128 | 144 | | |
129 | 145 | | |
| |||
177 | 193 | | |
178 | 194 | | |
179 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
180 | 218 | | |
181 | 219 | | |
182 | 220 | | |
| 221 | + | |
183 | 222 | | |
184 | 223 | | |
185 | 224 | | |
| |||
230 | 269 | | |
231 | 270 | | |
232 | 271 | | |
233 | | - | |
234 | 272 | | |
235 | 273 | | |
236 | 274 | | |
237 | 275 | | |
238 | 276 | | |
239 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
240 | 282 | | |
241 | 283 | | |
242 | | - | |
| 284 | + | |
243 | 285 | | |
244 | 286 | | |
245 | 287 | | |
246 | 288 | | |
247 | | - | |
| 289 | + | |
248 | 290 | | |
249 | 291 | | |
250 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
0 commit comments