Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Wait for buffered stdout/stderr before reading MCP execution results (#8577)

Trevor Manzf2a096f08441
diff --git a/marimo/_mcp/code_server/main.py b/marimo/_mcp/code_server/main.py
index 3ad63e4f64..635958c8ea 100644
--- a/marimo/_mcp/code_server/main.py
+++ b/marimo/_mcp/code_server/main.py
@@ -193,6 +193,12 @@ def setup_code_mcp_server(
# Wait for the scratch cell to become idle
await asyncio.wait_for(done.wait(), timeout=_EXECUTION_TIMEOUT)
+
+ # FIXME: stdout/stderr are flushed every 10ms by the buffered
+ # writer thread. Wait 50ms so trailing console output arrives
+ # before we read cell_notifications.
+ # See: marimo-team/marimo-lsp ExecutionRegistry.ts
+ await asyncio.sleep(0.05)
except asyncio.TimeoutError:
return CodeExecutionResult(
success=False,