DEV Community

Cover image for Both writes said “success”. One was lost. Test your MCP server for it

Both writes said “success”. One was lost. Test your MCP server for it

Joshua Bryan on November 17, 2026

Two agents edit the same record through an MCP server. Both get "success" back. One of the changes is gone, and nothing in either result says so. ...
Collapse
 
chao_yan_0eca708448360655 profile image
Henry Yan •

The subtlety I would pin is the one you already named: a version check refuses a stale version, not stale content.

If the tool accepts a full-record replace, an agent that gets the new version from the conflict and resends the body it read earlier still wins, and the other writer's change is still gone. The write that must fail in the test is that second one, not only the first stale-version call.

I would also want the success result to show the fields that actually landed, or require a read of the current record as part of the same acceptance, so "success" cannot mean only that the server accepted a write.

Collapse
 
jsbry profile image
Joshua Bryan IsoKron •

Agreed, and that's the case our conflict study turned up. With a whole-list replace, an agent that took the new version from the conflict and resent the list it had read earlier overwrote the other writer's change: 38 of 48 runs under one trap, 0 of 48 once the error quoted the labels. So yes, the test has to judge that second write, not only the first stale one.

In MWS 0.9 that's MWS-CONC-3 rather than the version check: two concurrent writes to different parts of one object must not both report success when either change is absent afterwards, whatever versions they carried. A full-replace tool is judged by CONC-2 and CONC-3. A field-patch tool falls under MWS-UPD-1 (only the named fields change), which is the structural fix.

On your second point: the write-result shape has changed, JSON Pointers to the fields whose stored value the write actually changed. MWS-RES-4 asks for a receipt, and MWS-RES-1 allows success only when the state asked for is in effect. Whether acceptance should also require a read-back is a fair question for the comment window, if you'd like to file it: github.com/isokron-ai/mcp-write-sa...

Study: https://isokron.ai/research/mcp-conflict-errors-ai-agent?utm_source=devto&utm_medium=social&utm_campaign=mws-launch&utm_content=comment

Collapse
 
chao_yan_0eca708448360655 profile image
Henry Yan •

The 38-of-48 result is the measurement I would keep next to CONC-3. The second write is the one that has to fail, and quoting the labels is what actually changed the outcome.

On whether acceptance should also require a read-back: JSON Pointers name the paths whose stored value this write changed. They do not carry those values, and they do not, by themselves, show whether another writer's field is still present.

If the receipt only lists those pointers, or echoes paths from the request body, a "state asked for is in effect" check can still pass while the other change is already gone. CONC-3 has to look at the committed object, including fields this write did not name, not only at the versions the callers carried or the paths it reports.

A second client read is one way to observe that object. A server-built receipt could do the same if it is taken from storage and includes enough of the committed state to see an absent field — the pointers alone are not that proof.

Thread Thread
 
jsbry profile image
Joshua Bryan IsoKron •

Agreed, and that's how the test works: it doesn't trust the receipt. After each pair it reads both fields back with a separate read, and a loss is any case where both calls said success and one value isn't the one its writer sent. A receipt could stand in for that read only if it's built from storage and carries enough of the committed object to show a missing field. Pointers alone tell you where the write landed, not what's still standing. "The answer said so" is exactly how 38 of 48 got through.

Collapse
 
cianspider profile image
Cian •

The nastiest variant I hit was the test infra lying rather than the server. I ran forced collisions like you describe, and the runner that spawned the two agents got OOM killed on the second write. Exit 137. My summary said "no conflicts found" because the harness never distinguished a clean pass from a dead process. Worth adding to the CI recipe: assert the runner's own exit code and RSS ceiling before trusting a "no conflicts" result. A green run from a process the kernel reaped is worse than no run, it certifies the bug away. I run a small paid audit endpoint for this class of thing, so take that as disclosure, but the exit-code check is free either way.

Collapse
 
jsbry profile image
Joshua Bryan IsoKron •

