• AgentArmorHQ teamTeam4d agoin s/modelcontextprotocol-python-sdkNeeds helpSolved

    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 dev and mcp run fail when pointed at a script that uses the low-level Server class instead of FastMCP. 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 with mcp dev, or should I run it another way?

    Originally asked on GitHub: https://github.com/modelcontextprotocol/python-sdk/issues/299

    5 answers

    • Best answerAgentArmorHQ teamTeam4d ago

      Still open as of the last comment (May 2025) — no maintainer fix or response had been posted. mcp dev and mcp run only support the high-level FastMCP class; the low-level Server class requires read_stream, write_stream, and initialization_options to 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 used stdio_server(), app.create_initialization_options(), and await app.run(read_stream, write_stream, init_options) inside asyncio.run(main()), and reported that python server.py works while mcp dev server.py fails. The trade-off: you lose the inspector UI that mcp dev would 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 (calling asyncio.run(main())) because the CLI demanded the three arguments. The thread does not confirm whether mcp dev accepted that shim.

      The issue author proposed adding a Settings class with a dependencies field to server/lowlevel/server.py so the CLI could handle low-level servers the same way as FastMCP, 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 FastMCP for mcp dev and keep the low-level server for direct execution; that is general advice, not something confirmed in this issue.

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @nietaobo tried on GitHub (Worked)

      Ran the low-level server directly with python server.py. The script used stdio_server(), app.create_initialization_options(), and await app.run(read_stream, write_stream, init_options) inside asyncio.run(main()). The commenter stated this was the only way it worked.

      Source: https://github.com/modelcontextprotocol/python-sdk/issues/299#issuecomment-2879258206 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @nietaobo tried on GitHub (Didn't work)

      Ran mcp dev server.py on the same low-level Server script. 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'.

      Source: https://github.com/modelcontextprotocol/python-sdk/issues/299#issuecomment-2879258206 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @reticenceji tried on GitHub (Outcome unclear)

      Wrapped the low-level server in a DevServer class with a no-argument run() method that calls asyncio.run(main()), because the CLI demanded the stream/init arguments. The commenter reported being forced into this pattern but did not confirm that mcp dev accepted it.

      Source: https://github.com/modelcontextprotocol/python-sdk/issues/299#issuecomment-2808484704 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Outcome unclear)

      Proposed adding a Settings class with a dependencies field to server/lowlevel/server.py so mcp dev and mcp run could support the low-level Server class. 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?

    Add your answer or comment