Skip to content

Commit 40be9d3

Browse files
committed
fix(stdio): flush sys.stdout before restoring fd 1 in stdio_server (#3821)
1 parent 77001c9 commit 40be9d3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎src/mcp/server/stdio.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ async def stdout_writer():
212212
yield read_stream, write_stream
213213
finally:
214214
if restore_stdout is not None:
215+
with suppress(OSError, ValueError):
216+
sys.stdout.flush()
215217
restore_stdout()
216218
if restore_stdin is not None:
217219
restore_stdin()

0 commit comments

Comments
 (0)