mcp dev fails with 'Server.run() missing 3 required positional arguments' for low-level Server
In the modelcontextprotocol/python-sdk repo (as of early 2025),
mcp devandmcp runfail when pointed at a script that uses the low-levelServerclass instead ofFastMCP. The error is 'Failed to run server: Server.run() missing 3 required positional arguments: read_stream, write_stream, and initialization_options'. How can I test a low-level Server withmcp dev, or should I run it another way?Originally asked on GitHub: https://github.com/modelcontextprotocol/python-sdk/issues/299
5 answers
Still open as of the last comment (May 2025) — no maintainer fix or response had been posted.
mcp devandmcp runonly support the high-levelFastMCPclass; the low-levelServerclass requiresread_stream,write_stream, andinitialization_optionsto be passed explicitly, which the CLI does not do.The only confirmed workaround in the thread is to run the script directly instead of through
mcp dev. A commenter's test script usedstdio_server(),app.create_initialization_options(), andawait app.run(read_stream, write_stream, init_options)insideasyncio.run(main()), and reported thatpython server.pyworks whilemcp dev server.pyfails. The trade-off: you lose the inspector UI thatmcp devwould open at http://127.0.0.1:6274/.Another commenter reported having to wrap the low-level server in a shim class with a no-argument
run()method (callingasyncio.run(main())) because the CLI demanded the three arguments. The thread does not confirm whethermcp devaccepted that shim.The issue author proposed adding a
Settingsclass with adependenciesfield toserver/lowlevel/server.pyso the CLI could handle low-level servers the same way asFastMCP, but that remained a proposal.If you need the inspector UI, one option not discussed in the thread is to write your test script against
FastMCPformcp devand keep the low-level server for direct execution; that is general advice, not something confirmed in this issue.Did this work for you?What @nietaobo tried on GitHub (Worked)
Ran the low-level server directly with
python server.py. The script usedstdio_server(),app.create_initialization_options(), andawait app.run(read_stream, write_stream, init_options)insideasyncio.run(main()). The commenter stated this was the only way it worked.Did this work for you?What @nietaobo tried on GitHub (Didn't work)
Ran
mcp dev server.pyon the same low-levelServerscript. The inspector page at http://127.0.0.1:6274/ showed 'Failed to run server: Server.run() missing 3 required positional arguments: read_stream, write_stream, and initialization_options'.Did this work for you?What @reticenceji tried on GitHub (Outcome unclear)
Wrapped the low-level server in a
DevServerclass with a no-argumentrun()method that callsasyncio.run(main()), because the CLI demanded the stream/init arguments. The commenter reported being forced into this pattern but did not confirm thatmcp devaccepted it.Did this work for you?What a GitHub user tried on GitHub (Outcome unclear)
Proposed adding a
Settingsclass with adependenciesfield toserver/lowlevel/server.pysomcp devandmcp runcould support the low-levelServerclass. This was a design proposal seeking maintainer guidance; no decision was posted in the thread.Source: https://github.com/modelcontextprotocol/python-sdk/issues/299 (opens external site)
Did this work for you?
Related questions
- MCP python-sdk simple-chatbot: 'Attempted to exit cancel scope in a different task than it was entered in'
- Why is my MCP resource template (greeting://{name}) not available in Claude Desktop?
- How to disable TLS certificate verification (verify=False) in MCP streamablehttp_client?
- anyio.ClosedResourceError in MCP StreamableHTTP message router on fast-failing requests?
- Python MCP SDK streamable HTTP: 'Error in message router' ClosedResourceError after 307 redirect