Skip to content
Login Start Free

MCP Server

The Gaffer MCP server connects AI coding assistants to your test history. Ask about test health, investigate flaky tests, and get context about failures without leaving your editor.

The Model Context Protocol (MCP) is an open standard that lets AI assistants access external tools and data sources. By installing the Gaffer MCP server, your AI assistant gains direct access to your test analytics.

  • Test health insights - Ask about pass rates, trends, and overall test suite health
  • Flaky test detection - Identify tests with inconsistent behavior
  • Test history lookup - Check the history of specific tests to understand stability
  • Cross-project access - Query all your projects from a single API key
  • Report file access - Get links to HTML reports, coverage files, and other artifacts
  • Slowest test analysis - Find tests that are slowing down your CI pipeline
  1. A Gaffer account with test results uploaded
  2. For Claude Code, claude.ai and Claude Desktop on the hosted endpoint, nothing else: you sign in. For Cursor, CI and the npm package, a user API key (gaf_) from Account Settings > API Keys at app.gaffer.sh/account/api-keys. It covers every project your account can reach. A project token (gfr_) also works and is limited to one project. See Authentication for what each can do.

There are two ways to connect. Use the hosted endpoint unless your client only supports local stdio servers.

Hosted endpointnpm package
InstallNothingnpx runs @gaffer-sh/mcp on your machine
CredentialOAuth sign-in, or Authorization: Bearer <key> headerGAFFER_API_KEY environment variable
Functions17 with a key, same as npm. A signed-in connection has 16: it is read-only, so upload_test_results is listed but refusedAll 17
execute_code runsIn an isolated sandbox with no network accessIn a local Node process
ClientsThose that support remote HTTP serversAny client that can start a stdio server

The endpoint is https://app.gaffer.sh/mcp (Streamable HTTP, POST only). Each credential is limited to 1,000 requests per hour. Requests without a valid credential get a 401, and requests over the limit get a 429 with a Retry-After header.

Claude Code, claude.ai and Claude Desktop sign in with OAuth. You do not create an API key.

Claude Code

Terminal window
claude mcp add --transport http gaffer https://app.gaffer.sh/mcp

Then run /mcp inside Claude Code, select gaffer, and finish the sign-in in your browser.

claude.ai and Claude Desktop

  1. Open Customize > Connectors, click + Add, then Add custom connector. On Team and Enterprise plans an owner adds it under Organization settings > Connectors, and each member then clicks Connect.
  2. Enter a name and https://app.gaffer.sh/mcp as the URL, then click Add and sign in to Gaffer.
  3. On the consent page, pick the organization to connect and approve.

Anthropic’s steps for custom connectors are the reference if the menu names change.

Share it with your team

Commit this .mcp.json at the root of your repository. It holds no secret. Each teammate signs in once with /mcp and Claude Code asks them to approve the project server first.

{
"mcpServers": {
"gaffer": {
"type": "http",
"url": "https://app.gaffer.sh/mcp"
}
}
}

What signing in grants

  • Access to one organization, the one you pick on the consent page. To use another organization, connect again and pick it.
  • Read access only. A signed-in assistant can read test runs, failures, flaky tests and coverage. It cannot call upload_test_results.
  • The same limit of 1,000 requests per hour, counted per connected app.

To revoke access, open Account Settings > AI assistants at app.gaffer.sh/account/ai-assistants and click Disconnect next to the app under Connected apps.

Use a key for CI, Cursor, or if you prefer one. A key can also upload results.

Claude Code:

Terminal window
claude mcp add --transport http gaffer https://app.gaffer.sh/mcp --header "Authorization: Bearer gaf_YOUR_KEY"

Cursor: add to .cursor/mcp.json in your project, or ~/.cursor/mcp.json for every project:

{
"mcpServers": {
"gaffer": {
"url": "https://app.gaffer.sh/mcp",
"headers": {
"Authorization": "Bearer gaf_YOUR_KEY"
}
}
}
}

The package runs locally over stdio and reads your key from GAFFER_API_KEY.

Terminal window
claude mcp add gaffer -e GAFFER_API_KEY=gaf_YOUR_KEY -- npx -y @gaffer-sh/mcp

Or add to your Claude Code settings (~/.claude.json or project .claude/settings.json):

{
"mcpServers": {
"gaffer": {
"command": "npx",
"args": ["-y", "@gaffer-sh/mcp"],
"env": {
"GAFFER_API_KEY": "gaf_YOUR_KEY"
}
}
}
}

Add to .cursor/mcp.json in your project:

{
"mcpServers": {
"gaffer": {
"command": "npx",
"args": ["-y", "@gaffer-sh/mcp"],
"env": {
"GAFFER_API_KEY": "gaf_YOUR_KEY"
}
}
}
}

