Debugging an MCP Server for EKS: 3 Real Bugs Found Building a Downstream Client
Building a downstream client against my own MCP server surfaced three real bugs: an import-hook conflict, a silent error-parsing gap, and a severity field that lied. Here's each fix.
I set out to build Sentinel-One, an AI incident copilot for EKS, expecting the hard part to be the reasoning layer turning raw pod state into a correct diagnosis. It was. But some of the most useful bugs I found weren't in my new code at all. They were sitting in the MCP server I was building on top of: eks-sage-enterprise, a 62-tool server I'd published earlier for EKS incident diagnosis across the full six-layer traffic path.
Sentinel-One pulls in eks-sage-enterprise as an in-process library dependency, same IAM role, no MCP protocol hop instead of just calling it over transport. That one decision, using the tool as a real consumer instead of testing it as its own author, is what surfaced these bugs. They'd been sitting there invisible the whole time, because nothing had ever exercised the code paths the way a genuine downstream client does.
Here's what I found, how I fixed each one, and why it matters if you're building MCP tooling for infrastructure diagnosis.
Bug 1: an import-hook conflict that only shows up downstream
Importing
eks_sage_enterprise.server directly just failed a beartype import-hook conflict, triggered by a Unicode arrow character sitting in a docstring inside one of the tool modules ( tools/nlb.py ). As the author, I'd never once hit this, because my own tests always imported the package the same way I always had. As a consumer trying to reuse it as a library, the failure was immediate and total.Importing through the server module pulls in every tool, including the one with the bad docstring:
python
# Fails: ImportError via beartype's import hook,# triggered transitively by tools/nlb.pyfrom eks_sage_enterprise.server import get_pods, get_nodesThe fix is importing the tool submodules directly, bypassing the server aggregation layer entirely:
python
from eks_sage_enterprise.tools.pods import get_podsfrom eks_sage_enterprise.tools.nodes import get_nodesThat fix exposed a second problem:
get_pod_resource_usage had no standalone entry point at all — it only existed inline inside server.py . I ended up reimplementing it as its own importable function. If a function only exists as a private implementation detail of your server module, you don't actually have a library. You have a script that happens to expose MCP tools.If you want an MCP server to be composable, used as a sub-agent, wrapped by another tool, or embedded in a bigger system, go test that composability directly. Exposing tools over MCP transport and being importable as a library are two different guarantees, and only one of them gets exercised by end-to-end protocol tests.
Bug 2: error strings silently parsed as real data
This one was worse, because it failed silently. Error detection worked by checking whether the string
"error" showed up, case-insensitive, in a tool's output:python
def is_error(output: str) -> bool: return "error" in output.lower()Reasonable first pass until you hit an error message that doesn't contain the word "error."
kubectl not found doesn't. So when kubectl wasn't on the path, detection never fired, and the literal string "kubectl not found" got parsed downstream like it was legitimate pod data.Easy to miss in isolation; a tool call failing loudly is obvious. It's only once you're chaining outputs into a reasoning pipeline, the way Sentinel-One does, that a quietly malformed input turns into a wrong diagnosis instead of a crash. Fixed it by replacing substring matching with structural validation of the output shape:
python
def is_error(output: Any) -> bool: if not isinstance(output, dict): return True if "items" not in output or not isinstance(output["items"], list): return True return FalseString-matching for error detection is a trap in MCP pipelines, because the failure modes of whatever CLI you're wrapping kubectl here aren't under your control and won't reliably say "error." Structural checks catch what keyword matching can't.
Bug 3: a shadowed import that broke reporting, and a severity field that lied
This one was the most consequential, because it hit the thing an incident copilot actually exists for: telling the engineer whether something's really wrong.
get_incident_summary had a genuine UnboundLocalError a local import json mid-function was shadowing the module-level import, breaking everything downstream of it. Straightforward bug on its own. But it exposed a worse one underneath: the severity field only ever looked at the top_issues section. So if three of four report sections failed outright, the overall report could still come back OK because severity never checked whether most of the report had even generated.I forced 3 of 4 sections to fail and confirmed it live: severity still said
OK . Fix is a majority-section-failure override:python
def compute_severity(sections: dict, top_issues: list) -> str: failed = sum(1 for s in sections.values() if s.get("status") == "failed") if failed > len(sections) / 2: return "UNKNOWN" # most of the report didn't generate — don't trust top_issues return severity_from_top_issues(top_issues)Before: top_issues empty -> severity = OK (even if pods/nodes/events/metrics sections all failed)
After: 3 of 4 sections failed -> severity = UNKNOWN (overrides top_issues regardless of what it says)For any tool whose output feeds a human's go/no-go decision, partial failure needs to be visible at the top level, not buried in a sub-field somewhere. An incident summary that says "OK" while three-quarters of its own sections silently failed is worse than no summary; it actively misleads whoever's deciding whether to page someone.
Why this happened at all
None of these were exotic bugs. They're the ordinary kind that pile up in any tool mostly tested by its own author, calling its own happy paths. What changed the outcome wasn't more code review it was building a second, independent system that had to actually depend on the first one, under real failure conditions: missing
kubectl , partial cluster state, an environment the original author had never run in.If you're publishing an MCP server for infra tooling, the best test you can run isn't more unit tests against your own assumptions. It's handing the tool to a second system that has to trust its output for something that matters, and watching what breaks.
eks-sage-enterprise is Apache 2.0 licensed and public on GitHub . Sentinel-One, the copilot built on top of it, is still a work in progress.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article