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.
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
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
Non-goals