All posts
patternsmcptool-usearchitecture

MCP Is Two Years Old. The Pattern I Used to Fix It Is Twenty-Three.

MCP shipped in 2024. The Anti-Corruption Layer shipped in 2003. Thoughtworks and AWS have already put the two together for schema translation. The harder half, what the layer says when the tool cannot answer, is what this post is about.

5 min read
TL;DR The One Thing to Know

New protocols create new plumbing, not new problems. MCP gave agents a standard way to call tools, and Thoughtworks and AWS have both pointed out that the fix for the foreign model on the other side is Eric Evans' Anti-Corruption Layer from 2003. Both stop at translating shape and vocabulary. The harder half is failure classification: a return contract with nowhere to put uncertainty or an outage collapses both into no, and in an agent that no gets spoken to a person.

The Model Context Protocol shipped in late 2024. The pattern that fixed my worst MCP integration problem shipped in a book in 2003, written about mainframes.

The new boundary

MCP did something genuinely useful. Before it, every agent-to-tool integration was bespoke: your own schema, your own transport, your own glue, rewritten per vendor. MCP made the plumbing standard. A server exposes tools, your agent calls them, and you stop writing adapters for a living.

What it standardised was the transport of the call. What it could not standardise is what the thing on the other end actually means.

So now you have a clean, well-specified pipe to a tool built by someone else, on their release cycle, with their assumptions baked into its return values. The protocol is modern. What arrives through it is whatever that team decided a return value should look like, which is sometimes twenty years of conventions and sometimes a single boolean.

What that looked like for me

I hit this building agents in production. A tool returned a bare boolean. Covered or not covered.

Then it had a bad minute. A gateway hiccuped and returned an error dressed as a success. A term came in that the catalogue did not recognise. A lookup timed out.

Every one of those came back as false.

My agent could not tell "no" from "I did not understand the word" from "the service is down." It said the same thing to all three: sorry, that isn't covered. Confidently. To a real person. Who hung up.

Nothing threw. No test went red. The tool's own error rate looked fine, because returning false is, from its point of view, a success.

I went looking for the answer. Part of it had already been written, by people who got to the boundary before me. The rest was on a bookshelf. The part nobody had written is what this post is about.

What Eric Evans wrote in 2003

Domain-Driven Design has a chapter on what to do when your system has to talk to one you do not control. His answer was the Anti-Corruption Layer: do not let the foreign model across the border. Build a layer at the seam whose entire job is translation, so their assumptions stay on their side of it and your model stays coherent.

He was writing about legacy systems. Mainframes, batch jobs, a schema nobody could change because the person who designed it had retired.

Read that description again and ask how much of it is about mainframes, and how much is about any system you do not control. A model you cannot change. A team on a different release cycle. Semantics you inherited rather than chose.

That is an MCP server built by another company.

Who mapped it onto MCP first

Two posts had already made the connection before I did, and you should read both.

Thoughtworks, in "Your agent skill is not an anti-corruption layer," argues that plugging an off-the-shelf MCP server straight into an agent is what domain-driven design calls a conformist integration: you adopt the other side's model wholesale. Their fix is a custom MCP server whose tools are typed and enforced in code, so the tools themselves are the Anti-Corruption Layer, not a prompt asking the model to be careful.

AWS, in "Rediscovering Domain-Driven Design, one MCP server at a time," applies bounded contexts and the Anti-Corruption Layer to MCP servers directly and puts the layer in the tools layer.

Both are right, and both stop at the same place: the translation of shape and vocabulary, so the upstream's schema does not leak into yours. Neither asks what the layer should say when the upstream cannot answer. That is where the problem I hit actually lived, and it is the half this post adds.

The half they skip: what the layer says when the tool cannot answer

Line them up and the correspondence is exact.

The foreign model is the tool's return contract. The domain you are protecting is your agent's reasoning. The seam is the MCP call. The translation layer owns what crosses it: it normalizes what goes out, classifies what comes back, and emits only values from a set you defined.

Schema translation gets you a typed tool that still returns one boolean. The boolean is the bug. In my case the set had four members instead of two, covered, not covered, unresolved, lookup failed, because the agent needed to do four different things and a boolean can only express two. Uncertainty got its own state, so it stopped being rounded down to "no." Upstream failure got its own state, so the agent stopped asserting things during an outage. And the rule that holds the whole thing together is one line: the layer never emits a false no. Below the matching threshold it says unresolved and the agent asks a question.

