Get the FREE Ultimate OpenClaw Setup Guide →

hmr

Real hot-module reload for Python—side effects handled reactively. https://py3.online/hmr

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio promplate-hmr python -m mcp_hmr \
  --env MCP_HOST="0.0.0.0" \
  --env MCP_PORT="25577" \
  --env HMRC_PATH="path/to/your/mcp/config" \
  --env LOG_LEVEL="INFO"

How to use

This MCP server integrates the HMR (Hot Module Reload) workflow into your MCP environment. It leverages the HMR runtime to reload only the modules that have changed, preserving state and avoiding full connection drops whenever possible. The server exposes an MCP-compatible interface, so clients and other MCP components can interact with it as you would with a regular MCP server, but with the added benefit of on-the-fly code updates during development.

To use it, install the HMR-enabled MCP package and start the server using the included entry point. The server will monitor Python module changes and trigger targeted reloads of affected MCP modules or handlers. You can customize host/port and logging via environment variables, making it suitable for local development or integration into your CI workflow. Typical workflows involve editing MCP-related handlers, services, or scripts, then saving changes to observe instant behavior updates without disconnecting active clients.

How to install

Prerequisites:

  • Python 3.8+ (recommended 3.10+)
  • Basic MCP server familiarity

Install the MCP HMR package and the MCP server package that provides the entry point:

# Install the HMR-enabled MCP package (adjust as needed for your environment)
pip install mcp-hmr
# If you have a separate MCP server package, install it similarly
# Example (if separate package exists):
pip install promplate-mcp-hmr

Run the MCP server with HMR enabled:

# Start the MCP server using the HMR entry point
hmr path/to/your/mcp-entry-script.py
# Or, explicitly via Python module if using -m entry point
python -m mcp_hmr

If you prefer to route through uvicorn-like tooling or a dockerized setup, adjust the command accordingly to your environment. Ensure your MCP server entry points to the appropriate MCP modules (e.g., handlers, services) that should benefit from hot-reloading.

Additional notes

Tips and common considerations:

  • Environment variables: Set MCP_HOST and MCP_PORT to match your network and firewall rules. Use a development port (e.g., 25577) to avoid conflicts with production MCP servers.
  • State preservation: HMR aims to preserve runtime state. If you encounter a rare state inconsistency after a reload, try triggering a full restart to ensure a clean baseline.
  • File types watched: HMR tracks Python module changes and can extend to non-Python assets (config files, JSON, YAML) depending on your setup. Keep non-Python assets in a predictable import path if you rely on reactive reloads.
  • Debug logging: Increase LOG_LEVEL to DEBUG when diagnosing reload behavior. This helps understand which modules were reloaded and why.
  • Compatibility: While HMR supports many Python patterns (lazy imports, getattr in modules, decorators), extremely dynamic import schemes may require manual validation after reloads.
  • MCP-specific concerns: When integrating with MCP clients, ensure that client sessions tolerate hot-reloads gracefully and that connection handling remains robust during module changes.

Related MCP Servers

Sponsor this space

Reach thousands of developers