Agreed, and it's nasty because the report looks clean. We hit a cousin of it: a test backend that died 20 seconds into a run, so the CLI finished with exit 0 and every later check came back "not tested". Nothing was violated, so nothing failed.

So the GitHub Action now fails the job, whatever fail-on says, when:

  • the CLI's exit status isn't one that means it ran to completion, so a kill like your 137 fails the job and the status shows in the summary;
  • the results file doesn't say the run reached complete, or the action can't read it;
  • the clean-up didn't finish (that's how the dead backend showed up).

"No violated records" only counts once all of those hold. Good call on the RSS ceiling; we don't check that, and it belongs in the CI recipe.

Collapse
 
beusebiu profile image
Eusebiu Balan •

A cousin of this hit my MCP writes through idempotency keys, not versions. I cached every write's result by its key, so when an agent completed a task, uncompleted it, and then retried the completion with the same key, it got the old "completed" back. Success, and the task stayed open.

Now only creates are cached. Toggles, updates and deletes always run.

Collapse
 
jsbry profile image
Joshua Bryan IsoKron •

Good catch, and I think the replay was right but the reading of it was wrong. Under MWS-RETRY-2, a repeat with the same key and the same arguments is applied at most once and answered with the first call's outcome. The piece most servers miss is saying that it's a replay. Our write-result shape has replayed: true for that: "this call applied nothing; the answer describes an earlier call." With that flag the agent can tell an old "completed" from a fresh one, and read the task before trusting its state.

One caution on caching only creates: a true toggle is where an uncached retry hurts most. If the first toggle landed and its answer was lost, the retry flips it back. Two ways out: make the tool set a state (completed: true) rather than toggle, so a repeat is harmless, or keep the key and mark replays. And completing again after reopening is a new intent, so it should carry a new key.

Right now the spec only has that replayed marker in its guidance, not as a requirement. If you think it should be a MUST, that's exactly the kind of comment we'd like: github.com/isokron-ai/mcp-write-sa...

Collapse
 
beusebiu profile image
Eusebiu Balan •

In mine complete and uncomplete are two separate tools, so there's no toggle to flip back. A retried completion that already landed just gets "Task is already completed" and nothing changes.

Thread Thread
 
jsbry profile image
Joshua Bryan IsoKron •

That's the cleanest fix. A tool that sets a state instead of flipping it can be repeated safely without any key, and "Task is already completed" tells the caller exactly where things stand.

The one case left is two agents racing, one completing and one uncompleting the same task: each call is safe on its own, and whichever lands last wins. If that matters for your users, a version on the call is what catches it.

Collapse
 
dpietro profile image
Denise Pietro •

What makes this particularly important is that concurrency failures in MCP servers aren't simply backend consistency problems; they're failures of communication between the tool and the agent. An agent can only make sound decisions based on the state the server truthfully reports, so returning a generic success after silently overwriting another writer's changes creates a dangerous illusion of correctness. I especially appreciate the distinction between rejecting a stale version and actually rebuilding a write from the latest state. Version checks alone aren't sufficient if an agent simply resubmits its outdated payload with an updated version number. The atomic compare-and-set approach is therefore essential, as is making conflict responses explicit, machine-readable, and actionable. The observation about ambiguous error formatting causing agents to misinterpret record contents is another valuable contribution because it demonstrates that even error messages are part of the system's safety architecture. I also like that the project distinguishes verified failures from untested requirements rather than presenting a misleading aggregate score. As MCP adoption accelerates and multiple agents increasingly operate on shared data, write correctness, idempotency, and truthful outcome reporting deserve the same engineering attention we already give authentication and authorization. This is exactly the kind of practical testing infrastructure the ecosystem needs to move from impressive agent demonstrations toward genuinely dependable production systems.

Collapse
 
jsbry profile image
Joshua Bryan IsoKron •

Thanks, Denise. "Illusion of correctness" is the right name for it: the server's answer is all the agent has to go on, so a wrong "success" costs more than an honest error. Keeping "failed" apart from "never tested" was deliberate. A score that averaged the two would look better and mean less.