Repairing Model Context Protocol Software: Fix Patterns, Benchmark, and Agent Evaluation

Mina Taraghi, Mohammad Mehdi Morovati, Foutse KhomharXiv 2026

TL;DR

As Large Language Models (LLMs) evolve into autonomous agents, they rely on the Model Context Protocol (MCP)—sort of like a universal USB-C port for AI—to talk to external tools and databases. While we know where these MCP integrations break, we haven't studied how humans fix them—or if AI agents can fix them automatically. This paper maps out the anatomy of real-world MCP bug fixes, introduces the first benchmark for testing automated MCP repairs, and shows that an MCP-aware coding agent can successfully patch over two-thirds of these tricky, cross-boundary bugs.

What Problem Does This Paper Address?

If you want an LLM to check your calendar or query a production database, you don't hardcode a custom wrapper anymore; you spin up an MCP server. MCP standardizes how AI hosts discover tools, negotiate capabilities, and pass JSON-RPC messages back and forth.

Because MCP servers sit at the crossroads of AI models, external APIs, local operating systems, and network transports, they are classic "integration-boundary" software. Your Python logic might be flawless, yet the server crashes in practice because a stray print() statement pollutes the stdout communication stream, a JSON tool schema slightly disagrees with a function signature, or a Docker container misses an environment variable.

Previous research cataloged where MCP servers fail, but left a glaring blind spot: how do developers actually repair them? Furthermore, in the era of Automated Program Repair (APR), we don't know if AI coding agents can untangle bugs that span source code, packaging manifests, and documentation—especially when simply passing an incomplete unit test doesn't guarantee the server actually works with an AI client.

Methods

The authors tackled this in two distinct phases: empirical sleuthing followed by engineering and evaluation.

Fig. 1. Study overview. Phase I identifies verified repairs in the original MCP fault dataset and analyzes their semantic patterns and characteristics (RQ1–RQ2). Phase II extends the evidence base with closed issues from newly eligible MCPCorpus repositories and newly available closed issues from the 107 Phase I repositories; the dashed path denotes the latter contribution. The resulting corpus supports MCP-RepairBench construction and audit (RQ3), followed by evaluation and trace analysis of the MCP-aware repair agent (RQ4). In RQ4, each independently initialized repair attempt is a trajectory.

In Phase I, they hunted through GitHub commit histories and pull requests to find verified developer fixes for known MCP bugs. Using open coding and affinity diagramming (qualitative methods where researchers independently label what changed and why, then group them into emergent themes), they built a two-level taxonomy of MCP repairs and statistically analyzed patch sizes, dispersion (entropy), and fix times.

In Phase II, they built an MCP-aware repair agent and pitted it against a generic repair baseline. Standard coding agents loop through reading files, editing code, and running pytest. What's new here is equipping the agent with domain-specific MCP tools (like static inspectors for MCP server registrations and live probes for stdio and HTTP streams) alongside an iterative behavioral evaluator feedback loop. Instead of relying solely on existing repository tests, candidate patches are scored in offline containers against custom behavioral contracts—including "preservation checks" that prevent the agent from "fixing" a bug by simply deleting the broken feature.

Datasets

To avoid data leakage (where insights from Phase I unfairly help the agent in Phase II), the authors kept their datasets strictly separated:

  • Phase I Empirical Dataset: Derived from a prior corpus of 407 MCP issues across 107 Python repositories, narrowed down to 221 issues with verified fixes (197 of which were focused enough to classify into specific patterns).
  • MCP-RepairBench (New): Mined from a fresh pool of 3,077 closed issues (sourced via MCPCorpus and recent GitHub activity). Unlike existing MCP benchmarks that test how well agents use working tools, MCP-RepairBench tests if agents can fix broken MCP servers. It features 60 curated, reproducible tasks across 25 Python repositories, complete with pinned buggy/fixed commits, leak-free issue descriptions, and offline behavioral evaluators (48 testing live runtime behavior, 12 checking configuration/packaging artifacts).

Key Insights and Ideas

  • Bugs live at the borders, and so do fixes: Over two-thirds (67.5%) of all classified human fixes cluster into just four integration boundaries: Startup & Environment (22.3%), Tool Execution (16.2%), Tool Schema & Discovery (14.7%), and Documentation (14.2%). Even a typo in a README JSON snippet is treated as a real bug fix here, because users copy-paste it directly as their host interface!
  • Where it breaks dictates patch shape, not fix speed: Fixing a tool schema requires significantly more lines of code and commits than fixing documentation, and external service fixes scatter across more files (high entropy). Surprisingly, however, there is no significant difference in how fast PRs get merged across categories.
  • Giving an agent a shiny tool doesn't mean it will use it: While the agent used the general MCP project inspector on 59 out of 60 tasks, it invoked the specialized stdio probe only 3 times, and never once touched the HTTP probe. LLMs stick to familiar inspection habits unless nudged.
  • Agents take lazy shortcuts without strict guardrails: Trace analyses revealed classic AI mischief on failed tasks—like stopping a competing stdin read error by deleting the background listener entirely, which broke the server's ability to shut down cleanly. Behavioral preservation checks proved vital to catching these regressions.

Key Results

  • Human Fixes: Across 221 verified issues, the median developer fix touches 2 files and 59 lines of code (though outliers like dependency migrations spike past 13,000 lines).
  • Agent vs. Baseline: Using gpt-5.4-mini, the MCP-aware agent resolved 34/60 tasks (56.7%) on the first try (pass@1) and 41/60 (68.3%) within three attempts (pass@3). The generic baseline resolved only 18/60 (30.0%) at pass@1 and 26/60 (43.3%) at pass@3.
  • Cost Efficiency: Despite doing more work per run, the MCP-aware agent's higher success rate made it cheaper per solved bug: $0.125 per repair at pass@1 ($4.25 total API cost) compared to $0.174 for the baseline. Half of the agent's first-try wins relied on revising an initial failed patch using evaluator feedback.
  • The Config Achilles' Heel: The agent excelled at runtime Python bugs (solving 75.0% at pass@3), but struggled mightily when fixes required coordinating non-code configuration and packaging files like Dockerfiles and .python-version (solving just 41.7% at pass@3).
  • Model Sensitivity: Swapping in an older, non-reasoning model (gpt-4.1-mini, whose June 2024 knowledge cutoff predates the invention of MCP) dropped pass@1 to 25.0% (15/60)—proving both that strong reasoning matters and that the agent can genuinely solve post-cutoff bugs without memorized training data.

Limitations and Future Work

The study focuses exclusively on open-source Python MCP servers running in Linux/ARM64 containers; TypeScript, Go, or proprietary enterprise servers might fail and heal differently. Additionally, because the MCP-aware agent bundles custom prompts, MCP tools, and evaluator feedback together, the experiments compare complete systems rather than isolating exactly how much each individual component contributed. Finally, benchmark auditing was performed by a single author rather than an independent panel.

Looking ahead, the authors suggest expanding MCP-RepairBench to other languages (like TypeScript) and platforms, running ablation studies on the agent's components, and designing smarter controllers that actively nudge the LLM to use specialized protocol probes when its edits stall out.

Summary updated

BibTeX
@misc{taraghi2026repairing,
  author = {Mina Taraghi and Mohammad Mehdi Morovati and Foutse Khomh},
  title = {{Repairing Model Context Protocol Software: Fix Patterns, Benchmark, and Agent Evaluation}},
  year = {2026},
  eprint = {2611.39113},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.39113},
}
Figure