Twenty-three-year-old pattern. Two-year-old protocol. One rule added, and four states where there were two.

The contract the agent sees
VERDICTS = ("covered", "not_covered", "unresolved", "lookup_failed")

async def check(term: str) -> Verdict:
    key = normalize(term)
    try:
        catalogue = await cache.get_or_fetch(tools.list_covered_treatments)
    except (UpstreamError, TimeoutError):
        return Verdict("lookup_failed")      # never invent a verdict from a failure
    match = resolve(key, catalogue)
    if match is None:
        return Verdict("unresolved")         # ask, do not refuse
    return Verdict("covered" if match.covered else "not_covered", canonical=match.name)

What happened when it shipped

It has been running in production for over a month now, and the interesting result was not the one I expected.

I built the layer to fix matching: the terms the upstream tool did not recognise. It did that. But the largest class of thing it caught was something I had not been looking for: upstream errors arriving dressed as valid responses. A gateway returning a server error inside a successful-looking body. Those had been there the whole time, invisible, because nothing in the old path was looking for them. The agent had been treating them as answers.

That is the part worth knowing. You do not put a translation layer in only to fix the problem that sent you looking. You put one in because you cannot see what is crossing an unguarded boundary, and classifying everything that arrives is how you find out.

Where it does not hold

One thing is genuinely different, and it is the part that makes this worse than what Evans was describing.

In a classical ACL, a leaked bad value becomes a bug. Something throws. A test goes red. A number looks wrong in a report. You find it, eventually, because broken software announces itself.

In an agent, a leaked bad value becomes a sentence. Fluent, well-formed, delivered in your product's voice, and wrong. There is no stack trace for an agent that was told false and said "that isn't covered." The failure mode of a corrupted agent is not a crash. It is confidence.

That is the one line I would add to the 2003 version.

The general lesson

This is the thing I keep running into, and it is why this whole site is organised the way it is.

Agentic AI is a new field with a short memory. Every month there is a new protocol, a new framework, a new orchestration library, and a wave of blog posts discovering a problem from first principles. Most of those problems are not new. Retries and circuit breakers. Idempotency. Contract versioning. Observability. Backpressure. Our field solved these, wrote them down, and gave them names, and then we all started again because the thing calling the API is now a language model.

The model is new. The boundary is not. Before you invent something, check whether a distributed-systems engineer named it in 2003 and someone wrote a book about it.

The complete pattern, with the matching ladder, the failure matrix and practice exercises, is Pattern 22 in the course.

Key Takeaway

MCP standardised how agents call tools. Thoughtworks and AWS have already put an Anti-Corruption Layer at that seam for shape and vocabulary. The part they skip is what the layer says when the tool cannot answer: give uncertainty and failure their own states and never emit a false no, because in an agent a leaked value does not throw, it speaks.

Go Deeper Full Pattern Breakdown

This post covers the basics. The full curriculum page for Boundary Translation includes the SWE mapping, code examples, production notes, and an interactive building exercise.

Boundary Translation → Anti-Corruption Layer
Share this post:Twitter/XLinkedIn

AI-Readable Summary

Question: Can the Anti-Corruption Layer pattern from domain-driven design be applied to Model Context Protocol (MCP) tool integrations?

Answer: Yes, and it has been: Thoughtworks ("Your agent skill is not an anti-corruption layer") argues that a stock MCP server plugged straight into an agent is a conformist integration and that custom, typed tools should act as the ACL; an AWS post on dev.to applies bounded contexts and the ACL to MCP servers and places the layer in the tools. Both cover the translation of shape and vocabulary. What they leave out is failure classification: most tool contracts have nowhere to put uncertainty or an upstream failure, so an unmatched term, a timeout and a real negative all arrive as the same false. The fix is a verdict with its own states for unknown and for failure (covered, not covered, unresolved, lookup failed), a rule that the layer never emits a false no, and a matching ladder in plain code before any fuzzy step. The divergence from classical DDD is the failure mode: a leaked bad value in a classical system throws; in an agent it is spoken to a user as a confident sentence.

Key Takeaway: MCP standardised how agents call tools. Thoughtworks and AWS have already put an Anti-Corruption Layer at that seam for shape and vocabulary. The part they skip is what the layer says when the tool cannot answer: give uncertainty and failure their own states and never emit a false no, because in an agent a leaked value does not throw, it speaks.

Source: learnagenticpatterns.com/blog/anti-corruption-layer-mcp