Skip to content

mcp-hmr: AsyncReloader initialized with empty watch path, breaking hot reload #59

@verveguy

Description

@verveguy

Problem

mcp-hmr initializes reactivity.hmr.core.AsyncReloader with an empty watch path (""):

  • packages/mcp-hmr/mcp_hmr.py: super().__init__("")

Depending on platform / watcher backend, watching "" results in:

  • no files being watched (hot reload silently does nothing), or
  • startup/runtime errors from the watcher about an invalid path.

Expected behavior

mcp-hmr <target>:<attr> should watch the server code directory by default so edits trigger reloads reliably.

Actual behavior

Hot reload does not reliably trigger on file changes unless users patch mcp_hmr.py locally (e.g., hardcode a watch directory).

Reproduction

  1. Install mcp-hmr==0.0.3.2
  2. Run:
    • mcp-hmr some.module:app (module target), or
    • mcp-hmr ./path/to/server.py:app (path target)
  3. Edit a file inside the target server package/module (e.g., change a tool response)
  4. Observe: no reload (or watcher error), requiring server restart.

Proposed fix

Derive a stable watch directory from the target:

  • path:attr → watch the parent directory of the file
  • module:attr → watch the directory containing the module/package on disk via find_spec()
  • fallback → cwd

PR

I have a PR ready that implements the above watch-path derivation #58

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions