Skip to main content
Glama
rudrathkr

MCP Test Failure Analysis Server

by rudrathkr

detect_flaky_tests

Identify flaky tests by analyzing historical pass/fail data. Input test history with names and statuses to detect inconsistent test results.

Instructions

Detect flaky tests from historical pass/fail data.
Each item should contain test_name and status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
test_historyYes

Implementation Reference

  • The MCP tool handler that detects flaky tests from historical pass/fail data. It aggregates pass/fail counts per test, and flags tests with >=5 runs where both pass and fail counts are >0, returning their failure rates.
    @mcp.tool()
    def detect_flaky_tests(test_history: list[dict]) -> dict:
        """
        Detect flaky tests from historical pass/fail data.
        Each item should contain test_name and status.
        """
    
        stats = defaultdict(lambda: {"pass": 0, "fail": 0})
    
        for run in test_history:
            name = run["test_name"]
            status = run["status"].lower()
            if status in stats[name]:
                stats[name][status] += 1
    
        flaky = []
    
        for test_name, result in stats.items():
            total = result["pass"] + result["fail"]
            if total >= 5 and result["pass"] > 0 and result["fail"] > 0:
                failure_rate = result["fail"] / total
                flaky.append({
                    "test_name": test_name,
                    "pass_count": result["pass"],
                    "fail_count": result["fail"],
                    "failure_rate": round(failure_rate, 2)
                })
    
        return {"flaky_tests": flaky}
  • The @mcp.tool() decorator registers detect_flaky_tests as an MCP tool on the FastMCP server instance.
    @mcp.tool()
    def detect_flaky_tests(test_history: list[dict]) -> dict:
Behavior2/5

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

No annotations are provided, so the description bears full responsibility. It does not disclose whether the tool is read-only, destructive, or has side effects. It only hints at input formatting (test_name and status) but omits behavior like output structure or failure modes.

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

Conciseness5/5

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

The description is concise with two sentences: the first states the tool's purpose, and the second provides an input hint. No unnecessary words; every sentence contributes meaning.

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

Completeness3/5

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

For a simple tool with one array parameter and no output schema, the description covers the core purpose and input requirement. However, it lacks details on output (e.g., what the tool returns) and fails to provide context relative to siblings. It is minimally adequate but not fully complete.

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 0%, but the description adds that each item should contain 'test_name and status', which provides necessary meaning beyond the schema (which only says array of objects with additionalProperties). However, it does not specify data types or expected values, so it adds limited value.

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

Purpose5/5

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

The description clearly states the action ('Detect'), the resource ('flaky tests'), and the data source ('historical pass/fail data'). It distinguishes from sibling tools like 'analyze_test_failure' which focuses on analyzing a specific failure, and 'cluster_failures' which clusters failures, making the tool's purpose distinct.

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

Usage Guidelines2/5

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

The description provides no explicit guidance on when to use this tool versus alternatives ('analyze_test_failure', 'cluster_failures'). It implies usage for historical data but does not set context for selection, leaving the agent to infer.

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/rudrathkr/MCPServerCreationPythonSDK'

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