This example demonstrates how to use mcp-hmr with a FastMCP server.
First, install the required dependencies and activate the venv:
uv sync
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`First, open the inspector with npx / pnpx / bunx, etc:
npx @modelcontextprotocol/inspector --config mcp.json --server mainClick the "Connect" button in the inspector UI. It will connect to the MCP server with mcp-hmr main.py:app.
Now you can view the resources and tools as normal. Then change them in main.py and save the file WITHOUT clicking "Restart" in the inspector. Any call to get the resource / run the tool will reflect the updated code.
mcp-inspector-demo.mov
Run the client to start and use the server:
python client.pyIt uses the MCP server defined in main.py. Now open your favorite editor and modify main.py to see the printing update in real-time!
- Try changing the
echotool's return value or thegreetresource's content. - You will see the client output update to reflect your changes without restarting the connection.
This demo shows how to use mcp-hmr to enable seamless hot reloading for MCP servers, maintaining the connection between client and server while updating the code on-the-fly.