Labsco
vola-trebla logo

flakiness-knowledge-graph-mcp

from vola-trebla

Builds a knowledge graph of flaky tests from Playwright run history

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

πŸ“Š flakiness-knowledge-graph-mcp

npm downloads

A Playwright custom reporter + MCP server that builds a local flakiness knowledge graph from your test run history. Ask your AI agent which tests are unreliable, on which browser, and whether they're getting worse.

πŸ€” The Problem

A single Playwright trace tells you what failed right now. It doesn't tell you whether this test has been silently flaking for two weeks, or only fails on Firefox in CI, or is getting slower with every release.

This tool fixes that by accumulating run history into a SQLite database and exposing it to AI agents via MCP.

πŸ› οΈ Tools

ToolArgumentsWhat it returns
get_flaky_testsdb_path, min_runs?, limit?, since_days?Tests ranked by flakiness rate (failed+flaky / total runs)
get_test_historydb_path, test_id, limit?Full run history for a specific test β€” status, duration, error, retry, browser, OS
get_failure_patternsdb_path, since_days?Failure rates broken down by browser Γ— OS combination
get_slow_testsdb_path, limit?Tests ranked by average duration
get_error_groupsdb_path, min_failures?, limit?, since_days?Failures clustered by exact error prefix β€” surfaces shared root causes across tests
get_flakiness_trenddb_path, test_id, days?Daily flakiness rate over the last N days β€” shows whether a test is getting worse
cluster_semantic_error_treesdb_path, min_instances?, since_days?Like get_error_groups but normalises dynamic values (UUIDs, IDs, URLs) first, then fuzzy-merges with Levenshtein
correlate_git_commit_flakinessdb_path, min_stable_runs?, since_days?Finds the exact commit SHA where a test transitioned stable→flaky (or back), with branch and author

πŸ”— Works great with playwright-trace-decoder-mcp

These two MCP servers are designed to complement each other:

  • flakiness-knowledge-graph-mcp answers "is this test flaky historically, and which commit caused it?"
  • playwright-trace-decoder-mcp answers "what exactly failed in this specific run?"

Combined, an AI agent can diagnose whether a CI failure is a known flaky test or a new regression β€” without you opening a single file.

βš–οΈ Parallel Execution & CI Sharding

flakiness-knowledge-graph-mcp uses an in-process write queue to ensure that parallel Playwright workers within a single Node process do not corrupt the database.

However, if you run tests across multiple independent processes (e.g., parallel CI shards or separate machine runners) writing to the same shared network file:

  1. Race Conditions: Standard file systems do not guarantee atomic writes for SQLite files across processes without OS-level locking.
  2. Recommended Approach: Each CI shard should write to its own database file (e.g., flakiness-shard-1.db, flakiness-shard-2.db).
  3. Merging: At the end of the CI pipeline, you can merge these files into a single master database using standard SQLite tools or by running a script that reads from one and inserts into the other.

For local development or single-machine CI runs, the default configuration is safe.

πŸ—οΈ Architecture

playwright.config.ts
  └── FlakinessReporter β†’ flakiness.db (SQLite via sql.js)

flakiness.db
  └── test_runs table
        id, test_id, title, suite, file,
        status, duration_ms, browser, os,
        timestamp, error, retry,
        git_commit_sha, git_branch, git_author   ← added in v0.2.0

MCP server
  └── reads flakiness.db on demand (in-process handle reuse)

sql.js is used instead of better-sqlite3 β€” pure JavaScript SQLite compiled to WebAssembly, no native compilation needed. The git columns are added via ALTER TABLE migration on first use β€” existing databases upgrade automatically.

πŸ“‹ Scripts

npm run build        # compile TypeScript β†’ dist/
npm run lint         # ESLint
npm run format       # Prettier --write
npm run format:check # Prettier check (used in CI)
npm run seed         # populate flakiness.db with 30 days of demo data

πŸ“„ License

MIT