IamBishal

The Unhappy Path: A Production MCP Server's Failure Path, Measured

My production-MCP article says its snippets haven't been run. So I built its running example six ways and broke it on purpose.

The article's ticketing MCP server, built as a quickstart, as a production server and as four single-practice ablations, with one failure injected per task. 864 episodes on Claude Haiku and Sonnet: production finished every task, the quickstart 43% and 89%.

tasks done: production vs quickstart (Haiku)
100% vs 43%
notes duplicated after an opaque write error
12 / 12
duplicates without keys, when the error was honest
0
Haiku quickstart tasks reported done that weren't
33
  • Experiment
  • 7 min read
  • AI Agents
  • Evals & AgentOps
  • Python
  • Claude
  • MCP
  • Error handling
Figure 1. Tasks completed by server and failure mode

Overview

In "Build a Production MCP Server" I argued that a quickstart server passes the inspector and fails in front of a real agent, on the failure path: errors the model can't act on, free-string parameters it guesses at, lists it can't tell are truncated, and writes it may repeat after a dropped response. The article's snippets were illustrative and never run.

So I built its running example, an MCP server over a ticketing API with search, get and add-comment, on Kestrel Outfitters' 300 support tickets. There are six real servers on the Python SDK: a quickstart, a production server, and four versions of production with one practice removed each: actionable errors, a strict schema, totals and cursors, and idempotency keys.

Twenty-four tasks each inject one failure from the article's table: a ticket id that doesn't exist, a question in plain words whose filter values are the API's own, a count over more than one page, a write that lands and then times out, a temporary failure, and a ticket locked against comments. Grading reads the API's comment store, the call log and the agent's final answer. 864 episodes cost USD 3.04.

The pilot caught two flaws of my own: an ambiguous prompt, and tickets that didn't show their comments, so an agent couldn't check whether a write had landed. Both were fixed, tested and disclosed.

The production server finished every task on both models; the quickstart finished 43% on Haiku and 89% on Sonnet. Each practice prevented a specific failure, mostly for the weaker model. The surprise was idempotency: without keys there were no duplicates at all, because an honest error and a readable ticket made both models check first.

Did it hold up?

Full results

The hypothesis, written down before the first run, and what the results said.

  1. Confirmed

    The production server beats the quickstart across the six failure modes.

    100% on both models, against 43% (Haiku) and 89% (Sonnet) on the quickstart.

  2. Partly

    Actionable errors drive recovery on not-found, transient and permission failures.

    They stopped retries on locked tickets; agents recovered from not-found and transient failures even behind "Request failed."

  3. Partly

    Strict schemas stop silent wrong answers from invented enum values.

    Free strings drew invented values from both models; Haiku reported the empty result as fact, Sonnet explored and recovered.

  4. Partly

    Without a total, the model treats a truncated list as complete.

    Haiku answered 20 on 11 of 12 quickstart counts; Sonnet split its queries and counted correctly.

  5. Partly

    Without idempotency, a dropped write produces duplicates.

    Only behind an opaque error (Haiku 12/12). With an honest message and a readable ticket, 0 duplicates without keys.

  6. Confirmed

    A permission error isn't retried when the message says so; an opaque one is.

    One attempt in 96 of 96 episodes when told; two or three after "Request failed."

What it does

  • The article's own running example: an MCP server over a ticketing API
  • Six real MCP servers on the Python SDK, differing only on the failure path
  • Four single-practice ablations to attribute each effect
  • 24 tasks with one deterministic failure each, from the article's failure table
  • Grading from the API's comment store, the call log and a structured final answer
  • Invented filter values, truncated counts and duplicate writes counted directly
  • A literal-minded fake that proves each ablation breaks exactly its own mode
  • A hard spending cap checked before every model call

How it's built

  1. Inputs

    • Ticketing API300 tickets, fault injector
    • 24 tasksOne failure each
  2. Six MCP servers

    • Quickstart
    • Production
    • No actionable errors
    • No strict schema
    • No totals; no keys
  3. Outputs

    • Episodes864, graded in code
    • Failure countsDuplicates, silent wrongs
    • Recovery pathsWhat the agent did next
servers.py
# servers.py: the dropped write, as each server presents it.
@server.tool(description=COMMENT_DOC)
def add_ticket_comment(ticket_id: TicketId, body: str, internal: bool = True) -> str:
    args = {"ticket_id": ticket_id, "body": body, "internal": internal}
    # production: the server derives the key, so the model can't forge or drop it
    key = hashlib.sha256(f"{ticket_id.upper()}\n{body}".encode()).hexdigest()[:16] if cfg["keys"] else None
    try:
        c = api.add_comment(ticket_id, body, internal=internal, key=key)
    except Forbidden:
        fail(..., "forbidden", f"Not allowed to comment on {ticket_id}: the ticket is locked for a legal hold. "
                               "Retrying won't help; tell the user.")
    except Timeout:  # the write landed; the response never arrived
        fail(..., "write_timeout",
             "Comment unconfirmed: the ticketing API timed out after receiving it. Resending the same "
             "ticket_id and body is safe; it will not be posted twice." if cfg["keys"] else
             "Comment unconfirmed: the ticketing API timed out. The comment may or may not have been posted.")
    return f"Comment added to {c.ticket_id}."

def fail(tool, args, kind, actionable_text):
    raise ToolError(actionable_text if cfg["actionable"] else "Request failed.")   # the quickstart's error

Figures

Figure 1. Tasks completed by server and failure mode1 of 2

What I learned

  • A quickstart's worst failures look like success: Haiku reported 33 tasks as done that weren't, from undercounts to duplicated notes.
  • Say how many results there are. Without a total Haiku reported the 20-ticket page as the answer; Sonnet split its queries to work around it.
  • Free strings draw invented values from every model. Strict enums stopped them entirely; without them Haiku reported zero closed critical tickets, three times out of three.
  • Tell the model when a refusal is final. Told retrying won't help, both models stopped after one attempt every time.
  • An honest error plus readable state prevented duplicates without idempotency keys; an opaque error made Haiku duplicate 12 times out of 12.
  • Stronger models paper over weak servers; production practices raised both to 100% and closed the gap.
  • Pilot your harness: my first prompt was ambiguous, and my tickets hid the comments an agent needed to check its own write.

Next steps

  • Writes that can't be read back (an email, a payment), where only keys prevent duplicates
  • Tasks that combine failures, such as a not-found ticket followed by a dropped write
  • Free-string schemas that list the values in the description
  • Other model families, and the TypeScript SDK

Run it yourself

Everything on this page comes from code and data in the repository. The dry run is free and needs no API key. A full live rerun costs about USD 3.

Terminal
git clone https://github.com/bishal-saha/ai-lab-code.git
cd ai-lab-code/mcp-failure-path-benchmark
uv sync
uv run unhappy-path --dry-run           # a literal-minded fake, $0
mv results results-published           # the live runner resumes from committed results
cp .env.example .env                   # then add your ANTHROPIC_API_KEY
uv run --env-file .env unhappy-path --max-usd 8
uv run python -m unhappy.report

Bishal SahaLet's build together

Have a system to design, or an AI feature to get right?

Tell me about the problem. You'll get a clear, honest view of the best way forward.

  • Reply within 24 hoursOn business days, with my honest view and a next step.
  • Accepting select engagementsArchitecture, AI features and full builds.
  • Remote, worldwideWorking with startups, SMEs and enterprises.