flakiness-knowledge-graph-mcp

by vola-trebla

Not rated
GitHub

About

Builds a knowledge graph of flaky tests from Playwright run history

Details

Author
vola-trebla
Categories
Developer Tools, Other, Knowledge Base

Setup

Install flakiness-knowledge-graph-mcp in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/vola-trebla/flakiness-knowledge-graph-mcp

Follow the installation instructions in the repository README, then restart your MCP client.

Builds a knowledge graph of flaky tests from Playwright run history

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.

A single Playwright trace tells youwhatfailed 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.

npm install -g flakiness-knowledge-graph-mcp
git clone https://github.com/vola-trebla/flakiness-knowledge-graph-mcp.git cd flakiness-knowledge-graph-mcp npm install && npm run build

2. Add the reporter to your Playwright project

// playwright.config.ts export default defineConfig({ reporter: [["html"], ["flakiness-knowledge-graph-mcp/reporter", { dbPath: "./flakiness.db" }]], });

Run your tests normally — the reporter writes every result toflakiness.dbautomatically.

Cursor / VS Code (.cursor/mcp.jsonor.vscode/mcp.json)

{ "mcpServers": { "flakiness-knowledge-graph": { "command": "flakiness-knowledge-graph-mcp" } } }
claude mcp add flakiness-knowledge-graph flakiness-knowledge-graph-mcp

No Playwright project yet? Generate 30 days of realistic sample data:

Then point your AI agent at./demo.dbto explore all 8 tools.

I've been running my Playwright suite for two weeks. The DB is at /my-project/flakiness.db. 1. get_flaky_tests — which tests are most unreliable? Show last 7 days only. 2. get_test_history for the top flaky test — is it getting worse? 3. get_flakiness_trend for the same test over 14 days — plot the daily rate. 4. get_failure_patterns — does it only fail on a specific browser or OS? 5. cluster_semantic_error_trees — are multiple tests failing with semantically identical errors? 6. correlate_git_commit_flakiness — which commit introduced the flakiness? 7. get_slow_tests — which tests should I optimize for CI speed?

Grouping errors that look different but aren't

get_error_groupsclusters by raw string prefix — if the error contains a UUID or element ID it creates separate groups for what is really one root cause.cluster_semantic_error_treesstrips dynamic values first:

{ "total_clusters": 2, "clusters": [ { "cluster_id": "cluster-1", "canonical_message": "TimeoutError: locator.click: Timeout 30000ms exceeded\n waiting for locator('#submit-btn')", "normalized_message": "TimeoutError: locator.click: Timeout <num>ms exceeded waiting for locator", "error_taxonomy": "TimeoutError", "instance_count": 14, "affected_tests": 3, "sample_test_ids": ["checkout > submit order", "cart > add item", "checkout > apply coupon"] }, { "cluster_id": "cluster-2", "canonical_message": "Error: 2 requests to https://api.example.com/orders/8f3a1c were made. Expected 1", "normalized_message": "Error: <num> requests to <url> were made. Expected <num>", "error_taxonomy": "AssertionError", "instance_count": 6, "affected_tests": 1, "sample_test_ids": ["api-mock > intercept order"] } ] }

correlate_git_commit_flakinessuses a state machine — it looks for runs where a test was stable for ≥3 consecutive passes, then failed. The transition record includes the SHA from the CI environment:

{ "total_transitions": 1, "transitions": [ { "test_id": "auth > login > should redirect after login", "title": "should redirect after login", "transition_type": "stable_to_flaky", "git_commit_sha": "a3f8c1d9e2b54f6a", "git_branch": "main", "git_author": "dev-handle", "transition_date": "2025-04-14" } ] }

The reporter readsGITHUB_SHA/CI_COMMIT_SHA/CIRCLE_SHA1/GIT_COMMITautomatically — no reporter config changes needed beyond upgrading to v0.2.0.

🔗 Works great with playwright-trace-decoder-mcp

These two MCP servers are designed to complement each other:

- flakiness-knowledge-graph-mcpanswers "is this test flaky historically, and which commit caused it?"
- playwright-trace-decoder-mcpanswers "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.

flakiness-knowledge-graph-mcpuses an in-process write queue to ensure that parallel Playwright workers within asingle Node processdo not corrupt the database.

However, if you run tests acrossmultiple independent processes(e.g., parallel CI shards or separate machine runners) writing to the same shared network file:
- Race Conditions:Standard file systems do not guarantee atomic writes for SQLite files across processes without OS-level locking.
- Recommended Approach:Each CI shard should write to its own database file (e.g.,flakiness-shard-1.db,flakiness-shard-2.db).
- 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.

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.jsis used instead ofbetter-sqlite3— pure JavaScript SQLite compiled to WebAssembly, no native compilation needed. The git columns are added viaALTER TABLEmigration on first use — existing databases upgrade automatically.

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

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

An AI agent for the Playwright MCP server, enabling automated web testing and interaction.

Generate Playwright BDD tests, GitHub Actions and Azure Pipelines with business-rule traceability, focused CodeGraph context and persistent Engram memory.

Autonomous QA MCP that tests web and macOS apps like a real engineer and verifies every bug.

A Playwright-based MCP server that exposes a live browser as a traceable, inspectable, debuggable and controllable execution environment for AI agents.

Browser automation via Chrome DevTools Protocol

Drive, inspect, and assert on real Electron desktop apps from an AI agent — agent-native, Playwright-style automation with accessibility refs, stable error codes, and retrying assertions

Playwright MCP for Godot, screenshots, SceneTree manipulation, and arbitrary GDScript execution at runtime through a local UDP bridge.

A lightweight, AI-powered end-to-end testing framework for CI workflows. Requires an OpenAI API key.

Automate web testing and tasks by connecting Claude Desktop with Playwright.

Create and manage end-to-end tests using the Octomind platform.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.