◉CLAUDE LABJP
●CC 2.1.330 — Claude Code 2.1.330 fixes the multi-minute freeze right after compacting a long conversation●SONNET 4.5 — Sonnet 4.5 retires from the Claude API on 11/30, 8 days left. The suggested replacement is claude-sonnet-5-5●MCP 401 — Users report MCP servers that return 401 time out silently instead of showing an error●NEW — New: Desktop creates a worktree for every session? Three places to check●OPUS 4.5 — The 11/24 date for Opus 4.5 is a not-sooner-than floor, not a retirement notice●SCHEMA — Same schema, different shape: compare structured output from the Agent SDK and the Messages API●CC 2.1.330 — Claude Code 2.1.330 fixes the multi-minute freeze right after compacting a long conversation●SONNET 4.5 — Sonnet 4.5 retires from the Claude API on 11/30, 8 days left. The suggested replacement is claude-sonnet-5-5●MCP 401 — Users report MCP servers that return 401 time out silently instead of showing an error●NEW — New: Desktop creates a worktree for every session? Three places to check●OPUS 4.5 — The 11/24 date for Opus 4.5 is a not-sooner-than floor, not a retirement notice●SCHEMA — Same schema, different shape: compare structured output from the Agent SDK and the Messages API
Articles/API & SDK
⬡ API & SDK/2026-06-28Advanced

Did That Post Actually Go Through? Safely Retrying an Interrupted MCP Write Without Double-Executing

When an MCP write tool call is interrupted by a dropped connection, you can't tell whether the server ran it. Here's why naive retries cause double-execution, and a working wrapper that uses idempotency keys and a reconcile read to retry safely — with examples from an unattended pipeline.

Claude API148MCP63idempotency6automation110reliability18

✦ Premium Article

One of my unattended publishing jobs once got its connection cut mid-request while posting to X. All I got back was a timeout error, with no way to know whether the post had landed. The log recorded a "failure" — yet a few minutes later the same post was sitting on the timeline. The server had succeeded; only the result never reached me.

If I had naively decided "it failed, so retry," two identical posts would have ended up side by side. As an indie developer automating announcements across several sites, that is an incident that has nothing to do with content quality. To a reader, posting the same thing twice just signals sloppy operations. If you are going to run write-type tool calls unattended, you have to design for this "did it go through?" state head-on.

"Failed" and "uncertain" are not the same thing

There are two kinds of errors. One is a clear rejection — the server says "I will not accept your request." The other is unknown — the connection dropped before any response came back. The first is safe to retry, because you know the server did nothing.

The troublesome one is the second. The request may have reached the server and been processed, or it may have been cut off before arrival. From your side, you cannot tell. This is the well-known problem in distributed systems: the sender can never be certain the receiver executed. Timeouts, connection resets, and mid-stream disconnects all belong in this "uncertain" bucket.

The June 27, 2026 update improved MCP resilience in Claude Code so that partial responses are preserved even when a stream is cut mid-flight. The receiving side is genuinely more robust now. Even so, the uncertainty that remains the moment a write tool call is interrupted — "did the server execute it?" — is not something a more resilient receiver alone can remove. That part lives in your application.

A common implementation trap is error classification. An HTTP 5xx can mean "the server failed to process" or "it processed but only the response was lost," so pushing it straight to failed is dangerous. I treat every ambiguous error as uncertain. Since uncertain operations are settled by reconciliation during recovery, over-classifying as uncertain never causes double-execution — whereas mislabeling a truly uncertain call as failed leads to it immediately. When in doubt, fall to the safe side: uncertain.

Why naive retries cause double-execution

When people write retry logic, they usually think in two states: success or failure, and retry on failure. That design is the breeding ground for double-execution.

If you collapse "uncertain" into "failed," you re-run even the cases that actually succeeded on the server. A post becomes a double post, a charge becomes a double charge, an email becomes a second copy. That is exactly the trap I fell into first: I wrapped my retry logic in a sloppy except Exception: and unconditionally resent inside it. It never reproduced in testing, and the first double post showed up on a night when the production connection got flaky.

The correct approach splits state into three: committed, failed, and uncertain. Only failed is safe to retry directly. For uncertain, you always insert one extra step — "check before you redo."

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦A three-state ledger that treats a dropped connection as 'uncertain' rather than 'failed', and why two states break down
✦A Python wrapper that protects MCP tools without idempotency support, using a correlation token and a reconcile read
✦A table for deciding when retrying is safe and when it isn't, weighed by the cost of a duplicate vs the cost of a miss
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⬡ API & SDK2026-05-15
Automating Wallpaper Classification with Claude Vision API — Accuracy, Cost, and a Batch Job That Survives Interruptions
A firsthand account of automating wallpaper category classification with the Claude Vision API. Honest numbers on accuracy and cost, plus the batch design that stopped me re-paying for the same images.
⬡ API & SDK2026-11-18
Before Your Customers Pay Through Linked Billing: Reading a 402 or 403 to Find Whose Wallet Is Empty
Linked billing, released in beta on November 17, lets you choose who pays on every Claude API request through billing_policy. When a request billed to a customer comes back as a 402 or 403, here is how I work out which wallet is the cause, when to pay for it myself, and a small Python wrapper that keeps that decision in one place.
⬡ API & SDK2026-11-17
If You Rely on Claude's Text Watermark, Check temperature in the Request Body, Not Your Code
Since November 16, text from Opus 4.6, Opus 4.5, Sonnet 4.5, and Haiku 4.5 carries Anthropic's text watermark, but non-default temperature, top_p, or top_k may drop it. Here is how I log the request body once and decide.