Skip to content

Publish LLM Advisor MCP data updates atomically #82

Description

@jamditis

Problem

Mutating LLM Advisor MCP calls rewrite shared JSON data directly. Concurrent calls can interleave read-modify-write cycles, and interruption during truncation can corrupt the live data used by later requests.

Evidence

  • mcp-servers/llm-advisor-data/index.js:56-66 loads shared JSON state.
  • mcp-servers/llm-advisor-data/index.js:268-319 handles mutating MCP calls with direct final-file writes and no serialized publication boundary.

Proposed work

Put data mutation behind one async transaction queue or lock. Re-read after acquiring ownership, validate the requested change and resulting schema, write a temporary file in the same directory, replace the live file atomically, and update in-memory state only after publication succeeds.

Acceptance criteria

  • Start with a failing test where concurrent mutating calls lose one update.
  • Concurrent mutations are serialized and both valid changes persist.
  • Interrupted writes leave the prior JSON readable.
  • Invalid resulting data is rejected before publication.
  • In-memory and on-disk state remain aligned after a failed write.
  • Callers receive success only after the replacement completes.

Non-goals

  • Changing LLM Advisor recommendations.
  • Moving the MCP data to a hosted database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2medium prioritybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions