The question
A program calls Research A technical wordMCPModel Context Protocol. A standard way for AI apps to find and use tools that other programs offer. Service to do something, such as a save that creates a project. When a call fails, the caller needs enough detail to act on. But it shouldn’t get its own bad input sent back, or the service’s inner details. And trying a failed save again shouldn’t add a second audit event. An audit event is the saved record of a failed attempt.
What made it hard
The same action can be reached in two ways. One is a request through MCP, the Model Context Protocol, a standard way for AI apps to call tools. The other is calling the service directly. A check on only one route would let a caller on the other route skip it.
What I chose
So input is checked on both routes. On the MCP route, each tool is set up in the protocol’s own code library with strict input rulesResearch Workflow Engine · Research MCP Service · The serverTool registryHolds each tool’s version, its strict input rules and output rules, and short notes that describe it.See it in the Research Workflow Engine build. These rules describe the input that is allowed. Both routes then meet in one shared serviceResearch Workflow Engine · Research MCP Service · The serverShared serviceReads the input and limits how deeply data can sit inside other data. Then it hands the work to the engine and checks the result.See it in the Research Workflow Engine build, which reads the raw input again. It limits how large the input can be, and how deeply its A technical wordJSONA common text format that programs use to send each other structured data. data can sit inside other data. A bad call is sent back before it reaches a handler, the code that carries out the action.
Good input can still fail inside its handler. Known failuresResearch Workflow Engine · Research MCP Service · The serverError mappingSorts known failures into types, each with retry advice. Any unknown failure becomes one fixed internal error.See it in the Research Workflow Engine build, such as a missing record or a clash between versions of a record, keep set messages and retry advice. An unexpected error becomes one fixed internal error, without its original text. So the caller can act on a failure it knows. And it never receives the service’s inner details.
Sometimes a save fails even though its input was good. Then the service can save one audit event. The event holds a failure code and a fingerprint of the request, a short code made from it. Each save also carries a retry key, which lets the service tell a retry from a new save. A retry that clashes on its key takes a different route, and adds no audit event.
How I know it works
The security tests send unexpected input through the protocol’s code library. They also send text that is too large through the shared service. They check that the answer doesn’t repeat the bad value, and that no project was created.
A test of the parts working together makes a save fail on purpose. Then it retries with the same retry key, once with the same input and once with changed input. Both retries clash, and the count of audit events stays at one.