Skip to content

Commit 5b532a1

Browse files
docs: note Windows OpenBLAS hang with stdio tool imports
Point server authors at pre-importing numpy/scipy/torch before mcp.run() on Windows stdio, and link the troubleshooting path people search when a tool call hangs with no error (#2832). Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 754254c commit 5b532a1

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎docs/run/index.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ Nothing prints, and it doesn't return. It is waiting on stdin for a host to spea
4141

4242
That also means stdout **is the wire**. While serving, the SDK moves the wire to a private descriptor and diverts output that is *flushed* to stdout (a subprocess writing to its inherited stdout, a flushed `print()`) to stderr, where it can't corrupt the stream. Output flushed to stdout *before* serving begins (a wrapper script echoing, an unbuffered import-time print) still lands on the wire, and so does a `print()` that stays buffered until the interpreter drains it at exit. For output you actually want, the `logging` module is the right tool: its handler flushes each record to stderr as it happens. That story is in **[Logging](../handlers/logging.md)**.
4343

44+
!!! tip "Windows: import heavy native libraries before `run()`"
45+
On Windows, a tool that **first-imports** an OpenBLAS-backed library (`numpy`,
46+
`scipy`, `torch`, …) over **stdio** can hang with no error and no log line.
47+
The stdio transport reads piped stdin on a background thread; that overlaps with
48+
DLL init under the Windows loader lock (the same family as
49+
[numpy#24290](https://github.com/numpy/numpy/issues/24290)). Import those
50+
libraries at module scope **before** `mcp.run()`, so the in-tool import is a
51+
cache hit. `streamable-http` is unaffected. Background:
52+
[python-sdk#2832](https://github.com/modelcontextprotocol/python-sdk/issues/2832).
53+
4454
### Try it
4555

4656
```console

‎docs/troubleshooting.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ mcp = MCPServer("Weather", request_state_security=RequestStateSecurity(keys=[key
421421

422422
* If a message the SDK produced is not on this page, that is a documentation bug worth reporting on its own.
423423
* Search the [issue tracker](https://github.com/modelcontextprotocol/python-sdk/issues); most error strings appearing there are already someone's write-up.
424+
* Tool call **hangs on Windows** over stdio with no traceback (often after a first `import numpy` / `scipy` / `torch` inside the tool): that is not an SDK exception — import those libraries at module scope before `mcp.run()`, or use `streamable-http`. See **[Running your server → stdio](run/index.md#stdio)** and [#2832](https://github.com/modelcontextprotocol/python-sdk/issues/2832).
424425
* Found nothing? [Open an issue](https://github.com/modelcontextprotocol/python-sdk/issues/new?template=v2-feedback.yaml) with the full traceback, or ask in [#python-sdk-dev on the MCP Contributors Discord](https://discord.gg/6CSzBmMkjX).
425426

426427
## Recap

0 commit comments

Comments
 (0)