Skip to content

MCP server hot-reload on config or cache changes #90

Description

@jpower432

Design Question

Should the MCP server reload its ResourceStore when complypack.yaml or the cache directory changes, and if so, what's the right implementation?

Context

The MCP server loads all artifacts, schemas, and resolved policies once at startup in NewServer and holds them in a read-only ResourceStore. Any change requires restarting the server and the MCP client session.

In Claude Code, the MCP server stays alive for the entire session. In a long session, a user may pull a new catalog version (complypack pull) or edit their config mid-conversation. Without hot-reload, picking up those changes means restarting the server and losing session context.

Config loading today is hand-rolled (os.ReadFile + yaml.Unmarshal in internal/config/). The project already uses Cobra but not Viper.

Options Considered

  • ViperWatchConfig() + OnConfigChange() gives file-watch and hot-reload with minimal custom code. Also handles XDG path resolution (relevant to Persistent OCI cache with XDG_CACHE_HOME support #88). Natural pairing with Cobra. Downside: Viper is a heavy dependency for what may be a narrow use case — it pulls in a large transitive tree.
  • fsnotify directly — lighter dependency, more control, but more code to maintain.
  • Manual reload command — MCP tool or signal-based (e.g. SIGHUP). No file watching complexity, user-initiated only.
  • Don't bother — restarts are fast, especially with a warm cache (Persistent OCI cache with XDG_CACHE_HOME support #88). Defer until someone actually hits this friction repeatedly.

Acceptance Criteria (if we proceed)

  • Config file changes trigger reload
  • Reload is atomic — no partial state served
  • Failed reload logs error and keeps serving old state
  • Connected MCP clients see updated resources after reload

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Fields

    No fields configured for Spike.

    Projects

    Status
    Ready 🚀

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions