Skip to content

Hot-reload server list on external edits to ~/.mcp-inspector/mcp.json #1345

@cliffhall

Description

@cliffhall

Background

#1343 ships the file-backed server list at ~/.mcp-inspector/mcp.json. The browser holds a stale list if the user edits the file by hand — they have to hit Refresh on the Servers screen (via the refresh() returned by useServers).

This issue: watch the file from the backend and push a change event to subscribed clients so the list updates automatically.

Sketch

  • Backend (core/mcp/remote/node/server.ts): watch mcpConfigPath; emit a change event on a new /api/servers/events SSE channel (or piggyback on the existing /api/mcp/events).
  • Frontend (core/react/useServers.ts): subscribe to the channel and re-fetch on event.

Risks

  • fs.watch semantics differ across OSes (macOS = FSEvents, Linux = inotify, Windows = ReadDirectoryChangesW). Editors that save via temp-file + rename (vim, most IDEs) produce ENOENT + new-inode sequences that bare fs.watch handles poorly. Likely want chokidar to smooth these over.
  • Debounce/coalesce: editor saves can fire 2–3 events; ~100–200ms debounce.
  • Re-entrancy: the backend's own POST/PUT/DELETE writes will trigger watch events. Either suppress self-fires by tracking last-written mtime, or accept the (harmless) extra refresh.

Out of scope

  • File watching of any path other than the active mcpConfigPath.

Metadata

Metadata

Assignees

Labels

v2Issues and PRs for v2

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions