# Agent Coherence — Stale Write Guard (FS)

An MCP server that blocks stale writes to shared workspace files like plan.md. It stops concurrent agents from silently clobbering each other's progress.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 12
- Author: cohexa-ai
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/cohexa-ai/agent-coherence
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/mcp/agent-coherence-stale-write-guard-fs

## What it does

When multiple agents edit the same `plan.md` or `memory.json`, silent overwrites happen. One worker reads a snapshot while another writes changes. The last write wins silently. This server blocks those updates and returns explicit conflict signals instead.

Under the hood, the server implements MESI-style artifact tracking and optimistic compare-and-swap via `write_cas`. Reads register the active version generation. If a teammate updates the file before your write arrives, the commit fails closed. Safety invariants are verified by nine formal TLA+ specifications.

Setup requires Python 3.11 or higher. The coordination logic runs on a single host only. It does not track external side effects like outgoing emails or webhooks.

## Requirements
- Needs: Python and uv (commands run via uvx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add stale-write-guard-fs -- uvx agent-coherence
```
uvx runs the command named after the package; if the README names another one, use uvx --from agent-coherence <command>

### Codex

**Platform CLI**
```bash
codex mcp add agent-coherence-stale-write-guard-fs -- uvx agent-coherence
```
uvx runs the command named after the package; if the README names another one, use uvx --from agent-coherence <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "agent-coherence-stale-write-guard-fs": {
            "command": "uvx",
            "args": [
                "agent-coherence"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from agent-coherence <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "agent-coherence-stale-write-guard-fs": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "agent-coherence"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from agent-coherence <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add agent-coherence-stale-write-guard-fs uvx agent-coherence
```
uvx runs the command named after the package; if the README names another one, use uvx --from agent-coherence <command>

## When to use it
- prevent silent overwrites on shared `plan.md` files
- reject outdated edits via optimistic commit-CAS
- coordinate concurrent agent file access on a single host
- guard against lost state updates in `memory.json`

## Example prompts
- Read `plan.md` through the stale write guard before updating tasks.
- Commit these updates to `memory.json` using optimistic concurrency.

## Similar
- [write-swift](https://affpapa.org/en/nevibecode/skills/write-swift.md) — skill · 119300 installs
- [cleaning-up-stale-feature-flags](https://affpapa.org/en/nevibecode/skills/cleaning-up-stale-feature-flags.md) — skill · 434 installs
- [session-guard](https://affpapa.org/en/nevibecode/skills/session-guard.md) — skill · 2800 installs
- [write-plan](https://affpapa.org/en/nevibecode/skills/write-plan.md) — skill · 524 installs
- [write-issue](https://affpapa.org/en/nevibecode/skills/write-issue.md) — skill · 405 installs
- [gws-docs-write](https://affpapa.org/en/nevibecode/skills/gws-docs-write.md) — skill · 50200 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
