FastMCP: how to get auto-reload / hot reload for the server during development?
I'm developing a FastMCP (PrefectHQ/fastmcp) server and want code changes to be picked up automatically while it's running. Does FastMCP support auto-reload? A feature request for
--reloadwas closed as completed, and comments suggest running Uvicorn directly, butpython -m uvicorn main:sse_app --host 0.0.0.0 --port 8000 --reloadfails for me withTypeError: 'FastMCP' object is not callable.Originally asked on GitHub: https://github.com/PrefectHQ/fastmcp/issues/616
4 answers
Status: explained. This issue asked FastMCP for a
--reloadoption and was closed as completed. In the discussion, a maintainer said running Uvicorn is probably best, and that they don't think hot reloading will be reimplemented inside FastMCP itself.The workaround from the thread is to skip
mcp.run()and boot Uvicorn directly with the ASGI app, per the FastMCP ASGI docs (see https://gofastmcp.com/deployment/asgi (opens external site)):bashpython -m uvicorn main:sse_app --host 0.0.0.0 --port 8000 --reloadsse_appmust be the ASGI app exposed from your module, not theFastMCPinstance itself. One user tried this exact command and gotTypeError: 'FastMCP' object is not callable, then asked whatsse_appshould be, so double-check what your module exports.Passing
uvicorn_config={"reload": True}tomcp.run()was also tried and did not work: the option goes through, but Uvicorn'sConfig.should_reloadrequires the app to be a string, while FastMCP passes an app instance. The same commenter noted that getting to the app instance insideanyio.run(run_async(run_http_async(...)))is tricky, and that rewritingrun_http_asyncis possible but they'd prefer a proper hook or FAQ entry.As general advice, keep your FastMCP app in its own module (e.g.
main.py) so themain:sse_appimport string works with Uvicorn's reload mode. Also as general advice:--host 0.0.0.0binds all network interfaces; use127.0.0.1for local-only development.Did this work for you?What @Zambonilli tried on GitHub (Outcome unclear)
Suggested running the server through Uvicorn directly per the FastMCP ASGI docs:
python -m uvicorn main:sse_app --host 0.0.0.0 --port 8000 --reload.Source: https://github.com/PrefectHQ/fastmcp/issues/616#issuecomment-2956748514 (opens external site)
Did this work for you?What @bojanbg tried on GitHub (Didn't work)
Ran the suggested Uvicorn command but got
TypeError: 'FastMCP' object is not callableand asked whatsse_apprefers to.Source: https://github.com/PrefectHQ/fastmcp/issues/616#issuecomment-3118421726 (opens external site)
Did this work for you?What @cpbotha tried on GitHub (Didn't work)
Tried
mcp.run(transport="http", port=8000)withuvicorn_config={"reload": True}. The option was accepted, but Uvicorn'sConfig.should_reloadrequires the app to be a string, while FastMCP passes an app instance.Source: https://github.com/PrefectHQ/fastmcp/issues/616#issuecomment-3410128742 (opens external site)
Did this work for you?
Related questions
- How do I expose existing FastAPI endpoints as MCP tools with FastMCP 2?
- How to access HTTP headers from SSE requests in a fastmcp MCP server?
- Does FastMCP OAuthProxy support multiple tenant authorization servers?
- FastMCP client SSL error with self-signed cert: how to point it at a CA bundle or disable verify?
- FastMCP KeycloakAuthProvider: Keycloak 26.6.x requirement and MCP Inspector OAuth fix