Skip to main content
Glama
raeseoklee

MCP Workbench MCP Server

by raeseoklee

explain_failure

Analyze test failures to classify root causes and provide actionable recommendations for fixing issues in MCP server testing.

Instructions

Analyze test run results and explain failures with heuristic classification and actionable recommendations. Pass the structured result from run_spec.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
runResultYesThe RunReport object from a run_spec call

Implementation Reference

  • The main handler function for the explain_failure tool, which analyzes test run results and categorizes failures.
    export function explainFailure(
      input: ExplainFailureInput,
    ): ExplainFailureOutput {
      const { runResult } = input;
    
      const failedTests = runResult.tests.filter(
        (t) => t.status === "failed" || t.status === "error",
      );
    
      if (failedTests.length === 0) {
        return {
          text: "All tests passed \u2014 no failures to explain.",
          structured: {
            summary: "All tests passed",
            causes: [],
            recommendations: [],
          },
        };
      }
    
      const counts = new Map<CauseType, number>();
    
      for (const test of failedTests) {
        const cause = classifyCause(test);
        counts.set(cause, (counts.get(cause) ?? 0) + 1);
      }
    
      const causes: FailureCause[] = [];
      const recommendations: string[] = [];
    
      for (const [type, count] of counts) {
        causes.push({
          type,
          count,
          description: CAUSE_DESCRIPTIONS[type],
        });
        recommendations.push(RECOMMENDATIONS[type]);
      }
    
      const summary = causes
        .map((c) => `${c.count} ${c.type} failure${c.count > 1 ? "s" : ""}`)
        .join(", ");
    
      const textParts = [`${failedTests.length} failed test(s): ${summary}`, ""];
      textParts.push("Causes:");
      for (const c of causes) {
        textParts.push(`  [${c.type}] ${c.count}x \u2014 ${c.description}`);
      }
      textParts.push("");
      textParts.push("Recommendations:");
      for (const r of recommendations) {
        textParts.push(`  \u2022 ${r}`);
      }
    
      return {
        text: textParts.join("\n"),
        structured: { summary, causes, recommendations },
      };
    }
  • Input and output type definitions for the explain_failure tool.
    export interface ExplainFailureInput {
      runResult: RunReport;
    }
    
    export interface ExplainFailureOutput {
      text: string;
      structured: {
        summary: string;
        causes: FailureCause[];
        recommendations: string[];
      };
    }
  • Helper function to classify the type of test failure.
    function classifyCause(test: TestResult): CauseType {
      const errorText = gatherErrorText(test).toLowerCase();
    
      // auth
      if (AUTH_PATTERNS.some((p) => errorText.includes(p))) {
        return "auth";
      }
    
      // placeholder
      const idAndError = `${test.testId} ${errorText}`.toLowerCase();
      if (
        idAndError.includes("todo") ||
        idAndError.includes("placeholder") ||
        idAndError.includes("todo_")
      ) {
        return "placeholder";
      }
    
      // discovery
      if (
        test.status === "error" &&
        (errorText.includes("method not found") ||
          errorText.includes("not supported") ||
          errorText.includes("capability"))
      ) {
        return "discovery";
      }
    
      // protocol
      if (
        errorText.includes("timeout") ||
        errorText.includes("connection") ||
        errorText.includes("econnrefused") ||
        errorText.includes("parse error")
      ) {
        return "protocol";
      }
    
      // assertion
      if (
        test.status === "failed" &&
        test.assertionResults.some((a) => !a.passed)
      ) {
        return "assertion";
      }
    
      return "unknown";
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions 'heuristic classification' and 'actionable recommendations,' it doesn't describe what the tool actually returns (e.g., a summary, categorized failures, specific suggestions), whether it's read-only or has side effects, or any performance characteristics like rate limits. For a tool with no annotations, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, consisting of two sentences: the first states the core purpose, and the second provides usage guidance. There's no wasted text, but it could be slightly more structured (e.g., explicitly separating purpose from prerequisites).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (nested input object, no output schema, no annotations), the description is incomplete. It doesn't explain what the tool outputs (e.g., a failure analysis report, recommendations), how failures are classified, or what 'actionable recommendations' entail. For a tool that performs analysis on complex test data, this leaves too much unspecified for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'runResult' fully documented in the schema as 'The RunReport object from a run_spec call.' The description adds minimal value beyond this by restating the same information ('Pass the structured result from run_spec'). With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't provide additional semantic context about the parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Analyze test run results and explain failures with heuristic classification and actionable recommendations.' It specifies the verb ('analyze' and 'explain'), resource ('test run results'), and key capabilities ('heuristic classification' and 'actionable recommendations'). However, it doesn't explicitly differentiate from sibling tools like 'run_spec' beyond mentioning its input comes from that tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance by stating 'Pass the structured result from run_spec,' indicating this tool should be used after 'run_spec' to analyze its output. However, it doesn't explicitly state when to use this tool versus alternatives (e.g., when to use 'inspect_server' or 'generate_spec' instead) or provide any exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/raeseoklee/mcp-workbench-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server