Open Settings > Developer > Edit Config, or edit the file directly:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"gaffer": {
"command": "npx",
"args": ["-y", "@gaffer-sh/mcp"],
"env": {
"GAFFER_API_KEY": "gaf_YOUR_KEY"
}
}
}
}

Quit and restart Claude Desktop after saving. Node.js must be installed.

What tools does the Gaffer MCP server expose?

Section titled “What tools does the Gaffer MCP server expose?”

Three. The server runs in code mode: rather than one MCP tool per API call, it exposes three tools plus a codemode namespace of 17 analytics functions that you call from JavaScript. That keeps 17 tool definitions out of the context window, and it lets one execution chain several calls instead of paying a round-trip each.

MCP toolWhat it does
execute_codeRuns JavaScript against codemode.<function>(). Max 20 API calls, 30s timeout. On the hosted endpoint it runs in a sandbox with no network access.
search_toolsFinds available functions by keyword. An empty query lists all of them.
list_projectsLists projects. Registered for a user API Key (gaf_) and for sign-in, not for a project token (gfr_).

You rarely write this code yourself. You ask a question, and the assistant writes the call:

const health = await codemode.get_project_health({ projectId: "proj_abc" });
if (health.flakyTestCount > 0) {
const flaky = await codemode.get_flaky_tests({ projectId: "proj_abc" });
return { health, flaky };
}
return { health };

All 17 are reachable through execute_code with a key. A signed-in connection is read-only, so upload_test_results is refused and 16 work. Ask search_tools with an empty query to list them at runtime.

FunctionCategoryReturns
get_project_healthhealthHealth score (0-100), pass rate, run count, flaky count, trend
get_test_historytestingPass/fail history for one test, with branch, commit, and errors
get_flaky_teststestingFlip rates, transition counts, and last-seen timestamps
list_test_runstestingRecent runs, filterable by commit, branch, or status
get_test_run_detailstestingIndividual results for one run, with stack traces
get_failure_clusterstestingFailed tests grouped by error similarity
get_slowest_teststestingSlowest tests by average and P95 duration
compare_test_metricstestingBefore/after metrics across two commits or runs
search_failurestestingPast failures matching an error or test-name pattern
get_coverage_summarycoverageLine, branch, and function coverage, plus trend
get_coverage_for_filecoverageCoverage for an exact or partial file path
get_untested_filescoverageFiles below a coverage threshold
find_uncovered_failure_areascoverageFiles with low coverage and test failures
get_reportreportsReport file URLs for a test run
get_report_browser_urlreportsSigned browser URL, valid 30 minutes
get_upload_statusuploadsWhether CI results are uploaded and processed
upload_test_resultsuploadsUploads structured test results to a project (the one write function)

With a project token (gfr_), omit projectId on every function. It resolves automatically. list_projects and get_report are not available with one.

Yes. Every page on gaffer.sh registers four read-only WebMCP tools on document.modelContext, for browser agents rather than MCP clients. They cover the site, not your test data: gaffer.search_docs, gaffer.get_pricing, gaffer.install_mcp, and gaffer.signup_url. As of August 2026 the API is available only in Chrome’s origin trial, and the MCP server above remains the way to give an assistant your test history. Background: WebMCP on gaffer.sh.

Once the MCP server is connected, try asking your AI assistant:

  • “What projects do I have in Gaffer?”
  • “What’s the health of my test suite?”
  • “Which tests are flaky in my project?”
  • “Is the login test flaky? Check its history”
  • “What tests failed in the last commit?”
  • “Show me test runs on the main branch”
  • “Which tests are slowing down my CI pipeline?”
  • “Get the Playwright report for the latest test run”

These apply to the npm package. The hosted endpoint takes a key in the Authorization header, or you sign in with OAuth.

VariableRequiredDescription
GAFFER_API_KEYYesYour Gaffer API Key (starts with gaf_)
GAFFER_API_URLNoAPI base URL (default: https://app.gaffer.sh)
CredentialPrefixScopeWhat it can do
OAuth sign-innoneOne organization, chosen at sign-inRead functions only. No upload_test_results. list_projects lists that organization’s projects. Hosted endpoint only.
User API keygaf_Every project your account can reachRead functions, plus upload_test_results. list_projects lists projects in every organization you belong to.
Project tokengfr_One projectRead functions and upload_test_results for that project. Omit projectId.

Create a user API key under Account Settings > API Keys in the Gaffer dashboard. The hosted endpoint and the npm package serve the same functions, so both can upload. Uploads are rate-limited to 300 per hour per project and recorded in the project’s audit log.