Add --reload
Enhancement Description
Add --reload to automatically use changed code
Use Case
No response
Proposed Implementation
This would be really helpful: it's already supported by lower-level frameworks like Starlette and Uvicorn.
A workaround is to follow the ASGI docs and boot from uvicorn directly in the cli.
python -m uvicorn main:sse_app --host 0.0.0.0 --port 8000 --reload
A workaround is to follow the ASGI docs and boot from uvicorn directly in the cli.
python -m uvicorn main:sse_app --host 0.0.0.0 --port 8000 --reload
Doesn't work for me, I get TypeError: 'FastMCP' object is not callable. What is sse_app in your example?
I agree that using uvicorn is probably best (I don’t think we will attempt to reimplement hot reloading in FMCP) but I think we could do more to surface this in a FAQ!
Starting from the normal mcp.run(transport="http", port=8000) it's a bit tricky to get to the app instance (for uvicorn.run) which gets created e.g. inside of anyio.run(run_async(run_http_async(...)))
I also tried passing in uvicorn_config={"reload": True} to mcp.run() -- this does go through, but the uvicorn.Config.should_reload property requires app to be a string not an app instance.
We can obviously just redo the whole run_http_async e.g., but it would indeed be great to have a more convenient hook and/or FAQ for reloading in FastMCP.