effectfence
v0.3.0
Published
MCP server that stops agents double-firing side effects within one process. 1,000 racing duplicates, exactly one execution. In-memory and single-process by design — see Scope. No Rust toolchain required.
Maintainers
Readme
effectfence
MCP server that stops agents double-firing side effects. 1,000 racing duplicates, exactly one execution — proven on every commit.
Maintained by the people who run the public Retry-Safety Index — the register of which agent-payment implementations charge once when the answer is lost, and which charge twice. Seven teams have shipped fixes from our reports; the fastest took 4.3 hours.
Get your own code read — free · no payment, no account.
npx effectfence wrap -- npx -y your-mcp-serverNo Rust toolchain. No build step. No install-time downloads.
Try it in 10 seconds
npx -y effectfence demoNo install, no server of your own, no real call fired. Twelve agents reach for one $49 charge at once — you see it hit a built-in server raw (12 duplicate charges), then the same twelve behind the fence (exactly 1).
Prove your stack double-fires first
Don't take our word for it — check your own server. probe fires N byte-identical
calls at one tool concurrently (the twin-caller race) and counts distinct effects:
npx effectfence probe --tool charge_card --args '{"amount":4900}' --calls 12 -- npx -y your-mcp-server identical calls : 12
DISTINCT effects : 12
PROVEN DOUBLE-FIRE — 12 identical calls, 12 different results.Then re-run it through the fence and watch DISTINCT effects drop to 1:
npx effectfence probe --tool charge_card --args '{"amount":4900}' --calls 12 -- npx effectfence wrap -- npx -y your-mcp-serverThe footprints, then the lock — in two commands.
Wrap a server you already run (start here)
EffectFence stands in front of an existing MCP server and fences every tool call automatically — no changes to your agent, no remembering to call anything:
agent/client ──MCP──> effectfence wrap ──MCP──> your real tool serverThe tool list is mirrored 1:1 (same names, schemas, docs). What changes: identical duplicate calls — same tool, same arguments — execute the child once; later duplicates get the recorded result replayed instead of firing again.
One-paste recipe: fence a cluster-mutating server
The case this exists for — several agents holding kubectl on the same cluster.
Claude Code:
claude mcp add k8s-fenced -- npx -y effectfence wrap -- npx -y kubernetes-mcp-serverCursor (~/.cursor/mcp.json) or Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"k8s-fenced": {
"command": "npx",
"args": ["-y", "effectfence", "wrap", "--", "npx", "-y", "kubernetes-mcp-server"]
}
}
}Swap in whichever server holds your write-bearing tools — cloud APIs, deploy tooling, a payments server. Point every agent at the fenced name and remove access to the raw one; a fence only works if it is the only door.
See what it stopped
Call the fence_stats tool (no arguments) for live counters since the process
started:
effectfence since boot: admitted=1 replayed=995 refused(stale=0 race=4 in-flight=0 failed=0) total=1000 prevented=999prevented is every attempt that did not run the effect — the duplicate
executions that never happened.
Explicit fencing (without wrap)
If you want agents to fence deliberately instead — richer control via read_set,
parent, and known_clock — run the server bare and call fence_prepare /
fence_commit / fence_abort yourself:
{
"mcpServers": {
"effectfence": {
"command": "npx",
"args": ["-y", "effectfence"]
}
}
}What it does
An agent that retries a tool call after a timeout does not know whether the first attempt landed. The request reached the server, the work happened, the response never came back. Nothing failed loudly — it succeeded twice.
EffectFence sits in front of those effects. Identical intents are admitted once; every duplicate is fenced, replayed from the original result, or refused. The guarantee is enforced under real contention, not assumed:
- 1,000 racing duplicates → exactly one execution. Run
cargo run --release --example stormagainst the source and watch it yourself. - CI runs that storm on a fresh runner with no cache on every commit.
- Simultaneity is forced with a real barrier, not produced by spawning threads quickly and hoping the scheduler cooperates.
Scope — read this before you rely on it
This is an in-memory, single-process fence. Its state lives in this server process and is lost when the process restarts.
That is enough to close races and duplicates between concurrent threads, tasks and agents that share one running server. It is not enough for:
- Two instances of this server. Each has its own state, so the same intent can execute once per instance. A horizontally scaled or load-balanced deployment does not get exactly-once from this package.
- A restart mid-flight. State is not persisted. An intent admitted before a restart is unknown to the process that comes back.
- An agent that bypasses the fence. It protects effects routed through it; it cannot stop a caller that holds the credential and calls the provider directly. Deploy it at the one choke point your agents actually share.
If you need the guarantee to survive a restart or span processes, you need a
shared store behind it — see once-kernel
(Python, Postgres-backed, heartbeat leases and fence tokens) or
seal, which does cross-process
admission and confirms the result against the payment provider's own records.
We state this here rather than only in the source repo because the limit is the part you need before you deploy, not after.
Platforms
| Platform | Included |
|---|---|
| macOS Apple silicon (darwin-arm64) | yes |
| Linux x64 (linux-x64) | yes |
| Linux arm64 (linux-arm64) | yes |
| Windows x64 (win32-x64) | yes |
| macOS Intel (darwin-x64) | no — see below |
Every binary was built on its own native runner and made to answer an MCP
initialize on that platform before being published. None were cross-compiled.
Intel macOS is deliberately absent. GitHub retired the Intel runners, so the
only way to produce that binary would be cross-compiling it on Apple silicon —
shipping something that has never once executed. A missing download costs less
trust than a broken one. If you need it: cargo install effectfence.
Why this package is ~8 MB
It bundles all four platform binaries rather than downloading the right one after install. That is deliberate:
- No
postinstallscript. A tool whose entire job is guarding side effects should not fetch and execute code from the network while being installed. - Works with
--ignore-scripts, which is increasingly the default in CI. A download-on-install package silently produces a broken install there. - Works offline and air-gapped.
The cost is that you download three binaries you will not run. A future release
will split these into per-platform packages selected by optionalDependencies,
so you fetch only yours. Correctness first, then size.
Also available
- Rust crate —
effectfenceto embed the fence directly. once-kernel— the same exactly-once guarantee as a TypeScript library, zero dependencies, for when you want it inside your own code rather than as a separate MCP server.once-kernelon PyPI — the Python kernel. It shares a payload hash with the TypeScript one (RFC 8785), so a Python service and a Node service agree about whether an operation already ran.
Licence
MIT — same as the Rust crate this packages.
If this caught something
EffectFence stops the duplicate at the fence. It cannot tell you where else in your codebase the same mistake is waiting — that takes reading the path.
Free. Submit any client, facilitator, SDK or toolkit that moves money — yours or someone else's — and we read it and publish a verdict on the Retry-Safety Index at no cost. If we find something, you get the mechanism, the file and line, and a failing test. You are counted, never named, until you ship a fix; when you do, the row goes up with credit and your time-to-fix as the headline. → Submit for grading
Paid, and only this. A Retry-Safety Review: we read one money path end to end and return every finding tied to your own file and line numbers, each with its fix and a failing test in your own harness. Five working days, written only, no call. $1,200 — and no invoice if the path is clean, in which case you keep the report saying your guards hold. → Book it · the deliverable is specified up front so you can check the report you get against it.
