Why unit tests fail to protect AI agents in production incidents
A new testing rubric reveals that Model Context Protocol servers often pass standard checks but fail when driven by non-deterministic AI agents during real incidents.
The Model Context Protocol (MCP) has rapidly evolved from a GitHub experiment into critical infrastructure for connecting Large Language Models to monitoring tools. However, a recent analysis highlights a dangerous gap: servers that pass every unit test can still fail catastrophically when an AI agent attempts to use them during a 3 AM incident. This discrepancy arises because standard tests assume polite, deterministic callers, while AI agents operate on probability and often make messy, non-linear choices.
What happened
Anthropic introduced the first MCP specification in November 2024, enabling LLMs to plug directly into databases and tools via standards like OAuth 2.1 and Streamable HTTP. Platform teams are now wiring these servers into Prometheus, Grafana, and Loki to create automated on-call triage agents. The goal is for an AI to investigate PagerDuty alerts and diagnose issues before human engineers wake up. Yet, as adoption grows, so does the risk of silent failures where the agent misinterprets data or crashes the triage loop.
QuietDesk Studio published a rubric distinguishing between two testing tiers. Tier 1 covers protocol and handler correctness, ensuring the server code works according to spec. Tier 2 covers behavior under an agent, testing what happens when a non-deterministic model actually drives the tools. The analysis shows that scoring below five out of six on either tier means the tool is not ready for production. A server might be technically correct but operationally hazardous if it cannot handle the erratic behavior of an AI trying to guess its way through an outage.
Key details
- Tier 1 tests verify JSON schemas, structured error handling, negative test coverage, timeout distinction, per-call auth validation, and latency under load.
- Tier 2 tests evaluate transport parity with production, separate scoring for tool selection and arguments, multiple trials per task, and adversarial prompt handling.
- Timeouts must return explicit error codes rather than empty results to prevent agents from falsely reporting system health during outages.
- Authentication must be validated on every call, not just at startup, to avoid silent failures when credentials expire mid-incident.
- Post-run state diffs are required to ensure read-only tools do not accidentally mutate dashboards or alert rules.
- Recovery behavior must be tested by injecting network failures to ensure agents retry sensibly rather than launching denial-of-service attacks.
Background
Model Context Protocol allows AI models to interact with external software using standardized interfaces. Unlike traditional API clients written by humans, LLM agents are non-deterministic, meaning they may choose different tools or arguments each time they run. They rely on token probability rather than strict logic, which leads to creative but sometimes incorrect inputs. Standard unit tests typically verify happy paths with clean data, missing the edge cases where agents struggle, such as ambiguous tool descriptions or partial network failures.
Why it matters
For teams running their own software, relying on untested MCP servers creates significant operational risk. An agent that misinterprets a timeout as a successful empty result might announce that everything is healthy while the production database is down. This false confidence delays human intervention and extends outage duration. Furthermore, agents that do not handle authentication expiration gracefully will stop gathering data silently, leaving on-call engineers blind to the root cause.
The distinction between Tier 1 and Tier 2 testing is crucial for resource allocation. Fixing Tier 1 issues involves correcting code bugs, while Tier 2 failures require adjusting how tools are described and how errors are structured for AI consumption. Ignoring Tier 2 means deploying systems that work in demos but fail under pressure. Teams must treat agent interaction as a distinct failure mode, requiring specific validation strategies that go beyond traditional software quality assurance.
What you can do
- Implement negative tests in your CI pipeline that send empty inputs, wrong types, and out-of-bounds values to your MCP handlers.
- Ensure your server returns distinct JSON structures for timeouts versus empty results to prevent agent hallucinations about system health.
- Run each triage task at least five times in your test harness to measure reliability rather than cherry-picking a single successful run.
- Validate authentication tokens on every individual call instead of only at server startup to handle credential expiration during long incidents.
- Diff your system state after every automated test run to detect any unintended mutations to dashboards or alert configurations.
- Inject synthetic network failures during tests to verify that your agent retries with exponential backoff instead of spamming requests.



