@gaffer-sh/mcp 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -138,7 +138,7 @@ var GafferApiClient = class GafferApiClient {
138
138
  * @param options.offset - Offset for pagination
139
139
  */
140
140
  async listProjects(options = {}) {
141
- if (!this.isUserToken()) throw new Error("listProjects requires a user API Key (gaf_). Upload Tokens (gfr_) can only access a single project.");
141
+ if (!this.isUserToken()) throw new Error("list_projects is not available with project tokens (gfr_). Your token is already scoped to a single project — call tools directly without passing projectId.");
142
142
  return this.request("/user/projects", {
143
143
  ...options.organizationId && { organizationId: options.organizationId },
144
144
  ...options.limit && { limit: options.limit },
@@ -443,7 +443,7 @@ var GafferApiClient = class GafferApiClient {
443
443
  * Input schema for compare_test_metrics tool
444
444
  */
445
445
  const compareTestMetricsInputSchema = {
446
- projectId: z.string().describe("Project ID. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
446
+ projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
447
447
  testName: z.string().describe("The test name to compare. Can be the short name or full name including describe blocks."),
448
448
  beforeCommit: z.string().optional().describe("Commit SHA for the \"before\" measurement. Use with afterCommit."),
449
449
  afterCommit: z.string().optional().describe("Commit SHA for the \"after\" measurement. Use with beforeCommit."),
@@ -517,9 +517,6 @@ const compareTestMetricsMetadata = {
517
517
 
518
518
  Useful for measuring the impact of code changes on test performance or reliability.
519
519
 
520
- When using a user API Key (gaf_), you must provide a projectId.
521
- Use list_projects to find available project IDs.
522
-
523
520
  Parameters:
524
521
  - projectId (required): Project ID
525
522
  - testName (required): The test name to compare (short name or full name)
@@ -556,7 +553,7 @@ Tip: Use get_test_history first to find the commit SHAs or test run IDs you want
556
553
  * Input schema for find_uncovered_failure_areas tool
557
554
  */
558
555
  const findUncoveredFailureAreasInputSchema = {
559
- projectId: z.string().describe("Project ID to analyze. Required. Use list_projects to find project IDs."),
556
+ projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
560
557
  days: z.number().int().min(1).max(365).optional().describe("Number of days to analyze for test failures (default: 30)"),
561
558
  coverageThreshold: z.number().min(0).max(100).optional().describe("Include files with coverage below this percentage (default: 80)")
562
559
  };
@@ -603,9 +600,6 @@ This cross-references test failures with coverage data to identify high-risk
603
600
  areas in your codebase that need attention. Files are ranked by a "risk score"
604
601
  calculated as: (100 - coverage%) × failureCount.
605
602
 
606
- When using a user API Key (gaf_), you must provide a projectId.
607
- Use list_projects first to find available project IDs.
608
-
609
603
  Parameters:
610
604
  - projectId: The project to analyze (required)
611
605
  - days: Analysis period for test failures (default: 30)
@@ -624,7 +618,7 @@ Use this to prioritize which parts of your codebase need better test coverage.`
624
618
  * Input schema for get_coverage_for_file tool
625
619
  */
626
620
  const getCoverageForFileInputSchema = {
627
- projectId: z.string().describe("Project ID to get coverage for. Required. Use list_projects to find project IDs."),
621
+ projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
628
622
  filePath: z.string().describe("File path to get coverage for. Can be exact path or partial match.")
629
623
  };
630
624
  /**
@@ -680,9 +674,6 @@ const getCoverageForFileMetadata = {
680
674
  title: "Get Coverage for File",
681
675
  description: `Get coverage metrics for a specific file or files matching a path pattern.
682
676
 
683
- When using a user API Key (gaf_), you must provide a projectId.
684
- Use list_projects first to find available project IDs.
685
-
686
677
  Parameters:
687
678
  - projectId: The project to query (required)
688
679
  - filePath: File path to search for (exact or partial match)
@@ -710,7 +701,7 @@ Prioritize: high utilization + low coverage = highest impact.`
710
701
  * Input schema for get_coverage_summary tool
711
702
  */
712
703
  const getCoverageSummaryInputSchema = {
713
- projectId: z.string().describe("Project ID to get coverage for. Required. Use list_projects to find project IDs."),
704
+ projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
714
705
  days: z.number().int().min(1).max(365).optional().describe("Number of days to analyze for trends (default: 30)")
715
706
  };
716
707
  /**
@@ -765,9 +756,6 @@ const getCoverageSummaryMetadata = {
765
756
  title: "Get Coverage Summary",
766
757
  description: `Get the coverage metrics summary for a project.
767
758
 
768
- When using a user API Key (gaf_), you must provide a projectId.
769
- Use list_projects first to find available project IDs.
770
-
771
759
  Returns:
772
760
  - Current coverage percentages (lines, branches, functions)
773
761
  - Trend direction (up, down, stable) and change amount
@@ -789,7 +777,7 @@ high-value targets in critical code paths rather than just the files with lowest
789
777
  */
790
778
  const getFailureClustersInputSchema = {
791
779
  projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
792
- testRunId: z.string().describe("Test run ID to get failure clusters for. Use list_test_runs to find test run IDs.")
780
+ testRunId: z.string().describe("Test run ID. Use list_test_runs to find test run IDs.")
793
781
  };
794
782
  /**
795
783
  * Output schema for get_failure_clusters tool
@@ -825,9 +813,6 @@ const getFailureClustersMetadata = {
825
813
  title: "Get Failure Clusters",
826
814
  description: `Group failed tests by root cause using error message similarity.
827
815
 
828
- When using a user API Key (gaf_), you must provide a projectId.
829
- Use list_projects to find available project IDs, and list_test_runs to find test run IDs.
830
-
831
816
  Parameters:
832
817
  - projectId (required): The project ID
833
818
  - testRunId (required): The test run ID to analyze
@@ -859,7 +844,7 @@ then use this tool to understand which failures share the same root cause.`
859
844
  * Input schema for get_flaky_tests tool
860
845
  */
861
846
  const getFlakyTestsInputSchema = {
862
- projectId: z.string().optional().describe("Project ID to get flaky tests for. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
847
+ projectId: z.string().optional().describe("Project ID. Required for user API keys (gaf_). Not needed for project tokens — omit and it resolves automatically."),
863
848
  threshold: z.number().min(0).max(1).optional().describe("Minimum flip rate to be considered flaky (0-1, default: 0.1 = 10%)"),
864
849
  limit: z.number().int().min(1).max(100).optional().describe("Maximum number of flaky tests to return (default: 50)"),
865
850
  days: z.number().int().min(1).max(365).optional().describe("Analysis period in days (default: 30)")
@@ -873,7 +858,8 @@ const getFlakyTestsOutputSchema = {
873
858
  flipRate: z.number(),
874
859
  flipCount: z.number(),
875
860
  totalRuns: z.number(),
876
- lastSeen: z.string()
861
+ lastSeen: z.string(),
862
+ flakinessScore: z.number()
877
863
  })),
878
864
  summary: z.object({
879
865
  threshold: z.number(),
@@ -904,19 +890,18 @@ const getFlakyTestsMetadata = {
904
890
  title: "Get Flaky Tests",
905
891
  description: `Get the list of flaky tests in a project.
906
892
 
907
- When using a user API Key (gaf_), you must provide a projectId.
908
- Use list_projects first to find available project IDs.
909
-
910
- A test is considered flaky if it frequently switches between pass and fail states
911
- (high "flip rate"). This helps identify unreliable tests that need attention.
893
+ A test is considered flaky if it frequently switches between pass and fail states.
894
+ Tests are ranked by a composite flakinessScore that factors in flip behavior,
895
+ failure rate, and duration variability.
912
896
 
913
897
  Returns:
914
- - List of flaky tests with:
898
+ - List of flaky tests sorted by flakinessScore (most flaky first), with:
915
899
  - name: Test name
916
900
  - flipRate: How often the test flips between pass/fail (0-1)
917
901
  - flipCount: Number of status transitions
918
902
  - totalRuns: Total test executions analyzed
919
903
  - lastSeen: When the test last ran
904
+ - flakinessScore: Composite score (0-1) combining flip proximity, failure rate, and duration variability
920
905
  - Summary with threshold used and total count
921
906
 
922
907
  Use this after get_project_health shows flaky tests exist, to identify which
@@ -929,7 +914,7 @@ specific tests are flaky and need investigation.`
929
914
  * Input schema for get_project_health tool
930
915
  */
931
916
  const getProjectHealthInputSchema = {
932
- projectId: z.string().optional().describe("Project ID to get health for. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
917
+ projectId: z.string().optional().describe("Project ID. Required for user API keys (gaf_). Not needed for project tokens — omit and it resolves automatically."),
933
918
  days: z.number().int().min(1).max(365).optional().describe("Number of days to analyze (default: 30)")
934
919
  };
935
920
  /**
@@ -978,9 +963,6 @@ const getProjectHealthMetadata = {
978
963
  title: "Get Project Health",
979
964
  description: `Get the health metrics for a project.
980
965
 
981
- When using a user API Key (gaf_), you must provide a projectId.
982
- Use list_projects first to find available project IDs.
983
-
984
966
  Returns:
985
967
  - Health score (0-100): Overall project health based on pass rate and trend
986
968
  - Pass rate: Percentage of tests passing
@@ -997,7 +979,7 @@ Use this to understand the current state of your test suite.`
997
979
  * Input schema for get_report_browser_url tool
998
980
  */
999
981
  const getReportBrowserUrlInputSchema = {
1000
- projectId: z.string().describe("Project ID the test run belongs to. Required. Use list_projects to find project IDs."),
982
+ projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
1001
983
  testRunId: z.string().describe("The test run ID to get the report URL for. Use list_test_runs to find test run IDs."),
1002
984
  filename: z.string().optional().describe("Specific file to open (default: index.html or first HTML file)")
1003
985
  };
@@ -1039,9 +1021,6 @@ const getReportBrowserUrlMetadata = {
1039
1021
  Returns a signed URL that can be opened directly in a browser without requiring
1040
1022
  the user to log in. The URL expires after 30 minutes for security.
1041
1023
 
1042
- When using a user API Key (gaf_), you must provide both projectId and testRunId.
1043
- Use list_projects and list_test_runs to find available IDs.
1044
-
1045
1024
  Parameters:
1046
1025
  - projectId: The project the test run belongs to (required)
1047
1026
  - testRunId: The test run to view (required)
@@ -1146,7 +1125,7 @@ Use cases:
1146
1125
  * Input schema for get_slowest_tests tool
1147
1126
  */
1148
1127
  const getSlowestTestsInputSchema = {
1149
- projectId: z.string().describe("Project ID to get slowest tests for. Required. Use list_projects to find project IDs."),
1128
+ projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
1150
1129
  days: z.number().int().min(1).max(365).optional().describe("Analysis period in days (default: 30)"),
1151
1130
  limit: z.number().int().min(1).max(100).optional().describe("Maximum number of tests to return (default: 20)"),
1152
1131
  framework: z.string().optional().describe("Filter by test framework (e.g., \"playwright\", \"vitest\", \"jest\")"),
@@ -1204,9 +1183,6 @@ const getSlowestTestsMetadata = {
1204
1183
  title: "Get Slowest Tests",
1205
1184
  description: `Get the slowest tests in a project, sorted by P95 duration.
1206
1185
 
1207
- When using a user API Key (gaf_), you must provide a projectId.
1208
- Use list_projects first to find available project IDs.
1209
-
1210
1186
  Parameters:
1211
1187
  - projectId (required): Project ID to analyze
1212
1188
  - days (optional): Analysis period in days (default: 30, max: 365)
@@ -1238,7 +1214,7 @@ Use cases:
1238
1214
  * Input schema for get_test_history tool
1239
1215
  */
1240
1216
  const getTestHistoryInputSchema = {
1241
- projectId: z.string().optional().describe("Project ID to get test history for. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
1217
+ projectId: z.string().optional().describe("Project ID. Required for user API keys (gaf_). Not needed for project tokens — omit and it resolves automatically."),
1242
1218
  testName: z.string().optional().describe("Exact test name to search for"),
1243
1219
  filePath: z.string().optional().describe("File path containing the test"),
1244
1220
  limit: z.number().int().min(1).max(100).optional().describe("Maximum number of results (default: 20)")
@@ -1305,9 +1281,6 @@ const getTestHistoryMetadata = {
1305
1281
  title: "Get Test History",
1306
1282
  description: `Get the pass/fail history for a specific test.
1307
1283
 
1308
- When using a user API Key (gaf_), you must provide a projectId.
1309
- Use list_projects first to find available project IDs.
1310
-
1311
1284
  Search by either:
1312
1285
  - testName: The exact name of the test (e.g., "should handle user login")
1313
1286
  - filePath: The file path containing the test (e.g., "tests/auth.test.ts")
@@ -1329,7 +1302,7 @@ Use this to investigate flaky tests or understand test stability.`
1329
1302
  */
1330
1303
  const getTestRunDetailsInputSchema = {
1331
1304
  testRunId: z.string().describe("The test run ID to get details for. Use list_test_runs to find test run IDs."),
1332
- projectId: z.string().describe("Project ID the test run belongs to. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
1305
+ projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
1333
1306
  status: z.enum([
1334
1307
  "passed",
1335
1308
  "failed",
@@ -1403,9 +1376,6 @@ const getTestRunDetailsMetadata = {
1403
1376
  title: "Get Test Run Details",
1404
1377
  description: `Get parsed test results for a specific test run.
1405
1378
 
1406
- When using a user API Key (gaf_), you must provide a projectId.
1407
- Use list_projects to find available project IDs, and list_test_runs to find test run IDs.
1408
-
1409
1379
  Parameters:
1410
1380
  - testRunId (required): The test run ID to get details for
1411
1381
  - projectId (required): Project ID the test run belongs to
@@ -1446,7 +1416,7 @@ use get_test_history, get_flaky_tests, or get_slowest_tests instead.`
1446
1416
  * Input schema for get_untested_files tool
1447
1417
  */
1448
1418
  const getUntestedFilesInputSchema = {
1449
- projectId: z.string().describe("Project ID to analyze. Required. Use list_projects to find project IDs."),
1419
+ projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
1450
1420
  maxCoverage: z.number().min(0).max(100).optional().describe("Maximum coverage percentage to include (default: 10 for \"untested\")"),
1451
1421
  limit: z.number().int().min(1).max(100).optional().describe("Maximum number of files to return (default: 20)")
1452
1422
  };
@@ -1512,9 +1482,6 @@ const getUntestedFilesMetadata = {
1512
1482
  Returns files sorted by coverage percentage (lowest first), filtered
1513
1483
  to only include files below a coverage threshold.
1514
1484
 
1515
- When using a user API Key (gaf_), you must provide a projectId.
1516
- Use list_projects first to find available project IDs.
1517
-
1518
1485
  Parameters:
1519
1486
  - projectId: The project to analyze (required)
1520
1487
  - maxCoverage: Include files with coverage at or below this % (default: 10)
@@ -1708,7 +1675,7 @@ Requires a user API Key (gaf_). Get one from Account Settings in the Gaffer dash
1708
1675
  * Input schema for list_test_runs tool
1709
1676
  */
1710
1677
  const listTestRunsInputSchema = {
1711
- projectId: z.string().optional().describe("Project ID to list test runs for. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
1678
+ projectId: z.string().optional().describe("Project ID. Required for user API keys (gaf_). Not needed for project tokens — omit and it resolves automatically."),
1712
1679
  commitSha: z.string().optional().describe("Filter by commit SHA (exact or prefix match)"),
1713
1680
  branch: z.string().optional().describe("Filter by branch name"),
1714
1681
  status: z.enum(["passed", "failed"]).optional().describe("Filter by status: \"passed\" (no failures) or \"failed\" (has failures)"),
@@ -1769,9 +1736,6 @@ const listTestRunsMetadata = {
1769
1736
  title: "List Test Runs",
1770
1737
  description: `List recent test runs for a project with optional filtering.
1771
1738
 
1772
- When using a user API Key (gaf_), you must provide a projectId.
1773
- Use list_projects first to find available project IDs.
1774
-
1775
1739
  Filter by:
1776
1740
  - commitSha: Filter by commit SHA (supports prefix matching)
1777
1741
  - branch: Filter by branch name
@@ -1873,6 +1837,10 @@ async function main() {
1873
1837
  version: "0.1.0"
1874
1838
  }, { instructions: `Gaffer provides test analytics and coverage data for your projects.
1875
1839
 
1840
+ ## Authentication
1841
+
1842
+ ${client.isUserToken() ? "You have access to multiple projects. Use `list_projects` to find project IDs, then pass `projectId` to all tools." : "Your token is scoped to a single project. Do NOT call `list_projects`. Do NOT pass `projectId` — it is resolved automatically. Note: some tools (coverage, failure clusters, slowest tests, etc.) require a user API key and are not available."}
1843
+
1876
1844
  ## Coverage Analysis Best Practices
1877
1845
 
1878
1846
  When helping users improve test coverage, combine coverage data with codebase exploration:
@@ -1956,7 +1924,7 @@ When an agent needs to know if CI results are ready:
1956
1924
  outputSchema: listTestRunsOutputSchema,
1957
1925
  execute: executeListTestRuns
1958
1926
  });
1959
- registerTool(server, client, {
1927
+ if (client.isUserToken()) registerTool(server, client, {
1960
1928
  metadata: listProjectsMetadata,
1961
1929
  inputSchema: listProjectsInputSchema,
1962
1930
  outputSchema: listProjectsOutputSchema,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/api-client.ts","../src/tools/compare-test-metrics.ts","../src/tools/find-uncovered-failure-areas.ts","../src/tools/get-coverage-for-file.ts","../src/tools/get-coverage-summary.ts","../src/tools/get-failure-clusters.ts","../src/tools/get-flaky-tests.ts","../src/tools/get-project-health.ts","../src/tools/get-report-browser-url.ts","../src/tools/get-report.ts","../src/tools/get-slowest-tests.ts","../src/tools/get-test-history.ts","../src/tools/get-test-run-details.ts","../src/tools/get-untested-files.ts","../src/tools/get-upload-status.ts","../src/tools/list-projects.ts","../src/tools/list-test-runs.ts","../src/index.ts"],"sourcesContent":["import type {\n AnalyticsResponse,\n ApiErrorResponse,\n BrowserUrlResponse,\n CompareTestResponse,\n CoverageFilesResponse,\n CoverageRiskAreasResponse,\n CoverageSummaryResponse,\n FailureClustersResponse,\n FlakyTestsResponse,\n GafferConfig,\n ProjectsResponse,\n ReportResponse,\n SlowestTestsResponse,\n TestHistoryResponse,\n TestRunDetailsResponse,\n TestRunsResponse,\n UploadSessionDetailResponse,\n UploadSessionsResponse,\n} from './types.js'\nimport { createRequire } from 'node:module'\n\nconst require = createRequire(import.meta.url)\nconst pkg = require('../package.json') as { version: string }\n\n// Request timeout in milliseconds (30 seconds)\nconst REQUEST_TIMEOUT_MS = 30000\n\n// Retry configuration\nconst MAX_RETRIES = 3\nconst INITIAL_RETRY_DELAY_MS = 1000\nconst RETRYABLE_STATUS_CODES = [401, 429, 500, 502, 503, 504]\n\n/**\n * Sleep for a given number of milliseconds\n */\nfunction sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\n/**\n * Token type detection based on prefix\n */\nexport type TokenType = 'user' | 'project'\n\n/**\n * Detect token type from prefix\n * - gaf_ = user API Key (read-only, cross-project)\n * - gfr_ = Project Upload Token (legacy, single project)\n */\nexport function detectTokenType(token: string): TokenType {\n if (token.startsWith('gaf_')) {\n return 'user'\n }\n return 'project'\n}\n\n/**\n * Gaffer API v1 client for MCP server\n *\n * Supports two authentication modes:\n * 1. User API Keys (gaf_) - Read-only access to all user's projects\n * 2. Project Upload Tokens (gfr_) - Legacy, single project access\n */\nexport class GafferApiClient {\n private apiKey: string\n private baseUrl: string\n public readonly tokenType: TokenType\n\n constructor(config: GafferConfig) {\n this.apiKey = config.apiKey\n this.baseUrl = config.baseUrl.replace(/\\/$/, '') // Remove trailing slash\n this.tokenType = detectTokenType(config.apiKey)\n }\n\n /**\n * Create client from environment variables\n *\n * Supports:\n * - GAFFER_API_KEY (for user API Keys gaf_)\n */\n static fromEnv(): GafferApiClient {\n const apiKey = process.env.GAFFER_API_KEY\n if (!apiKey) {\n throw new Error('GAFFER_API_KEY environment variable is required')\n }\n\n const baseUrl = process.env.GAFFER_API_URL || 'https://app.gaffer.sh'\n\n return new GafferApiClient({ apiKey, baseUrl })\n }\n\n /**\n * Check if using a user API Key (enables cross-project features)\n */\n isUserToken(): boolean {\n return this.tokenType === 'user'\n }\n\n /**\n * Make authenticated request to Gaffer API with retry logic\n */\n private async request<T>(\n endpoint: string,\n params?: Record<string, string | number>,\n ): Promise<T> {\n const url = new URL(`/api/v1${endpoint}`, this.baseUrl)\n\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value))\n }\n }\n }\n\n let lastError: Error | null = null\n\n for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {\n // Set up request timeout\n const controller = new AbortController()\n const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS)\n\n try {\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'X-API-Key': this.apiKey,\n 'Accept': 'application/json',\n 'User-Agent': `gaffer-mcp/${pkg.version}`,\n },\n signal: controller.signal,\n })\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({})) as ApiErrorResponse\n\n // Check if we should retry this status code\n if (RETRYABLE_STATUS_CODES.includes(response.status) && attempt < MAX_RETRIES) {\n // For 429 (rate limit), use Retry-After header if available\n let delayMs = INITIAL_RETRY_DELAY_MS * (2 ** attempt)\n if (response.status === 429) {\n const retryAfter = response.headers.get('Retry-After')\n if (retryAfter) {\n delayMs = Math.max(delayMs, Number.parseInt(retryAfter, 10) * 1000)\n }\n }\n lastError = new Error(errorData.error?.message || `API request failed: ${response.status}`)\n await sleep(delayMs)\n continue\n }\n\n const errorMessage = errorData.error?.message || `API request failed: ${response.status}`\n throw new Error(errorMessage)\n }\n\n return response.json() as Promise<T>\n }\n catch (error) {\n clearTimeout(timeoutId)\n\n if (error instanceof Error && error.name === 'AbortError') {\n lastError = new Error(`Request timed out after ${REQUEST_TIMEOUT_MS}ms`)\n if (attempt < MAX_RETRIES) {\n await sleep(INITIAL_RETRY_DELAY_MS * (2 ** attempt))\n continue\n }\n throw lastError\n }\n\n // For network errors, retry\n if (error instanceof TypeError && attempt < MAX_RETRIES) {\n lastError = error\n await sleep(INITIAL_RETRY_DELAY_MS * (2 ** attempt))\n continue\n }\n\n throw error\n }\n finally {\n clearTimeout(timeoutId)\n }\n }\n\n // Should not reach here, but just in case\n throw lastError || new Error('Request failed after retries')\n }\n\n /**\n * List all projects the user has access to\n * Requires user API Key (gaf_)\n *\n * @param options - Query options\n * @param options.organizationId - Filter by organization ID\n * @param options.limit - Maximum number of results\n * @param options.offset - Offset for pagination\n */\n async listProjects(options: {\n organizationId?: string\n limit?: number\n offset?: number\n } = {}): Promise<ProjectsResponse> {\n if (!this.isUserToken()) {\n throw new Error('listProjects requires a user API Key (gaf_). Upload Tokens (gfr_) can only access a single project.')\n }\n\n return this.request<ProjectsResponse>('/user/projects', {\n ...(options.organizationId && { organizationId: options.organizationId }),\n ...(options.limit && { limit: options.limit }),\n ...(options.offset && { offset: options.offset }),\n })\n }\n\n /**\n * Get project health analytics\n *\n * @param options - Query options\n * @param options.projectId - Required for user tokens, ignored for project tokens\n * @param options.days - Analysis period in days (default: 30)\n */\n async getProjectHealth(options: {\n projectId?: string\n days?: number\n } = {}): Promise<AnalyticsResponse> {\n if (this.isUserToken()) {\n if (!options.projectId) {\n throw new Error('projectId is required when using a user API Key')\n }\n return this.request<AnalyticsResponse>(`/user/projects/${options.projectId}/health`, {\n days: options.days || 30,\n })\n }\n\n // Legacy: project token uses /project/analytics\n return this.request<AnalyticsResponse>('/project/analytics', {\n days: options.days || 30,\n })\n }\n\n /**\n * Get test history for a specific test\n *\n * @param options - Query options\n * @param options.projectId - Required for user tokens, ignored for project tokens\n * @param options.testName - Test name to search for\n * @param options.filePath - File path to search for\n * @param options.limit - Maximum number of results\n */\n async getTestHistory(options: {\n projectId?: string\n testName?: string\n filePath?: string\n limit?: number\n }): Promise<TestHistoryResponse> {\n const testName = options.testName?.trim()\n const filePath = options.filePath?.trim()\n\n if (!testName && !filePath) {\n throw new Error('Either testName or filePath is required (and must not be empty)')\n }\n\n if (this.isUserToken()) {\n if (!options.projectId) {\n throw new Error('projectId is required when using a user API Key')\n }\n return this.request<TestHistoryResponse>(`/user/projects/${options.projectId}/test-history`, {\n ...(testName && { testName }),\n ...(filePath && { filePath }),\n ...(options.limit && { limit: options.limit }),\n })\n }\n\n // Legacy: project token uses /project/test-history\n return this.request<TestHistoryResponse>('/project/test-history', {\n ...(testName && { testName }),\n ...(filePath && { filePath }),\n ...(options.limit && { limit: options.limit }),\n })\n }\n\n /**\n * Get flaky tests for the project\n *\n * @param options - Query options\n * @param options.projectId - Required for user tokens, ignored for project tokens\n * @param options.threshold - Minimum flip rate to be considered flaky (0-1)\n * @param options.limit - Maximum number of results\n * @param options.days - Analysis period in days\n */\n async getFlakyTests(options: {\n projectId?: string\n threshold?: number\n limit?: number\n days?: number\n } = {}): Promise<FlakyTestsResponse> {\n if (this.isUserToken()) {\n if (!options.projectId) {\n throw new Error('projectId is required when using a user API Key')\n }\n return this.request<FlakyTestsResponse>(`/user/projects/${options.projectId}/flaky-tests`, {\n ...(options.threshold && { threshold: options.threshold }),\n ...(options.limit && { limit: options.limit }),\n ...(options.days && { days: options.days }),\n })\n }\n\n // Legacy: project token uses /project/flaky-tests\n return this.request<FlakyTestsResponse>('/project/flaky-tests', {\n ...(options.threshold && { threshold: options.threshold }),\n ...(options.limit && { limit: options.limit }),\n ...(options.days && { days: options.days }),\n })\n }\n\n /**\n * List test runs for the project\n *\n * @param options - Query options\n * @param options.projectId - Required for user tokens, ignored for project tokens\n * @param options.commitSha - Filter by commit SHA\n * @param options.branch - Filter by branch name\n * @param options.status - Filter by status ('passed' or 'failed')\n * @param options.limit - Maximum number of results\n */\n async getTestRuns(options: {\n projectId?: string\n commitSha?: string\n branch?: string\n status?: 'passed' | 'failed'\n limit?: number\n } = {}): Promise<TestRunsResponse> {\n if (this.isUserToken()) {\n if (!options.projectId) {\n throw new Error('projectId is required when using a user API Key')\n }\n return this.request<TestRunsResponse>(`/user/projects/${options.projectId}/test-runs`, {\n ...(options.commitSha && { commitSha: options.commitSha }),\n ...(options.branch && { branch: options.branch }),\n ...(options.status && { status: options.status }),\n ...(options.limit && { limit: options.limit }),\n })\n }\n\n // Legacy: project token uses /project/test-runs\n return this.request<TestRunsResponse>('/project/test-runs', {\n ...(options.commitSha && { commitSha: options.commitSha }),\n ...(options.branch && { branch: options.branch }),\n ...(options.status && { status: options.status }),\n ...(options.limit && { limit: options.limit }),\n })\n }\n\n /**\n * Get report files for a test run\n *\n * @param testRunId - The test run ID\n * @returns Report metadata with download URLs for each file\n */\n async getReport(testRunId: string): Promise<ReportResponse> {\n if (!this.isUserToken()) {\n throw new Error('getReport requires a user API Key (gaf_). Upload Tokens (gfr_) cannot access reports via API.')\n }\n\n if (!testRunId) {\n throw new Error('testRunId is required')\n }\n\n return this.request<ReportResponse>(`/user/test-runs/${testRunId}/report`)\n }\n\n /**\n * Get slowest tests for a project\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.days - Analysis period in days (default: 30)\n * @param options.limit - Maximum number of results (default: 20)\n * @param options.framework - Filter by test framework\n * @param options.branch - Filter by git branch name\n * @returns Slowest tests sorted by P95 duration\n */\n async getSlowestTests(options: {\n projectId: string\n days?: number\n limit?: number\n framework?: string\n branch?: string\n }): Promise<SlowestTestsResponse> {\n if (!this.isUserToken()) {\n throw new Error('getSlowestTests requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n return this.request<SlowestTestsResponse>(`/user/projects/${options.projectId}/slowest-tests`, {\n ...(options.days && { days: options.days }),\n ...(options.limit && { limit: options.limit }),\n ...(options.framework && { framework: options.framework }),\n ...(options.branch && { branch: options.branch }),\n })\n }\n\n /**\n * Get parsed test results for a specific test run\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.testRunId - The test run ID (required)\n * @param options.status - Filter by test status ('passed', 'failed', 'skipped')\n * @param options.limit - Maximum number of results (default: 100)\n * @param options.offset - Pagination offset (default: 0)\n * @returns Parsed test cases with pagination\n */\n async getTestRunDetails(options: {\n projectId: string\n testRunId: string\n status?: 'passed' | 'failed' | 'skipped'\n limit?: number\n offset?: number\n }): Promise<TestRunDetailsResponse> {\n if (!this.isUserToken()) {\n throw new Error('getTestRunDetails requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n if (!options.testRunId) {\n throw new Error('testRunId is required')\n }\n\n return this.request<TestRunDetailsResponse>(\n `/user/projects/${options.projectId}/test-runs/${options.testRunId}/details`,\n {\n ...(options.status && { status: options.status }),\n ...(options.limit && { limit: options.limit }),\n ...(options.offset && { offset: options.offset }),\n },\n )\n }\n\n /**\n * Compare test metrics between two commits or test runs\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.testName - The test name to compare (required)\n * @param options.beforeCommit - Commit SHA for before (use with afterCommit)\n * @param options.afterCommit - Commit SHA for after (use with beforeCommit)\n * @param options.beforeRunId - Test run ID for before (use with afterRunId)\n * @param options.afterRunId - Test run ID for after (use with beforeRunId)\n * @returns Comparison of test metrics\n */\n async compareTestMetrics(options: {\n projectId: string\n testName: string\n beforeCommit?: string\n afterCommit?: string\n beforeRunId?: string\n afterRunId?: string\n }): Promise<CompareTestResponse> {\n if (!this.isUserToken()) {\n throw new Error('compareTestMetrics requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n if (!options.testName) {\n throw new Error('testName is required')\n }\n\n return this.request<CompareTestResponse>(\n `/user/projects/${options.projectId}/compare-test`,\n {\n testName: options.testName,\n ...(options.beforeCommit && { beforeCommit: options.beforeCommit }),\n ...(options.afterCommit && { afterCommit: options.afterCommit }),\n ...(options.beforeRunId && { beforeRunId: options.beforeRunId }),\n ...(options.afterRunId && { afterRunId: options.afterRunId }),\n },\n )\n }\n\n /**\n * Get coverage summary for a project\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.days - Analysis period in days (default: 30)\n * @returns Coverage summary with trends and lowest coverage files\n */\n async getCoverageSummary(options: {\n projectId: string\n days?: number\n }): Promise<CoverageSummaryResponse> {\n if (!this.isUserToken()) {\n throw new Error('getCoverageSummary requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n return this.request<CoverageSummaryResponse>(\n `/user/projects/${options.projectId}/coverage-summary`,\n {\n ...(options.days && { days: options.days }),\n },\n )\n }\n\n /**\n * Get coverage files for a project with filtering\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.filePath - Filter to specific file path\n * @param options.minCoverage - Minimum coverage percentage\n * @param options.maxCoverage - Maximum coverage percentage\n * @param options.limit - Maximum number of results\n * @param options.offset - Pagination offset\n * @param options.sortBy - Sort by 'path' or 'coverage'\n * @param options.sortOrder - Sort order 'asc' or 'desc'\n * @returns List of files with coverage data\n */\n async getCoverageFiles(options: {\n projectId: string\n filePath?: string\n minCoverage?: number\n maxCoverage?: number\n limit?: number\n offset?: number\n sortBy?: 'path' | 'coverage'\n sortOrder?: 'asc' | 'desc'\n }): Promise<CoverageFilesResponse> {\n if (!this.isUserToken()) {\n throw new Error('getCoverageFiles requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n return this.request<CoverageFilesResponse>(\n `/user/projects/${options.projectId}/coverage/files`,\n {\n ...(options.filePath && { filePath: options.filePath }),\n ...(options.minCoverage !== undefined && { minCoverage: options.minCoverage }),\n ...(options.maxCoverage !== undefined && { maxCoverage: options.maxCoverage }),\n ...(options.limit && { limit: options.limit }),\n ...(options.offset && { offset: options.offset }),\n ...(options.sortBy && { sortBy: options.sortBy }),\n ...(options.sortOrder && { sortOrder: options.sortOrder }),\n },\n )\n }\n\n /**\n * Get risk areas (files with low coverage AND test failures)\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.days - Analysis period in days (default: 30)\n * @param options.coverageThreshold - Include files below this coverage (default: 80)\n * @returns List of risk areas sorted by risk score\n */\n async getCoverageRiskAreas(options: {\n projectId: string\n days?: number\n coverageThreshold?: number\n }): Promise<CoverageRiskAreasResponse> {\n if (!this.isUserToken()) {\n throw new Error('getCoverageRiskAreas requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n return this.request<CoverageRiskAreasResponse>(\n `/user/projects/${options.projectId}/coverage/risk-areas`,\n {\n ...(options.days && { days: options.days }),\n ...(options.coverageThreshold !== undefined && { coverageThreshold: options.coverageThreshold }),\n },\n )\n }\n\n /**\n * Get a browser-navigable URL for viewing a test report\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.testRunId - The test run ID (required)\n * @param options.filename - Specific file to open (default: index.html)\n * @returns URL with signed token for browser access\n */\n async getReportBrowserUrl(options: {\n projectId: string\n testRunId: string\n filename?: string\n }): Promise<BrowserUrlResponse> {\n if (!this.isUserToken()) {\n throw new Error('getReportBrowserUrl requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n if (!options.testRunId) {\n throw new Error('testRunId is required')\n }\n\n return this.request<BrowserUrlResponse>(\n `/user/projects/${options.projectId}/reports/${options.testRunId}/browser-url`,\n {\n ...(options.filename && { filename: options.filename }),\n },\n )\n }\n\n /**\n * Get failure clusters for a test run\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.testRunId - The test run ID (required)\n * @returns Failure clusters grouped by error similarity\n */\n async getFailureClusters(options: {\n projectId: string\n testRunId: string\n }): Promise<FailureClustersResponse> {\n if (!this.isUserToken()) {\n throw new Error('getFailureClusters requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n if (!options.testRunId) {\n throw new Error('testRunId is required')\n }\n\n return this.request<FailureClustersResponse>(\n `/user/projects/${options.projectId}/test-runs/${options.testRunId}/failure-clusters`,\n )\n }\n\n /**\n * List upload sessions for a project\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.commitSha - Filter by commit SHA\n * @param options.branch - Filter by branch name\n * @param options.limit - Maximum number of results (default: 10)\n * @param options.offset - Pagination offset (default: 0)\n * @returns Paginated list of upload sessions\n */\n async listUploadSessions(options: {\n projectId: string\n commitSha?: string\n branch?: string\n limit?: number\n offset?: number\n }): Promise<UploadSessionsResponse> {\n if (!this.isUserToken()) {\n throw new Error('listUploadSessions requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n return this.request<UploadSessionsResponse>(\n `/user/projects/${options.projectId}/upload-sessions`,\n {\n ...(options.commitSha && { commitSha: options.commitSha }),\n ...(options.branch && { branch: options.branch }),\n ...(options.limit && { limit: options.limit }),\n ...(options.offset && { offset: options.offset }),\n },\n )\n }\n\n /**\n * Get upload session detail with linked results\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.sessionId - The upload session ID (required)\n * @returns Upload session details with linked test runs and coverage reports\n */\n async getUploadSessionDetail(options: {\n projectId: string\n sessionId: string\n }): Promise<UploadSessionDetailResponse> {\n if (!this.isUserToken()) {\n throw new Error('getUploadSessionDetail requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n if (!options.sessionId) {\n throw new Error('sessionId is required')\n }\n\n return this.request<UploadSessionDetailResponse>(\n `/user/projects/${options.projectId}/upload-sessions/${options.sessionId}`,\n )\n }\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport type { CompareTestResponse } from '../types.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for compare_test_metrics tool\n */\nexport const compareTestMetricsInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Required when using a user API Key (gaf_). Use list_projects to find project IDs.'),\n testName: z\n .string()\n .describe('The test name to compare. Can be the short name or full name including describe blocks.'),\n beforeCommit: z\n .string()\n .optional()\n .describe('Commit SHA for the \"before\" measurement. Use with afterCommit.'),\n afterCommit: z\n .string()\n .optional()\n .describe('Commit SHA for the \"after\" measurement. Use with beforeCommit.'),\n beforeRunId: z\n .string()\n .optional()\n .describe('Test run ID for the \"before\" measurement. Use with afterRunId.'),\n afterRunId: z\n .string()\n .optional()\n .describe('Test run ID for the \"after\" measurement. Use with beforeRunId.'),\n}\n\n/**\n * Output schema for compare_test_metrics tool\n */\nexport const compareTestMetricsOutputSchema = {\n testName: z.string(),\n before: z.object({\n testRunId: z.string(),\n commit: z.string().nullable(),\n branch: z.string().nullable(),\n status: z.enum(['passed', 'failed', 'skipped']),\n durationMs: z.number().nullable(),\n createdAt: z.string(),\n }),\n after: z.object({\n testRunId: z.string(),\n commit: z.string().nullable(),\n branch: z.string().nullable(),\n status: z.enum(['passed', 'failed', 'skipped']),\n durationMs: z.number().nullable(),\n createdAt: z.string(),\n }),\n change: z.object({\n durationMs: z.number().nullable(),\n percentChange: z.number().nullable(),\n statusChanged: z.boolean(),\n }),\n}\n\nexport interface CompareTestMetricsInput {\n projectId: string\n testName: string\n beforeCommit?: string\n afterCommit?: string\n beforeRunId?: string\n afterRunId?: string\n}\n\n// Re-export response type from types.ts for convenience\nexport type CompareTestMetricsOutput = CompareTestResponse\n\n/**\n * Execute compare_test_metrics tool\n */\nexport async function executeCompareTestMetrics(\n client: GafferApiClient,\n input: CompareTestMetricsInput,\n): Promise<CompareTestMetricsOutput> {\n // Validate input - check for presence of required pairs\n const hasCommits = input.beforeCommit && input.afterCommit\n const hasRunIds = input.beforeRunId && input.afterRunId\n\n if (!hasCommits && !hasRunIds) {\n throw new Error('Must provide either (beforeCommit + afterCommit) or (beforeRunId + afterRunId)')\n }\n\n // Validate non-empty strings\n if (hasCommits) {\n if (input.beforeCommit!.trim().length === 0 || input.afterCommit!.trim().length === 0) {\n throw new Error('beforeCommit and afterCommit must not be empty strings')\n }\n }\n\n if (hasRunIds) {\n if (input.beforeRunId!.trim().length === 0 || input.afterRunId!.trim().length === 0) {\n throw new Error('beforeRunId and afterRunId must not be empty strings')\n }\n }\n\n const response = await client.compareTestMetrics({\n projectId: input.projectId,\n testName: input.testName,\n beforeCommit: input.beforeCommit,\n afterCommit: input.afterCommit,\n beforeRunId: input.beforeRunId,\n afterRunId: input.afterRunId,\n })\n\n return response\n}\n\n/**\n * Tool metadata\n */\nexport const compareTestMetricsMetadata = {\n name: 'compare_test_metrics',\n title: 'Compare Test Metrics',\n description: `Compare test metrics between two commits or test runs.\n\nUseful for measuring the impact of code changes on test performance or reliability.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects to find available project IDs.\n\nParameters:\n- projectId (required): Project ID\n- testName (required): The test name to compare (short name or full name)\n- Option 1 - Compare by commit:\n - beforeCommit: Commit SHA for \"before\" measurement\n - afterCommit: Commit SHA for \"after\" measurement\n- Option 2 - Compare by test run:\n - beforeRunId: Test run ID for \"before\" measurement\n - afterRunId: Test run ID for \"after\" measurement\n\nReturns:\n- testName: The test that was compared\n- before: Metrics from the before commit/run\n - testRunId, commit, branch, status, durationMs, createdAt\n- after: Metrics from the after commit/run\n - testRunId, commit, branch, status, durationMs, createdAt\n- change: Calculated changes\n - durationMs: Duration difference (negative = faster)\n - percentChange: Percentage change (negative = improvement)\n - statusChanged: Whether pass/fail status changed\n\nUse cases:\n- \"Did my fix make this test faster?\"\n- \"Compare test performance between these two commits\"\n- \"Did this test start failing after my changes?\"\n- \"Show me the before/after for the slow test I optimized\"\n\nTip: Use get_test_history first to find the commit SHAs or test run IDs you want to compare.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for find_uncovered_failure_areas tool\n */\nexport const findUncoveredFailureAreasInputSchema = {\n projectId: z\n .string()\n .describe('Project ID to analyze. Required. Use list_projects to find project IDs.'),\n days: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Number of days to analyze for test failures (default: 30)'),\n coverageThreshold: z\n .number()\n .min(0)\n .max(100)\n .optional()\n .describe('Include files with coverage below this percentage (default: 80)'),\n}\n\n/**\n * Output schema for find_uncovered_failure_areas tool\n */\nexport const findUncoveredFailureAreasOutputSchema = {\n hasCoverage: z.boolean(),\n hasTestResults: z.boolean(),\n riskAreas: z.array(z.object({\n filePath: z.string(),\n coverage: z.number(),\n failureCount: z.number(),\n riskScore: z.number(),\n testNames: z.array(z.string()),\n })),\n message: z.string().optional(),\n}\n\nexport interface FindUncoveredFailureAreasInput {\n projectId: string\n days?: number\n coverageThreshold?: number\n}\n\nexport interface FindUncoveredFailureAreasOutput {\n hasCoverage: boolean\n hasTestResults: boolean\n riskAreas: Array<{\n filePath: string\n coverage: number\n failureCount: number\n riskScore: number\n testNames: string[]\n }>\n message?: string\n}\n\n/**\n * Execute find_uncovered_failure_areas tool\n */\nexport async function executeFindUncoveredFailureAreas(\n client: GafferApiClient,\n input: FindUncoveredFailureAreasInput,\n): Promise<FindUncoveredFailureAreasOutput> {\n const response = await client.getCoverageRiskAreas({\n projectId: input.projectId,\n days: input.days,\n coverageThreshold: input.coverageThreshold,\n })\n\n return {\n hasCoverage: response.hasCoverage,\n hasTestResults: response.hasTestResults,\n riskAreas: response.riskAreas,\n message: response.message,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const findUncoveredFailureAreasMetadata = {\n name: 'find_uncovered_failure_areas',\n title: 'Find Uncovered Failure Areas',\n description: `Find areas of code that have both low coverage AND test failures.\n\nThis cross-references test failures with coverage data to identify high-risk\nareas in your codebase that need attention. Files are ranked by a \"risk score\"\ncalculated as: (100 - coverage%) × failureCount.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects first to find available project IDs.\n\nParameters:\n- projectId: The project to analyze (required)\n- days: Analysis period for test failures (default: 30)\n- coverageThreshold: Include files below this coverage % (default: 80)\n\nReturns:\n- List of risk areas sorted by risk score (highest risk first)\n- Each area includes: file path, coverage %, failure count, risk score, test names\n\nUse this to prioritize which parts of your codebase need better test coverage.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_coverage_for_file tool\n */\nexport const getCoverageForFileInputSchema = {\n projectId: z\n .string()\n .describe('Project ID to get coverage for. Required. Use list_projects to find project IDs.'),\n filePath: z\n .string()\n .describe('File path to get coverage for. Can be exact path or partial match.'),\n}\n\n/**\n * Output schema for get_coverage_for_file tool\n */\nexport const getCoverageForFileOutputSchema = {\n hasCoverage: z.boolean(),\n files: z.array(z.object({\n path: z.string(),\n lines: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n branches: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n functions: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n })),\n message: z.string().optional(),\n}\n\nexport interface GetCoverageForFileInput {\n projectId: string\n filePath: string\n}\n\nexport interface GetCoverageForFileOutput {\n hasCoverage: boolean\n files: Array<{\n path: string\n lines: { covered: number, total: number, percentage: number }\n branches: { covered: number, total: number, percentage: number }\n functions: { covered: number, total: number, percentage: number }\n }>\n message?: string\n}\n\n/**\n * Execute get_coverage_for_file tool\n */\nexport async function executeGetCoverageForFile(\n client: GafferApiClient,\n input: GetCoverageForFileInput,\n): Promise<GetCoverageForFileOutput> {\n const response = await client.getCoverageFiles({\n projectId: input.projectId,\n filePath: input.filePath,\n limit: 10, // Return up to 10 matching files\n })\n\n return {\n hasCoverage: response.hasCoverage,\n files: response.files.map(f => ({\n path: f.path,\n lines: f.lines,\n branches: f.branches,\n functions: f.functions,\n })),\n message: response.message,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getCoverageForFileMetadata = {\n name: 'get_coverage_for_file',\n title: 'Get Coverage for File',\n description: `Get coverage metrics for a specific file or files matching a path pattern.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects first to find available project IDs.\n\nParameters:\n- projectId: The project to query (required)\n- filePath: File path to search for (exact or partial match)\n\nReturns:\n- Line coverage (covered/total/percentage)\n- Branch coverage (covered/total/percentage)\n- Function coverage (covered/total/percentage)\n\nThis is the preferred tool for targeted coverage analysis. Use path prefixes to focus on\nspecific areas of the codebase:\n- \"server/services\" - Backend service layer\n- \"server/utils\" - Backend utilities\n- \"src/api\" - API routes\n- \"lib/core\" - Core business logic\n\nBefore querying, explore the codebase to identify critical paths - entry points,\nheavily-imported files, and code handling auth/payments/data mutations.\nPrioritize: high utilization + low coverage = highest impact.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_coverage_summary tool\n */\nexport const getCoverageSummaryInputSchema = {\n projectId: z\n .string()\n .describe('Project ID to get coverage for. Required. Use list_projects to find project IDs.'),\n days: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Number of days to analyze for trends (default: 30)'),\n}\n\n/**\n * Output schema for get_coverage_summary tool\n */\nexport const getCoverageSummaryOutputSchema = {\n hasCoverage: z.boolean(),\n current: z.object({\n lines: z.number(),\n branches: z.number(),\n functions: z.number(),\n }).optional(),\n trend: z.object({\n direction: z.enum(['up', 'down', 'stable']),\n change: z.number(),\n }).optional(),\n totalReports: z.number(),\n latestReportDate: z.string().nullable().optional(),\n lowestCoverageFiles: z.array(z.object({\n path: z.string(),\n coverage: z.number(),\n })).optional(),\n message: z.string().optional(),\n}\n\nexport interface GetCoverageSummaryInput {\n projectId: string\n days?: number\n}\n\nexport interface GetCoverageSummaryOutput {\n hasCoverage: boolean\n current?: {\n lines: number\n branches: number\n functions: number\n }\n trend?: {\n direction: 'up' | 'down' | 'stable'\n change: number\n }\n totalReports: number\n latestReportDate?: string | null\n lowestCoverageFiles?: Array<{\n path: string\n coverage: number\n }>\n message?: string\n}\n\n/**\n * Execute get_coverage_summary tool\n */\nexport async function executeGetCoverageSummary(\n client: GafferApiClient,\n input: GetCoverageSummaryInput,\n): Promise<GetCoverageSummaryOutput> {\n const response = await client.getCoverageSummary({\n projectId: input.projectId,\n days: input.days,\n })\n\n return {\n hasCoverage: response.hasCoverage,\n current: response.current,\n trend: response.trend,\n totalReports: response.totalReports,\n latestReportDate: response.latestReportDate,\n lowestCoverageFiles: response.lowestCoverageFiles,\n message: response.message,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getCoverageSummaryMetadata = {\n name: 'get_coverage_summary',\n title: 'Get Coverage Summary',\n description: `Get the coverage metrics summary for a project.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects first to find available project IDs.\n\nReturns:\n- Current coverage percentages (lines, branches, functions)\n- Trend direction (up, down, stable) and change amount\n- Total number of coverage reports\n- Latest report date\n- Top 5 files with lowest coverage\n\nUse this to understand your project's overall test coverage health.\n\nAfter getting the summary, use get_coverage_for_file with path prefixes to drill into\nspecific areas (e.g., \"server/services\", \"src/api\", \"lib/core\"). This helps identify\nhigh-value targets in critical code paths rather than just the files with lowest coverage.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport type { FailureClustersResponse } from '../types.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_failure_clusters tool\n */\nexport const getFailureClustersInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n testRunId: z\n .string()\n .describe('Test run ID to get failure clusters for. Use list_test_runs to find test run IDs.'),\n}\n\n/**\n * Output schema for get_failure_clusters tool\n */\nexport const getFailureClustersOutputSchema = {\n clusters: z.array(z.object({\n representativeError: z.string(),\n count: z.number(),\n tests: z.array(z.object({\n name: z.string(),\n fullName: z.string(),\n errorMessage: z.string(),\n filePath: z.string().nullable(),\n })),\n similarity: z.number(),\n })),\n totalFailures: z.number(),\n}\n\nexport interface GetFailureClustersInput {\n projectId: string\n testRunId: string\n}\n\n/**\n * Execute get_failure_clusters tool\n */\nexport async function executeGetFailureClusters(\n client: GafferApiClient,\n input: GetFailureClustersInput,\n): Promise<FailureClustersResponse> {\n return client.getFailureClusters({\n projectId: input.projectId,\n testRunId: input.testRunId,\n })\n}\n\n/**\n * Tool metadata\n */\nexport const getFailureClustersMetadata = {\n name: 'get_failure_clusters',\n title: 'Get Failure Clusters',\n description: `Group failed tests by root cause using error message similarity.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects to find available project IDs, and list_test_runs to find test run IDs.\n\nParameters:\n- projectId (required): The project ID\n- testRunId (required): The test run ID to analyze\n\nReturns:\n- clusters: Array of failure clusters, each containing:\n - representativeError: The error message representing this cluster\n - count: Number of tests with this same root cause\n - tests: Array of individual failed tests in this cluster\n - name: Short test name\n - fullName: Full test name including describe blocks\n - errorMessage: The specific error message\n - filePath: Test file path (null if not recorded)\n - similarity: Similarity threshold used for clustering (0-1)\n- totalFailures: Total number of failed tests across all clusters\n\nUse cases:\n- \"Group these 15 failures by root cause\" — often reveals 2-3 distinct bugs\n- \"Which error affects the most tests?\" — fix the largest cluster first\n- \"Are these failures related?\" — check if they land in the same cluster\n\nTip: Use get_test_run_details with status='failed' first to see raw failures,\nthen use this tool to understand which failures share the same root cause.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_flaky_tests tool\n */\nexport const getFlakyTestsInputSchema = {\n projectId: z\n .string()\n .optional()\n .describe('Project ID to get flaky tests for. Required when using a user API Key (gaf_). Use list_projects to find project IDs.'),\n threshold: z\n .number()\n .min(0)\n .max(1)\n .optional()\n .describe('Minimum flip rate to be considered flaky (0-1, default: 0.1 = 10%)'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of flaky tests to return (default: 50)'),\n days: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Analysis period in days (default: 30)'),\n}\n\n/**\n * Output schema for get_flaky_tests tool\n */\nexport const getFlakyTestsOutputSchema = {\n flakyTests: z.array(z.object({\n name: z.string(),\n flipRate: z.number(),\n flipCount: z.number(),\n totalRuns: z.number(),\n lastSeen: z.string(),\n })),\n summary: z.object({\n threshold: z.number(),\n totalFlaky: z.number(),\n period: z.number(),\n }),\n}\n\nexport interface GetFlakyTestsInput {\n projectId?: string\n threshold?: number\n limit?: number\n days?: number\n}\n\nexport interface GetFlakyTestsOutput {\n flakyTests: Array<{\n name: string\n flipRate: number\n flipCount: number\n totalRuns: number\n lastSeen: string\n }>\n summary: {\n threshold: number\n totalFlaky: number\n period: number\n }\n}\n\n/**\n * Execute get_flaky_tests tool\n */\nexport async function executeGetFlakyTests(\n client: GafferApiClient,\n input: GetFlakyTestsInput,\n): Promise<GetFlakyTestsOutput> {\n const response = await client.getFlakyTests({\n projectId: input.projectId,\n threshold: input.threshold,\n limit: input.limit,\n days: input.days,\n })\n\n return {\n flakyTests: response.flakyTests,\n summary: response.summary,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getFlakyTestsMetadata = {\n name: 'get_flaky_tests',\n title: 'Get Flaky Tests',\n description: `Get the list of flaky tests in a project.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects first to find available project IDs.\n\nA test is considered flaky if it frequently switches between pass and fail states\n(high \"flip rate\"). This helps identify unreliable tests that need attention.\n\nReturns:\n- List of flaky tests with:\n - name: Test name\n - flipRate: How often the test flips between pass/fail (0-1)\n - flipCount: Number of status transitions\n - totalRuns: Total test executions analyzed\n - lastSeen: When the test last ran\n- Summary with threshold used and total count\n\nUse this after get_project_health shows flaky tests exist, to identify which\nspecific tests are flaky and need investigation.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_project_health tool\n */\nexport const getProjectHealthInputSchema = {\n projectId: z\n .string()\n .optional()\n .describe('Project ID to get health for. Required when using a user API Key (gaf_). Use list_projects to find project IDs.'),\n days: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Number of days to analyze (default: 30)'),\n}\n\n/**\n * Output schema for get_project_health tool\n */\nexport const getProjectHealthOutputSchema = {\n projectName: z.string(),\n healthScore: z.number(),\n passRate: z.number().nullable(),\n testRunCount: z.number(),\n flakyTestCount: z.number(),\n trend: z.enum(['up', 'down', 'stable']),\n period: z.object({\n days: z.number(),\n start: z.string(),\n end: z.string(),\n }),\n}\n\nexport interface GetProjectHealthInput {\n projectId?: string\n days?: number\n}\n\nexport interface GetProjectHealthOutput {\n projectName: string\n healthScore: number\n passRate: number | null\n testRunCount: number\n flakyTestCount: number\n trend: 'up' | 'down' | 'stable'\n period: {\n days: number\n start: string\n end: string\n }\n}\n\n/**\n * Execute get_project_health tool\n */\nexport async function executeGetProjectHealth(\n client: GafferApiClient,\n input: GetProjectHealthInput,\n): Promise<GetProjectHealthOutput> {\n const response = await client.getProjectHealth({\n projectId: input.projectId,\n days: input.days,\n })\n\n return {\n projectName: response.analytics.projectName,\n healthScore: response.analytics.healthScore,\n passRate: response.analytics.passRate,\n testRunCount: response.analytics.testRunCount,\n flakyTestCount: response.analytics.flakyTestCount,\n trend: response.analytics.trend,\n period: response.analytics.period,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getProjectHealthMetadata = {\n name: 'get_project_health',\n title: 'Get Project Health',\n description: `Get the health metrics for a project.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects first to find available project IDs.\n\nReturns:\n- Health score (0-100): Overall project health based on pass rate and trend\n- Pass rate: Percentage of tests passing\n- Test run count: Number of test runs in the period\n- Flaky test count: Number of tests with inconsistent results\n- Trend: Whether test health is improving (up), declining (down), or stable\n\nUse this to understand the current state of your test suite.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_report_browser_url tool\n */\nexport const getReportBrowserUrlInputSchema = {\n projectId: z\n .string()\n .describe('Project ID the test run belongs to. Required. Use list_projects to find project IDs.'),\n testRunId: z\n .string()\n .describe('The test run ID to get the report URL for. Use list_test_runs to find test run IDs.'),\n filename: z\n .string()\n .optional()\n .describe('Specific file to open (default: index.html or first HTML file)'),\n}\n\n/**\n * Output schema for get_report_browser_url tool\n */\nexport const getReportBrowserUrlOutputSchema = {\n url: z.string(),\n filename: z.string(),\n testRunId: z.string(),\n expiresAt: z.string(),\n expiresInSeconds: z.number(),\n}\n\nexport interface GetReportBrowserUrlInput {\n projectId: string\n testRunId: string\n filename?: string\n}\n\nexport interface GetReportBrowserUrlOutput {\n url: string\n filename: string\n testRunId: string\n expiresAt: string\n expiresInSeconds: number\n}\n\n/**\n * Execute get_report_browser_url tool\n */\nexport async function executeGetReportBrowserUrl(\n client: GafferApiClient,\n input: GetReportBrowserUrlInput,\n): Promise<GetReportBrowserUrlOutput> {\n const response = await client.getReportBrowserUrl({\n projectId: input.projectId,\n testRunId: input.testRunId,\n filename: input.filename,\n })\n\n return {\n url: response.url,\n filename: response.filename,\n testRunId: response.testRunId,\n expiresAt: response.expiresAt,\n expiresInSeconds: response.expiresInSeconds,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getReportBrowserUrlMetadata = {\n name: 'get_report_browser_url',\n title: 'Get Report Browser URL',\n description: `Get a browser-navigable URL for viewing a test report (Playwright, Vitest, etc.).\n\nReturns a signed URL that can be opened directly in a browser without requiring\nthe user to log in. The URL expires after 30 minutes for security.\n\nWhen using a user API Key (gaf_), you must provide both projectId and testRunId.\nUse list_projects and list_test_runs to find available IDs.\n\nParameters:\n- projectId: The project the test run belongs to (required)\n- testRunId: The test run to view (required)\n- filename: Specific file to open (optional, defaults to index.html)\n\nReturns:\n- url: Browser-navigable URL with signed token\n- filename: The file being accessed\n- expiresAt: ISO timestamp when the URL expires\n- expiresInSeconds: Time until expiration\n\nThe returned URL can be shared with users who need to view the report.\nNote: URLs expire after 30 minutes for security.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport type { ReportFile, ReportResponse } from '../types.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_report tool\n */\nexport const getReportInputSchema = {\n testRunId: z\n .string()\n .describe('The test run ID to get report files for. Use list_test_runs to find test run IDs.'),\n}\n\n/**\n * Output schema for get_report tool\n */\nexport const getReportOutputSchema = {\n testRunId: z.string(),\n projectId: z.string(),\n projectName: z.string(),\n resultSchema: z.string().optional(),\n files: z.array(z.object({\n filename: z.string(),\n size: z.number(),\n contentType: z.string(),\n downloadUrl: z.string(),\n })),\n urlExpiresInSeconds: z.number().optional(),\n}\n\nexport interface GetReportInput {\n testRunId: string\n}\n\n// Re-export types from types.ts for convenience\nexport type { ReportFile, ReportResponse }\n\n// Output type matches ReportResponse\nexport type GetReportOutput = ReportResponse\n\n/**\n * Execute get_report tool\n */\nexport async function executeGetReport(\n client: GafferApiClient,\n input: GetReportInput,\n): Promise<GetReportOutput> {\n const response = await client.getReport(input.testRunId)\n\n return {\n testRunId: response.testRunId,\n projectId: response.projectId,\n projectName: response.projectName,\n resultSchema: response.resultSchema,\n files: response.files.map(file => ({\n filename: file.filename,\n size: file.size,\n contentType: file.contentType,\n downloadUrl: file.downloadUrl,\n })),\n urlExpiresInSeconds: response.urlExpiresInSeconds,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getReportMetadata = {\n name: 'get_report',\n title: 'Get Report Files',\n description: `Get URLs for report files uploaded with a test run.\n\nIMPORTANT: This tool returns download URLs, not file content. You must fetch the URLs separately.\n\nReturns for each file:\n- filename: The file name (e.g., \"report.html\", \"results.json\", \"junit.xml\")\n- size: File size in bytes\n- contentType: MIME type (e.g., \"text/html\", \"application/json\", \"application/xml\")\n- downloadUrl: Presigned URL to download the file (valid for ~5 minutes)\n\nHow to use the returned URLs:\n\n1. **JSON files** (results.json, coverage.json):\n Use WebFetch with the downloadUrl to retrieve and parse the JSON content.\n Example: WebFetch(url=downloadUrl, prompt=\"Extract test results from this JSON\")\n\n2. **XML files** (junit.xml, xunit.xml):\n Use WebFetch with the downloadUrl to retrieve and parse the XML content.\n Example: WebFetch(url=downloadUrl, prompt=\"Parse the test results from this JUnit XML\")\n\n3. **HTML reports** (Playwright, pytest-html, Vitest):\n These are typically bundled React/JavaScript applications that require a browser.\n They cannot be meaningfully parsed by WebFetch.\n For programmatic analysis, use get_test_run_details instead.\n\nRecommendations:\n- For analyzing test results programmatically: Use get_test_run_details (returns parsed test data)\n- For JSON/XML files: Use this tool + WebFetch on the downloadUrl\n- For HTML reports: Direct users to view in browser, or use get_test_run_details\n\nUse cases:\n- \"What files are in this test run?\" (list available reports)\n- \"Get the coverage data from this run\" (then WebFetch the JSON URL)\n- \"Parse the JUnit XML results\" (then WebFetch the XML URL)`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport type { SlowestTestEntry, SlowestTestsResponse } from '../types.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_slowest_tests tool\n */\nexport const getSlowestTestsInputSchema = {\n projectId: z\n .string()\n .describe('Project ID to get slowest tests for. Required. Use list_projects to find project IDs.'),\n days: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Analysis period in days (default: 30)'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of tests to return (default: 20)'),\n framework: z\n .string()\n .optional()\n .describe('Filter by test framework (e.g., \"playwright\", \"vitest\", \"jest\")'),\n branch: z\n .string()\n .optional()\n .describe('Filter by git branch name (e.g., \"main\", \"develop\")'),\n}\n\n/**\n * Output schema for get_slowest_tests tool\n */\nexport const getSlowestTestsOutputSchema = {\n slowestTests: z.array(z.object({\n name: z.string(),\n fullName: z.string(),\n filePath: z.string().optional(),\n framework: z.string().optional(),\n avgDurationMs: z.number(),\n p95DurationMs: z.number(),\n runCount: z.number(),\n })),\n summary: z.object({\n projectId: z.string(),\n projectName: z.string(),\n period: z.number(),\n totalReturned: z.number(),\n }),\n}\n\nexport interface GetSlowestTestsInput {\n projectId: string\n days?: number\n limit?: number\n framework?: string\n branch?: string\n}\n\n// Re-export types from types.ts for convenience\nexport type { SlowestTestEntry, SlowestTestsResponse }\n\n// Output type matches SlowestTestsResponse\nexport type GetSlowestTestsOutput = SlowestTestsResponse\n\n/**\n * Execute get_slowest_tests tool\n */\nexport async function executeGetSlowestTests(\n client: GafferApiClient,\n input: GetSlowestTestsInput,\n): Promise<GetSlowestTestsOutput> {\n const response = await client.getSlowestTests({\n projectId: input.projectId,\n days: input.days,\n limit: input.limit,\n framework: input.framework,\n branch: input.branch,\n })\n\n return {\n slowestTests: response.slowestTests.map(test => ({\n name: test.name,\n fullName: test.fullName,\n filePath: test.filePath,\n framework: test.framework,\n avgDurationMs: test.avgDurationMs,\n p95DurationMs: test.p95DurationMs,\n runCount: test.runCount,\n })),\n summary: response.summary,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getSlowestTestsMetadata = {\n name: 'get_slowest_tests',\n title: 'Get Slowest Tests',\n description: `Get the slowest tests in a project, sorted by P95 duration.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects first to find available project IDs.\n\nParameters:\n- projectId (required): Project ID to analyze\n- days (optional): Analysis period in days (default: 30, max: 365)\n- limit (optional): Max tests to return (default: 20, max: 100)\n- framework (optional): Filter by framework (e.g., \"playwright\", \"vitest\")\n- branch (optional): Filter by git branch (e.g., \"main\", \"develop\")\n\nReturns:\n- List of slowest tests with:\n - name: Short test name\n - fullName: Full test name including describe blocks\n - filePath: Test file path (if available)\n - framework: Test framework used\n - avgDurationMs: Average test duration in milliseconds\n - p95DurationMs: 95th percentile duration (used for sorting)\n - runCount: Number of times the test ran in the period\n- Summary with project info and period\n\nUse cases:\n- \"Which tests are slowing down my CI pipeline?\"\n- \"Find the slowest Playwright tests to optimize\"\n- \"Show me e2e tests taking over 30 seconds\"\n- \"What are the slowest tests on the main branch?\"`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_test_history tool\n */\nexport const getTestHistoryInputSchema = {\n projectId: z\n .string()\n .optional()\n .describe('Project ID to get test history for. Required when using a user API Key (gaf_). Use list_projects to find project IDs.'),\n testName: z\n .string()\n .optional()\n .describe('Exact test name to search for'),\n filePath: z\n .string()\n .optional()\n .describe('File path containing the test'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of results (default: 20)'),\n}\n\n/**\n * Output schema for get_test_history tool\n */\nexport const getTestHistoryOutputSchema = {\n history: z.array(z.object({\n testRunId: z.string(),\n createdAt: z.string(),\n branch: z.string().optional(),\n commitSha: z.string().optional(),\n status: z.enum(['passed', 'failed', 'skipped', 'pending']),\n durationMs: z.number(),\n message: z.string().optional(),\n })),\n summary: z.object({\n totalRuns: z.number(),\n passedRuns: z.number(),\n failedRuns: z.number(),\n passRate: z.number().nullable(),\n }),\n}\n\nexport interface GetTestHistoryInput {\n projectId?: string\n testName?: string\n filePath?: string\n limit?: number\n}\n\nexport interface GetTestHistoryOutput {\n history: Array<{\n testRunId: string\n createdAt: string\n branch?: string\n commitSha?: string\n status: 'passed' | 'failed' | 'skipped' | 'pending'\n durationMs: number\n message?: string\n }>\n summary: {\n totalRuns: number\n passedRuns: number\n failedRuns: number\n passRate: number | null\n }\n}\n\n/**\n * Execute get_test_history tool\n */\nexport async function executeGetTestHistory(\n client: GafferApiClient,\n input: GetTestHistoryInput,\n): Promise<GetTestHistoryOutput> {\n if (!input.testName && !input.filePath) {\n throw new Error('Either testName or filePath is required')\n }\n\n const response = await client.getTestHistory({\n projectId: input.projectId,\n testName: input.testName,\n filePath: input.filePath,\n limit: input.limit || 20,\n })\n\n return {\n history: response.history.map(entry => ({\n testRunId: entry.testRunId,\n createdAt: entry.createdAt,\n branch: entry.branch,\n commitSha: entry.commitSha,\n status: entry.test.status,\n durationMs: entry.test.durationMs,\n message: entry.test.message || undefined, // Convert null to undefined for schema compliance\n })),\n summary: {\n totalRuns: response.summary.totalRuns,\n passedRuns: response.summary.passedRuns,\n failedRuns: response.summary.failedRuns,\n passRate: response.summary.passRate,\n },\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getTestHistoryMetadata = {\n name: 'get_test_history',\n title: 'Get Test History',\n description: `Get the pass/fail history for a specific test.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects first to find available project IDs.\n\nSearch by either:\n- testName: The exact name of the test (e.g., \"should handle user login\")\n- filePath: The file path containing the test (e.g., \"tests/auth.test.ts\")\n\nReturns:\n- History of test runs showing pass/fail status over time\n- Duration of each run\n- Branch and commit information\n- Error messages for failed runs\n- Summary statistics (pass rate, total runs)\n\nUse this to investigate flaky tests or understand test stability.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_test_run_details tool\n */\nexport const getTestRunDetailsInputSchema = {\n testRunId: z\n .string()\n .describe('The test run ID to get details for. Use list_test_runs to find test run IDs.'),\n projectId: z\n .string()\n .describe('Project ID the test run belongs to. Required when using a user API Key (gaf_). Use list_projects to find project IDs.'),\n status: z\n .enum(['passed', 'failed', 'skipped'])\n .optional()\n .describe('Filter tests by status. Returns only tests matching this status.'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(500)\n .optional()\n .describe('Maximum number of tests to return (default: 100, max: 500)'),\n offset: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Number of tests to skip for pagination (default: 0)'),\n}\n\n/**\n * Output schema for get_test_run_details tool\n */\nexport const getTestRunDetailsOutputSchema = {\n testRunId: z.string(),\n commitSha: z.string().nullable(),\n branch: z.string().nullable(),\n framework: z.string().nullable(),\n createdAt: z.string(),\n summary: z.object({\n passed: z.number(),\n failed: z.number(),\n skipped: z.number(),\n total: z.number(),\n }),\n tests: z.array(z.object({\n name: z.string(),\n fullName: z.string(),\n status: z.enum(['passed', 'failed', 'skipped']),\n durationMs: z.number().nullable(),\n filePath: z.string().nullable(),\n error: z.string().nullable(),\n errorStack: z.string().nullable(),\n })),\n pagination: z.object({\n total: z.number(),\n limit: z.number(),\n offset: z.number(),\n hasMore: z.boolean(),\n }),\n}\n\nexport interface GetTestRunDetailsInput {\n testRunId: string\n projectId: string\n status?: 'passed' | 'failed' | 'skipped'\n limit?: number\n offset?: number\n}\n\nexport interface GetTestRunDetailsOutput {\n testRunId: string\n commitSha: string | null\n branch: string | null\n framework: string | null\n createdAt: string\n summary: {\n passed: number\n failed: number\n skipped: number\n total: number\n }\n tests: Array<{\n name: string\n fullName: string\n status: 'passed' | 'failed' | 'skipped'\n durationMs: number | null\n filePath: string | null\n error: string | null\n errorStack: string | null\n }>\n pagination: {\n total: number\n limit: number\n offset: number\n hasMore: boolean\n }\n}\n\n/**\n * Execute get_test_run_details tool\n */\nexport async function executeGetTestRunDetails(\n client: GafferApiClient,\n input: GetTestRunDetailsInput,\n): Promise<GetTestRunDetailsOutput> {\n const response = await client.getTestRunDetails({\n projectId: input.projectId,\n testRunId: input.testRunId,\n status: input.status,\n limit: input.limit,\n offset: input.offset,\n })\n\n return {\n testRunId: response.testRunId,\n commitSha: response.commitSha,\n branch: response.branch,\n framework: response.framework,\n createdAt: response.createdAt,\n summary: response.summary,\n tests: response.tests,\n pagination: response.pagination,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getTestRunDetailsMetadata = {\n name: 'get_test_run_details',\n title: 'Get Test Run Details',\n description: `Get parsed test results for a specific test run.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects to find available project IDs, and list_test_runs to find test run IDs.\n\nParameters:\n- testRunId (required): The test run ID to get details for\n- projectId (required): Project ID the test run belongs to\n- status (optional): Filter by test status: \"passed\", \"failed\", or \"skipped\"\n- limit (optional): Max tests to return (default: 100, max: 500)\n- offset (optional): Pagination offset (default: 0)\n\nReturns:\n- testRunId: The test run ID\n- commitSha: Git commit SHA (null if not recorded)\n- branch: Git branch name (null if not recorded)\n- framework: Test framework (e.g., \"playwright\", \"vitest\")\n- createdAt: When the test run was created (ISO 8601)\n- summary: Overall counts (passed, failed, skipped, total)\n- tests: Array of individual test results with:\n - name: Short test name\n - fullName: Full test name including describe blocks\n - status: Test status (passed, failed, skipped)\n - durationMs: Test duration in milliseconds (null if not recorded)\n - filePath: Test file path (null if not recorded)\n - error: Error message for failed tests (null otherwise)\n - errorStack: Full stack trace for failed tests (null otherwise)\n- pagination: Pagination info (total, limit, offset, hasMore)\n\nUse cases:\n- \"Show me all failed tests from this test run\"\n- \"Get the test results from commit abc123\"\n- \"List tests that took the longest in this run\"\n- \"Find tests with errors in the auth module\"\n\nNote: For aggregate analytics like flaky test detection or duration trends,\nuse get_test_history, get_flaky_tests, or get_slowest_tests instead.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_untested_files tool\n */\nexport const getUntestedFilesInputSchema = {\n projectId: z\n .string()\n .describe('Project ID to analyze. Required. Use list_projects to find project IDs.'),\n maxCoverage: z\n .number()\n .min(0)\n .max(100)\n .optional()\n .describe('Maximum coverage percentage to include (default: 10 for \"untested\")'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of files to return (default: 20)'),\n}\n\n/**\n * Output schema for get_untested_files tool\n */\nexport const getUntestedFilesOutputSchema = {\n hasCoverage: z.boolean(),\n files: z.array(z.object({\n path: z.string(),\n lines: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n branches: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n functions: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n })),\n totalCount: z.number(),\n message: z.string().optional(),\n}\n\nexport interface GetUntestedFilesInput {\n projectId: string\n maxCoverage?: number\n limit?: number\n}\n\nexport interface GetUntestedFilesOutput {\n hasCoverage: boolean\n files: Array<{\n path: string\n lines: { covered: number, total: number, percentage: number }\n branches: { covered: number, total: number, percentage: number }\n functions: { covered: number, total: number, percentage: number }\n }>\n totalCount: number\n message?: string\n}\n\n/**\n * Execute get_untested_files tool\n */\nexport async function executeGetUntestedFiles(\n client: GafferApiClient,\n input: GetUntestedFilesInput,\n): Promise<GetUntestedFilesOutput> {\n const maxCoverage = input.maxCoverage ?? 10\n const limit = input.limit ?? 20\n\n const response = await client.getCoverageFiles({\n projectId: input.projectId,\n maxCoverage,\n limit,\n sortBy: 'coverage',\n sortOrder: 'asc', // Lowest coverage first\n })\n\n return {\n hasCoverage: response.hasCoverage,\n files: response.files.map(f => ({\n path: f.path,\n lines: f.lines,\n branches: f.branches,\n functions: f.functions,\n })),\n totalCount: response.pagination.total,\n message: response.message,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getUntestedFilesMetadata = {\n name: 'get_untested_files',\n title: 'Get Untested Files',\n description: `Get files with little or no test coverage.\n\nReturns files sorted by coverage percentage (lowest first), filtered\nto only include files below a coverage threshold.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects first to find available project IDs.\n\nParameters:\n- projectId: The project to analyze (required)\n- maxCoverage: Include files with coverage at or below this % (default: 10)\n- limit: Maximum number of files to return (default: 20, max: 100)\n\nReturns:\n- List of files sorted by coverage (lowest first)\n- Each file includes line/branch/function coverage metrics\n- Total count of files matching the criteria\n\nIMPORTANT: Results may be dominated by certain file types (e.g., UI components) that are\nnumerous but not necessarily the highest priority. For targeted analysis of specific code\nareas (backend, services, utilities), use get_coverage_for_file with path prefixes instead.\n\nTo prioritize effectively, explore the codebase to understand which code is heavily utilized\n(entry points, frequently-imported files, critical business logic) and then query coverage\nfor those specific paths.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport type { UploadSessionDetailResponse, UploadSessionsResponse } from '../types.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_upload_status tool\n */\nexport const getUploadStatusInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n sessionId: z\n .string()\n .optional()\n .describe('Specific upload session ID. If provided, returns detailed status for that session. Otherwise, lists recent sessions.'),\n commitSha: z\n .string()\n .optional()\n .describe('Filter sessions by commit SHA. Useful for checking if results for a specific commit are ready.'),\n branch: z\n .string()\n .optional()\n .describe('Filter sessions by branch name.'),\n}\n\n/**\n * Output schema for get_upload_status tool\n */\nexport const getUploadStatusOutputSchema = {\n sessions: z.array(z.object({\n id: z.string(),\n processingStatus: z.string(),\n commitSha: z.string().nullable(),\n branch: z.string().nullable(),\n pendingFileCount: z.number(),\n failedFileCount: z.number(),\n createdAt: z.string(),\n updatedAt: z.string(),\n })).optional(),\n session: z.object({\n id: z.string(),\n processingStatus: z.string(),\n commitSha: z.string().nullable(),\n branch: z.string().nullable(),\n createdAt: z.string(),\n }).optional(),\n testRuns: z.array(z.object({\n id: z.string(),\n framework: z.string().nullable(),\n summary: z.object({\n passed: z.number(),\n failed: z.number(),\n skipped: z.number(),\n total: z.number(),\n }),\n createdAt: z.string(),\n })).optional(),\n coverageReports: z.array(z.object({\n id: z.string(),\n format: z.string(),\n createdAt: z.string(),\n })).optional(),\n pagination: z.object({\n total: z.number(),\n limit: z.number(),\n offset: z.number(),\n hasMore: z.boolean(),\n }).optional(),\n}\n\nexport interface GetUploadStatusInput {\n projectId: string\n sessionId?: string\n commitSha?: string\n branch?: string\n}\n\nexport type GetUploadStatusOutput = UploadSessionsResponse | UploadSessionDetailResponse\n\n/**\n * Execute get_upload_status tool\n */\nexport async function executeGetUploadStatus(\n client: GafferApiClient,\n input: GetUploadStatusInput,\n): Promise<GetUploadStatusOutput> {\n if (input.sessionId) {\n return client.getUploadSessionDetail({\n projectId: input.projectId,\n sessionId: input.sessionId,\n })\n }\n\n return client.listUploadSessions({\n projectId: input.projectId,\n commitSha: input.commitSha,\n branch: input.branch,\n })\n}\n\n/**\n * Tool metadata\n */\nexport const getUploadStatusMetadata = {\n name: 'get_upload_status',\n title: 'Get Upload Status',\n description: `Check if CI results have been uploaded and processed.\n\nUse this tool to answer \"are my test results ready?\" after pushing code.\n\nParameters:\n- projectId (required): The project ID\n- sessionId (optional): Specific upload session ID for detailed status\n- commitSha (optional): Filter by commit SHA to find uploads for a specific commit\n- branch (optional): Filter by branch name\n\nBehavior:\n- If sessionId is provided: returns detailed status with linked test runs and coverage reports\n- Otherwise: returns a list of recent upload sessions (filtered by commitSha/branch if provided)\n\nProcessing statuses:\n- \"pending\" — upload received, processing not started\n- \"processing\" — files are being parsed\n- \"completed\" — all files processed successfully, results are ready\n- \"error\" — some files failed to process\n\nWorkflow:\n1. After pushing code, call with commitSha to find the upload session\n2. Check processingStatus — if \"completed\", results are ready\n3. If \"processing\" or \"pending\", wait and check again\n4. Once completed, use the linked testRunIds with get_test_run_details\n\nReturns (list mode):\n- sessions: Array of upload sessions with processing status\n- pagination: Pagination info\n\nReturns (detail mode):\n- session: Upload session details\n- testRuns: Linked test run summaries (id, framework, pass/fail counts)\n- coverageReports: Linked coverage report summaries (id, format)`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for list_projects tool\n */\nexport const listProjectsInputSchema = {\n organizationId: z\n .string()\n .optional()\n .describe('Filter by organization ID (optional)'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of projects to return (default: 50)'),\n}\n\n/**\n * Output schema for list_projects tool\n */\nexport const listProjectsOutputSchema = {\n projects: z.array(z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().nullable().optional(),\n organization: z.object({\n id: z.string(),\n name: z.string(),\n slug: z.string(),\n }),\n })),\n total: z.number(),\n}\n\nexport interface ListProjectsInput {\n organizationId?: string\n limit?: number\n}\n\nexport interface ListProjectsOutput {\n projects: Array<{\n id: string\n name: string\n description?: string | null\n organization: {\n id: string\n name: string\n slug: string\n }\n }>\n total: number\n}\n\n/**\n * Execute list_projects tool\n */\nexport async function executeListProjects(\n client: GafferApiClient,\n input: ListProjectsInput,\n): Promise<ListProjectsOutput> {\n const response = await client.listProjects({\n organizationId: input.organizationId,\n limit: input.limit,\n })\n\n return {\n projects: response.projects.map(p => ({\n id: p.id,\n name: p.name,\n description: p.description,\n organization: p.organization,\n })),\n total: response.pagination.total,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const listProjectsMetadata = {\n name: 'list_projects',\n title: 'List Projects',\n description: `List all projects you have access to.\n\nReturns a list of projects with their IDs, names, and organization info.\nUse this to find project IDs for other tools like get_project_health.\n\nRequires a user API Key (gaf_). Get one from Account Settings in the Gaffer dashboard.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for list_test_runs tool\n */\nexport const listTestRunsInputSchema = {\n projectId: z\n .string()\n .optional()\n .describe('Project ID to list test runs for. Required when using a user API Key (gaf_). Use list_projects to find project IDs.'),\n commitSha: z\n .string()\n .optional()\n .describe('Filter by commit SHA (exact or prefix match)'),\n branch: z\n .string()\n .optional()\n .describe('Filter by branch name'),\n status: z\n .enum(['passed', 'failed'])\n .optional()\n .describe('Filter by status: \"passed\" (no failures) or \"failed\" (has failures)'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of test runs to return (default: 20)'),\n}\n\n/**\n * Output schema for list_test_runs tool\n */\nexport const listTestRunsOutputSchema = {\n testRuns: z.array(z.object({\n id: z.string(),\n commitSha: z.string().optional(),\n branch: z.string().optional(),\n passedCount: z.number(),\n failedCount: z.number(),\n skippedCount: z.number(),\n totalCount: z.number(),\n createdAt: z.string(),\n })),\n pagination: z.object({\n total: z.number(),\n hasMore: z.boolean(),\n }),\n}\n\nexport interface ListTestRunsInput {\n projectId?: string\n commitSha?: string\n branch?: string\n status?: 'passed' | 'failed'\n limit?: number\n}\n\nexport interface ListTestRunsOutput {\n testRuns: Array<{\n id: string\n commitSha?: string\n branch?: string\n passedCount: number\n failedCount: number\n skippedCount: number\n totalCount: number\n createdAt: string\n }>\n pagination: {\n total: number\n hasMore: boolean\n }\n}\n\n/**\n * Execute list_test_runs tool\n */\nexport async function executeListTestRuns(\n client: GafferApiClient,\n input: ListTestRunsInput,\n): Promise<ListTestRunsOutput> {\n const response = await client.getTestRuns({\n projectId: input.projectId,\n commitSha: input.commitSha,\n branch: input.branch,\n status: input.status,\n limit: input.limit || 20,\n })\n\n return {\n testRuns: response.testRuns.map(run => ({\n id: run.id,\n commitSha: run.commitSha || undefined,\n branch: run.branch || undefined,\n passedCount: run.summary.passed,\n failedCount: run.summary.failed,\n skippedCount: run.summary.skipped,\n totalCount: run.summary.total,\n createdAt: run.createdAt,\n })),\n pagination: {\n total: response.pagination.total,\n hasMore: response.pagination.hasMore,\n },\n }\n}\n\n/**\n * Tool metadata\n */\nexport const listTestRunsMetadata = {\n name: 'list_test_runs',\n title: 'List Test Runs',\n description: `List recent test runs for a project with optional filtering.\n\nWhen using a user API Key (gaf_), you must provide a projectId.\nUse list_projects first to find available project IDs.\n\nFilter by:\n- commitSha: Filter by commit SHA (supports prefix matching)\n- branch: Filter by branch name\n- status: Filter by \"passed\" (no failures) or \"failed\" (has failures)\n\nReturns:\n- List of test runs with:\n - id: Test run ID (can be used with get_test_run for details)\n - commitSha: Git commit SHA\n - branch: Git branch name\n - passedCount/failedCount/skippedCount: Test counts\n - createdAt: When the test run was created\n- Pagination info (total count, hasMore flag)\n\nUse cases:\n- \"What tests failed in commit abc123?\"\n- \"Show me recent test runs on main branch\"\n- \"What's the status of tests on my feature branch?\"`,\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { GafferApiClient } from './api-client.js'\nimport {\n compareTestMetricsInputSchema,\n compareTestMetricsMetadata,\n compareTestMetricsOutputSchema,\n executeCompareTestMetrics,\n} from './tools/compare-test-metrics.js'\nimport {\n executeFindUncoveredFailureAreas,\n findUncoveredFailureAreasInputSchema,\n findUncoveredFailureAreasMetadata,\n findUncoveredFailureAreasOutputSchema,\n} from './tools/find-uncovered-failure-areas.js'\nimport {\n executeGetCoverageForFile,\n getCoverageForFileInputSchema,\n getCoverageForFileMetadata,\n getCoverageForFileOutputSchema,\n} from './tools/get-coverage-for-file.js'\nimport {\n executeGetCoverageSummary,\n getCoverageSummaryInputSchema,\n getCoverageSummaryMetadata,\n getCoverageSummaryOutputSchema,\n} from './tools/get-coverage-summary.js'\nimport {\n executeGetFailureClusters,\n getFailureClustersInputSchema,\n getFailureClustersMetadata,\n getFailureClustersOutputSchema,\n} from './tools/get-failure-clusters.js'\nimport {\n executeGetFlakyTests,\n getFlakyTestsInputSchema,\n getFlakyTestsMetadata,\n getFlakyTestsOutputSchema,\n} from './tools/get-flaky-tests.js'\nimport {\n executeGetProjectHealth,\n getProjectHealthInputSchema,\n getProjectHealthMetadata,\n getProjectHealthOutputSchema,\n} from './tools/get-project-health.js'\nimport {\n executeGetReportBrowserUrl,\n getReportBrowserUrlInputSchema,\n getReportBrowserUrlMetadata,\n getReportBrowserUrlOutputSchema,\n} from './tools/get-report-browser-url.js'\nimport {\n executeGetReport,\n getReportInputSchema,\n getReportMetadata,\n getReportOutputSchema,\n} from './tools/get-report.js'\nimport {\n executeGetSlowestTests,\n getSlowestTestsInputSchema,\n getSlowestTestsMetadata,\n getSlowestTestsOutputSchema,\n} from './tools/get-slowest-tests.js'\nimport {\n executeGetTestHistory,\n getTestHistoryInputSchema,\n getTestHistoryMetadata,\n getTestHistoryOutputSchema,\n} from './tools/get-test-history.js'\nimport {\n executeGetTestRunDetails,\n getTestRunDetailsInputSchema,\n getTestRunDetailsMetadata,\n getTestRunDetailsOutputSchema,\n} from './tools/get-test-run-details.js'\nimport {\n executeGetUntestedFiles,\n getUntestedFilesInputSchema,\n getUntestedFilesMetadata,\n getUntestedFilesOutputSchema,\n} from './tools/get-untested-files.js'\nimport {\n executeGetUploadStatus,\n getUploadStatusInputSchema,\n getUploadStatusMetadata,\n getUploadStatusOutputSchema,\n} from './tools/get-upload-status.js'\nimport {\n executeListProjects,\n listProjectsInputSchema,\n listProjectsMetadata,\n listProjectsOutputSchema,\n} from './tools/list-projects.js'\nimport {\n executeListTestRuns,\n listTestRunsInputSchema,\n listTestRunsMetadata,\n listTestRunsOutputSchema,\n} from './tools/list-test-runs.js'\n\n/**\n * Log error to stderr for observability\n * MCP uses stdout for communication, so stderr is safe for logging\n */\nfunction logError(toolName: string, error: unknown): void {\n const timestamp = new Date().toISOString()\n const message = error instanceof Error ? error.message : 'Unknown error'\n const stack = error instanceof Error ? error.stack : undefined\n console.error(`[${timestamp}] [gaffer-mcp] ${toolName} failed: ${message}`)\n if (stack) {\n console.error(stack)\n }\n}\n\n/**\n * Handle tool error: log it and return MCP error response\n */\nfunction handleToolError(toolName: string, error: unknown): { content: { type: 'text', text: string }[], isError: true } {\n logError(toolName, error)\n const message = error instanceof Error ? error.message : 'Unknown error'\n return {\n content: [{ type: 'text' as const, text: `Error: ${message}` }],\n isError: true,\n }\n}\n\n/**\n * Tool definition for registration helper.\n * Schema types use `any` to accommodate the MCP SDK's complex Zod type requirements.\n */\ninterface ToolDefinition<TInput, TOutput> {\n metadata: { name: string, title: string, description: string }\n inputSchema: any\n outputSchema: any\n execute: (client: GafferApiClient, input: TInput) => Promise<TOutput>\n}\n\n/**\n * Register a tool with the MCP server using a consistent pattern.\n * Reduces boilerplate by handling error wrapping and response formatting.\n */\nfunction registerTool<TInput, TOutput>(\n server: McpServer,\n client: GafferApiClient,\n tool: ToolDefinition<TInput, TOutput>,\n): void {\n server.registerTool(\n tool.metadata.name,\n {\n title: tool.metadata.title,\n description: tool.metadata.description,\n inputSchema: tool.inputSchema,\n outputSchema: tool.outputSchema,\n },\n async (input: TInput) => {\n try {\n const output = await tool.execute(client, input)\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(output, null, 2) }],\n structuredContent: output as unknown as Record<string, unknown>,\n }\n }\n catch (error) {\n return handleToolError(tool.metadata.name, error)\n }\n },\n )\n}\n\n/**\n * Gaffer MCP Server\n *\n * Provides AI assistants with access to test history and health metrics.\n *\n * Supports two authentication modes:\n * 1. User API Keys (gaf_) - Read-only access to all user's projects\n * Set via GAFFER_API_KEY environment variable\n * 2. Project Upload Tokens (gfr_) - Legacy, single project access\n */\nasync function main() {\n // Validate API key is present\n const apiKey = process.env.GAFFER_API_KEY\n if (!apiKey) {\n console.error('Error: GAFFER_API_KEY environment variable is required')\n console.error('')\n console.error('Get your API Key from: https://app.gaffer.sh/account/api-keys')\n console.error('')\n console.error('Then configure Claude Code or Cursor with:')\n console.error(JSON.stringify({\n mcpServers: {\n gaffer: {\n command: 'npx',\n args: ['-y', '@gaffer-sh/mcp'],\n env: {\n GAFFER_API_KEY: 'gaf_your-api-key-here',\n },\n },\n },\n }, null, 2))\n process.exit(1)\n }\n\n // Create API client\n const client = GafferApiClient.fromEnv()\n\n // Create MCP server\n const server = new McpServer(\n {\n name: 'gaffer',\n version: '0.1.0',\n },\n {\n instructions: `Gaffer provides test analytics and coverage data for your projects.\n\n## Coverage Analysis Best Practices\n\nWhen helping users improve test coverage, combine coverage data with codebase exploration:\n\n1. **Understand code utilization first**: Before targeting files by coverage percentage, explore which code is critical:\n - Find entry points (route definitions, event handlers, exported functions)\n - Find heavily-imported files (files imported by many others are high-value targets)\n - Identify critical business logic (auth, payments, data mutations)\n\n2. **Prioritize by impact**: Low coverage alone doesn't indicate priority. Consider:\n - High utilization + low coverage = highest priority\n - Large files with 0% coverage have bigger impact than small files\n - Use find_uncovered_failure_areas for files with both low coverage AND test failures\n\n3. **Use path-based queries**: The get_untested_files tool may return many files of a certain type (e.g., UI components). For targeted analysis, use get_coverage_for_file with path prefixes to focus on specific areas of the codebase.\n\n4. **Iterate**: Get baseline → identify targets → write tests → re-check coverage after CI uploads new results.\n\n## Finding Invisible Files\n\nCoverage tools can only report on files that were loaded during test execution. Some files have 0% coverage but don't appear in reports at all - these are \"invisible\" files that were never imported.\n\nTo find invisible files:\n1. Use get_coverage_for_file with a path prefix (e.g., \"server/\") to see what Gaffer tracks\n2. Use the local Glob tool to list all source files in that path\n3. Compare the lists - files in local but NOT in Gaffer are invisible\n4. These files need tests that actually import them\n\nExample: If get_coverage_for_file(\"server/api\") returns user.ts, auth.ts, but Glob finds user.ts, auth.ts, billing.ts - then billing.ts is invisible and needs tests that import it.\n\n## Agentic CI / Test Failure Diagnosis\n\nWhen helping diagnose CI failures or fix failing tests:\n\n1. **Check flakiness first**: Use get_flaky_tests to identify non-deterministic tests.\n Skip flaky tests unless the user specifically wants to stabilize them.\n\n2. **Get failure details**: Use get_test_run_details with status='failed'\n to see error messages and stack traces for failing tests.\n\n3. **Group by root cause**: Use get_failure_clusters to see which failures\n share the same underlying error — fix the root cause, not individual tests.\n\n4. **Check history**: Use get_test_history to understand if the failure is new\n (regression) or recurring (existing bug).\n\n5. **Verify fixes**: After code changes, use compare_test_metrics to confirm\n the specific test now passes.\n\n6. **Prioritize by risk**: Use find_uncovered_failure_areas to identify\n which failing code has the lowest test coverage — fix those first.\n\n## Checking Upload Status\n\nWhen an agent needs to know if CI results are ready:\n\n1. Use get_upload_status with commitSha or branch to find upload sessions\n2. Check processingStatus: \"completed\" means results are ready, \"processing\" means wait\n3. Once completed, use the linked testRunIds to get test results`,\n },\n )\n\n // Register all tools using the helper\n registerTool(server, client, {\n metadata: getProjectHealthMetadata,\n inputSchema: getProjectHealthInputSchema,\n outputSchema: getProjectHealthOutputSchema,\n execute: executeGetProjectHealth,\n })\n\n registerTool(server, client, {\n metadata: getTestHistoryMetadata,\n inputSchema: getTestHistoryInputSchema,\n outputSchema: getTestHistoryOutputSchema,\n execute: executeGetTestHistory,\n })\n\n registerTool(server, client, {\n metadata: getFlakyTestsMetadata,\n inputSchema: getFlakyTestsInputSchema,\n outputSchema: getFlakyTestsOutputSchema,\n execute: executeGetFlakyTests,\n })\n\n registerTool(server, client, {\n metadata: listTestRunsMetadata,\n inputSchema: listTestRunsInputSchema,\n outputSchema: listTestRunsOutputSchema,\n execute: executeListTestRuns,\n })\n\n registerTool(server, client, {\n metadata: listProjectsMetadata,\n inputSchema: listProjectsInputSchema,\n outputSchema: listProjectsOutputSchema,\n execute: executeListProjects,\n })\n\n registerTool(server, client, {\n metadata: getReportMetadata,\n inputSchema: getReportInputSchema,\n outputSchema: getReportOutputSchema,\n execute: executeGetReport,\n })\n\n registerTool(server, client, {\n metadata: getSlowestTestsMetadata,\n inputSchema: getSlowestTestsInputSchema,\n outputSchema: getSlowestTestsOutputSchema,\n execute: executeGetSlowestTests,\n })\n\n registerTool(server, client, {\n metadata: getTestRunDetailsMetadata,\n inputSchema: getTestRunDetailsInputSchema,\n outputSchema: getTestRunDetailsOutputSchema,\n execute: executeGetTestRunDetails,\n })\n\n registerTool(server, client, {\n metadata: getFailureClustersMetadata,\n inputSchema: getFailureClustersInputSchema,\n outputSchema: getFailureClustersOutputSchema,\n execute: executeGetFailureClusters,\n })\n\n registerTool(server, client, {\n metadata: compareTestMetricsMetadata,\n inputSchema: compareTestMetricsInputSchema,\n outputSchema: compareTestMetricsOutputSchema,\n execute: executeCompareTestMetrics,\n })\n\n registerTool(server, client, {\n metadata: getCoverageSummaryMetadata,\n inputSchema: getCoverageSummaryInputSchema,\n outputSchema: getCoverageSummaryOutputSchema,\n execute: executeGetCoverageSummary,\n })\n\n registerTool(server, client, {\n metadata: getCoverageForFileMetadata,\n inputSchema: getCoverageForFileInputSchema,\n outputSchema: getCoverageForFileOutputSchema,\n execute: executeGetCoverageForFile,\n })\n\n registerTool(server, client, {\n metadata: findUncoveredFailureAreasMetadata,\n inputSchema: findUncoveredFailureAreasInputSchema,\n outputSchema: findUncoveredFailureAreasOutputSchema,\n execute: executeFindUncoveredFailureAreas,\n })\n\n registerTool(server, client, {\n metadata: getUntestedFilesMetadata,\n inputSchema: getUntestedFilesInputSchema,\n outputSchema: getUntestedFilesOutputSchema,\n execute: executeGetUntestedFiles,\n })\n\n registerTool(server, client, {\n metadata: getReportBrowserUrlMetadata,\n inputSchema: getReportBrowserUrlInputSchema,\n outputSchema: getReportBrowserUrlOutputSchema,\n execute: executeGetReportBrowserUrl,\n })\n\n registerTool(server, client, {\n metadata: getUploadStatusMetadata,\n inputSchema: getUploadStatusInputSchema,\n outputSchema: getUploadStatusOutputSchema,\n execute: executeGetUploadStatus,\n })\n\n // Connect via stdio transport\n const transport = new StdioServerTransport()\n await server.connect(transport)\n}\n\n// Run the server\nmain().catch((error) => {\n console.error('Fatal error:', error)\n process.exit(1)\n})\n"],"mappings":";;;;;;;AAuBA,MAAM,MADU,cAAc,OAAO,KAAK,IAAI,CAC1B,kBAAkB;AAGtC,MAAM,qBAAqB;AAG3B,MAAM,cAAc;AACpB,MAAM,yBAAyB;AAC/B,MAAM,yBAAyB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAI;;;;AAK7D,SAAS,MAAM,IAA2B;AACxC,QAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC;;;;;;;AAaxD,SAAgB,gBAA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c;EACd,SAAS;EACV,CAAC;AAEF,cAAa,QAAQ,QAAQ;EAC3B,UAAU;EACV,aAAa;EACb,cAAc;EACd,SAAS;EACV,CAAC;AAEF,cAAa,QAAQ,QAAQ;EAC3B,UAAU;EACV,aAAa;EACb,cAAc;EACd,SAAS;EACV,CAAC;AAEF,cAAa,QAAQ,QAAQ;EAC3B,UAAU;EACV,aAAa;EACb,cAAc;EACd,SAAS;EACV,CAAC;AAEF,cAAa,QAAQ,QAAQ;EAC3B,UAAU;EACV,aAAa;EACb,cAAc;EACd,SAAS;EACV,CAAC;CAGF,MAAM,YAAY,IAAI,sBAAsB;AAC5C,OAAM,OAAO,QAAQ,UAAU;;AAIjC,MAAM,CAAC,OAAO,UAAU;AACtB,SAAQ,MAAM,gBAAgB,MAAM;AACpC,SAAQ,KAAK,EAAE;EACf"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/api-client.ts","../src/tools/compare-test-metrics.ts","../src/tools/find-uncovered-failure-areas.ts","../src/tools/get-coverage-for-file.ts","../src/tools/get-coverage-summary.ts","../src/tools/get-failure-clusters.ts","../src/tools/get-flaky-tests.ts","../src/tools/get-project-health.ts","../src/tools/get-report-browser-url.ts","../src/tools/get-report.ts","../src/tools/get-slowest-tests.ts","../src/tools/get-test-history.ts","../src/tools/get-test-run-details.ts","../src/tools/get-untested-files.ts","../src/tools/get-upload-status.ts","../src/tools/list-projects.ts","../src/tools/list-test-runs.ts","../src/index.ts"],"sourcesContent":["import type {\n AnalyticsResponse,\n ApiErrorResponse,\n BrowserUrlResponse,\n CompareTestResponse,\n CoverageFilesResponse,\n CoverageRiskAreasResponse,\n CoverageSummaryResponse,\n FailureClustersResponse,\n FlakyTestsResponse,\n GafferConfig,\n ProjectsResponse,\n ReportResponse,\n SlowestTestsResponse,\n TestHistoryResponse,\n TestRunDetailsResponse,\n TestRunsResponse,\n UploadSessionDetailResponse,\n UploadSessionsResponse,\n} from './types.js'\nimport { createRequire } from 'node:module'\n\nconst require = createRequire(import.meta.url)\nconst pkg = require('../package.json') as { version: string }\n\n// Request timeout in milliseconds (30 seconds)\nconst REQUEST_TIMEOUT_MS = 30000\n\n// Retry configuration\nconst MAX_RETRIES = 3\nconst INITIAL_RETRY_DELAY_MS = 1000\nconst RETRYABLE_STATUS_CODES = [401, 429, 500, 502, 503, 504]\n\n/**\n * Sleep for a given number of milliseconds\n */\nfunction sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\n/**\n * Token type detection based on prefix\n */\nexport type TokenType = 'user' | 'project'\n\n/**\n * Detect token type from prefix\n * - gaf_ = user API Key (read-only, cross-project)\n * - gfr_ = Project Upload Token (legacy, single project)\n */\nexport function detectTokenType(token: string): TokenType {\n if (token.startsWith('gaf_')) {\n return 'user'\n }\n return 'project'\n}\n\n/**\n * Gaffer API v1 client for MCP server\n *\n * Supports two authentication modes:\n * 1. User API Keys (gaf_) - Read-only access to all user's projects\n * 2. Project Upload Tokens (gfr_) - Legacy, single project access\n */\nexport class GafferApiClient {\n private apiKey: string\n private baseUrl: string\n public readonly tokenType: TokenType\n\n constructor(config: GafferConfig) {\n this.apiKey = config.apiKey\n this.baseUrl = config.baseUrl.replace(/\\/$/, '') // Remove trailing slash\n this.tokenType = detectTokenType(config.apiKey)\n }\n\n /**\n * Create client from environment variables\n *\n * Supports:\n * - GAFFER_API_KEY (for user API Keys gaf_)\n */\n static fromEnv(): GafferApiClient {\n const apiKey = process.env.GAFFER_API_KEY\n if (!apiKey) {\n throw new Error('GAFFER_API_KEY environment variable is required')\n }\n\n const baseUrl = process.env.GAFFER_API_URL || 'https://app.gaffer.sh'\n\n return new GafferApiClient({ apiKey, baseUrl })\n }\n\n /**\n * Check if using a user API Key (enables cross-project features)\n */\n isUserToken(): boolean {\n return this.tokenType === 'user'\n }\n\n /**\n * Make authenticated request to Gaffer API with retry logic\n */\n private async request<T>(\n endpoint: string,\n params?: Record<string, string | number>,\n ): Promise<T> {\n const url = new URL(`/api/v1${endpoint}`, this.baseUrl)\n\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value))\n }\n }\n }\n\n let lastError: Error | null = null\n\n for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {\n // Set up request timeout\n const controller = new AbortController()\n const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS)\n\n try {\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'X-API-Key': this.apiKey,\n 'Accept': 'application/json',\n 'User-Agent': `gaffer-mcp/${pkg.version}`,\n },\n signal: controller.signal,\n })\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({})) as ApiErrorResponse\n\n // Check if we should retry this status code\n if (RETRYABLE_STATUS_CODES.includes(response.status) && attempt < MAX_RETRIES) {\n // For 429 (rate limit), use Retry-After header if available\n let delayMs = INITIAL_RETRY_DELAY_MS * (2 ** attempt)\n if (response.status === 429) {\n const retryAfter = response.headers.get('Retry-After')\n if (retryAfter) {\n delayMs = Math.max(delayMs, Number.parseInt(retryAfter, 10) * 1000)\n }\n }\n lastError = new Error(errorData.error?.message || `API request failed: ${response.status}`)\n await sleep(delayMs)\n continue\n }\n\n const errorMessage = errorData.error?.message || `API request failed: ${response.status}`\n throw new Error(errorMessage)\n }\n\n return response.json() as Promise<T>\n }\n catch (error) {\n clearTimeout(timeoutId)\n\n if (error instanceof Error && error.name === 'AbortError') {\n lastError = new Error(`Request timed out after ${REQUEST_TIMEOUT_MS}ms`)\n if (attempt < MAX_RETRIES) {\n await sleep(INITIAL_RETRY_DELAY_MS * (2 ** attempt))\n continue\n }\n throw lastError\n }\n\n // For network errors, retry\n if (error instanceof TypeError && attempt < MAX_RETRIES) {\n lastError = error\n await sleep(INITIAL_RETRY_DELAY_MS * (2 ** attempt))\n continue\n }\n\n throw error\n }\n finally {\n clearTimeout(timeoutId)\n }\n }\n\n // Should not reach here, but just in case\n throw lastError || new Error('Request failed after retries')\n }\n\n /**\n * List all projects the user has access to\n * Requires user API Key (gaf_)\n *\n * @param options - Query options\n * @param options.organizationId - Filter by organization ID\n * @param options.limit - Maximum number of results\n * @param options.offset - Offset for pagination\n */\n async listProjects(options: {\n organizationId?: string\n limit?: number\n offset?: number\n } = {}): Promise<ProjectsResponse> {\n if (!this.isUserToken()) {\n throw new Error('list_projects is not available with project tokens (gfr_). Your token is already scoped to a single project — call tools directly without passing projectId.')\n }\n\n return this.request<ProjectsResponse>('/user/projects', {\n ...(options.organizationId && { organizationId: options.organizationId }),\n ...(options.limit && { limit: options.limit }),\n ...(options.offset && { offset: options.offset }),\n })\n }\n\n /**\n * Get project health analytics\n *\n * @param options - Query options\n * @param options.projectId - Required for user tokens, ignored for project tokens\n * @param options.days - Analysis period in days (default: 30)\n */\n async getProjectHealth(options: {\n projectId?: string\n days?: number\n } = {}): Promise<AnalyticsResponse> {\n if (this.isUserToken()) {\n if (!options.projectId) {\n throw new Error('projectId is required when using a user API Key')\n }\n return this.request<AnalyticsResponse>(`/user/projects/${options.projectId}/health`, {\n days: options.days || 30,\n })\n }\n\n // Legacy: project token uses /project/analytics\n return this.request<AnalyticsResponse>('/project/analytics', {\n days: options.days || 30,\n })\n }\n\n /**\n * Get test history for a specific test\n *\n * @param options - Query options\n * @param options.projectId - Required for user tokens, ignored for project tokens\n * @param options.testName - Test name to search for\n * @param options.filePath - File path to search for\n * @param options.limit - Maximum number of results\n */\n async getTestHistory(options: {\n projectId?: string\n testName?: string\n filePath?: string\n limit?: number\n }): Promise<TestHistoryResponse> {\n const testName = options.testName?.trim()\n const filePath = options.filePath?.trim()\n\n if (!testName && !filePath) {\n throw new Error('Either testName or filePath is required (and must not be empty)')\n }\n\n if (this.isUserToken()) {\n if (!options.projectId) {\n throw new Error('projectId is required when using a user API Key')\n }\n return this.request<TestHistoryResponse>(`/user/projects/${options.projectId}/test-history`, {\n ...(testName && { testName }),\n ...(filePath && { filePath }),\n ...(options.limit && { limit: options.limit }),\n })\n }\n\n // Legacy: project token uses /project/test-history\n return this.request<TestHistoryResponse>('/project/test-history', {\n ...(testName && { testName }),\n ...(filePath && { filePath }),\n ...(options.limit && { limit: options.limit }),\n })\n }\n\n /**\n * Get flaky tests for the project\n *\n * @param options - Query options\n * @param options.projectId - Required for user tokens, ignored for project tokens\n * @param options.threshold - Minimum flip rate to be considered flaky (0-1)\n * @param options.limit - Maximum number of results\n * @param options.days - Analysis period in days\n */\n async getFlakyTests(options: {\n projectId?: string\n threshold?: number\n limit?: number\n days?: number\n } = {}): Promise<FlakyTestsResponse> {\n if (this.isUserToken()) {\n if (!options.projectId) {\n throw new Error('projectId is required when using a user API Key')\n }\n return this.request<FlakyTestsResponse>(`/user/projects/${options.projectId}/flaky-tests`, {\n ...(options.threshold && { threshold: options.threshold }),\n ...(options.limit && { limit: options.limit }),\n ...(options.days && { days: options.days }),\n })\n }\n\n // Legacy: project token uses /project/flaky-tests\n return this.request<FlakyTestsResponse>('/project/flaky-tests', {\n ...(options.threshold && { threshold: options.threshold }),\n ...(options.limit && { limit: options.limit }),\n ...(options.days && { days: options.days }),\n })\n }\n\n /**\n * List test runs for the project\n *\n * @param options - Query options\n * @param options.projectId - Required for user tokens, ignored for project tokens\n * @param options.commitSha - Filter by commit SHA\n * @param options.branch - Filter by branch name\n * @param options.status - Filter by status ('passed' or 'failed')\n * @param options.limit - Maximum number of results\n */\n async getTestRuns(options: {\n projectId?: string\n commitSha?: string\n branch?: string\n status?: 'passed' | 'failed'\n limit?: number\n } = {}): Promise<TestRunsResponse> {\n if (this.isUserToken()) {\n if (!options.projectId) {\n throw new Error('projectId is required when using a user API Key')\n }\n return this.request<TestRunsResponse>(`/user/projects/${options.projectId}/test-runs`, {\n ...(options.commitSha && { commitSha: options.commitSha }),\n ...(options.branch && { branch: options.branch }),\n ...(options.status && { status: options.status }),\n ...(options.limit && { limit: options.limit }),\n })\n }\n\n // Legacy: project token uses /project/test-runs\n return this.request<TestRunsResponse>('/project/test-runs', {\n ...(options.commitSha && { commitSha: options.commitSha }),\n ...(options.branch && { branch: options.branch }),\n ...(options.status && { status: options.status }),\n ...(options.limit && { limit: options.limit }),\n })\n }\n\n /**\n * Get report files for a test run\n *\n * @param testRunId - The test run ID\n * @returns Report metadata with download URLs for each file\n */\n async getReport(testRunId: string): Promise<ReportResponse> {\n if (!this.isUserToken()) {\n throw new Error('getReport requires a user API Key (gaf_). Upload Tokens (gfr_) cannot access reports via API.')\n }\n\n if (!testRunId) {\n throw new Error('testRunId is required')\n }\n\n return this.request<ReportResponse>(`/user/test-runs/${testRunId}/report`)\n }\n\n /**\n * Get slowest tests for a project\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.days - Analysis period in days (default: 30)\n * @param options.limit - Maximum number of results (default: 20)\n * @param options.framework - Filter by test framework\n * @param options.branch - Filter by git branch name\n * @returns Slowest tests sorted by P95 duration\n */\n async getSlowestTests(options: {\n projectId: string\n days?: number\n limit?: number\n framework?: string\n branch?: string\n }): Promise<SlowestTestsResponse> {\n if (!this.isUserToken()) {\n throw new Error('getSlowestTests requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n return this.request<SlowestTestsResponse>(`/user/projects/${options.projectId}/slowest-tests`, {\n ...(options.days && { days: options.days }),\n ...(options.limit && { limit: options.limit }),\n ...(options.framework && { framework: options.framework }),\n ...(options.branch && { branch: options.branch }),\n })\n }\n\n /**\n * Get parsed test results for a specific test run\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.testRunId - The test run ID (required)\n * @param options.status - Filter by test status ('passed', 'failed', 'skipped')\n * @param options.limit - Maximum number of results (default: 100)\n * @param options.offset - Pagination offset (default: 0)\n * @returns Parsed test cases with pagination\n */\n async getTestRunDetails(options: {\n projectId: string\n testRunId: string\n status?: 'passed' | 'failed' | 'skipped'\n limit?: number\n offset?: number\n }): Promise<TestRunDetailsResponse> {\n if (!this.isUserToken()) {\n throw new Error('getTestRunDetails requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n if (!options.testRunId) {\n throw new Error('testRunId is required')\n }\n\n return this.request<TestRunDetailsResponse>(\n `/user/projects/${options.projectId}/test-runs/${options.testRunId}/details`,\n {\n ...(options.status && { status: options.status }),\n ...(options.limit && { limit: options.limit }),\n ...(options.offset && { offset: options.offset }),\n },\n )\n }\n\n /**\n * Compare test metrics between two commits or test runs\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.testName - The test name to compare (required)\n * @param options.beforeCommit - Commit SHA for before (use with afterCommit)\n * @param options.afterCommit - Commit SHA for after (use with beforeCommit)\n * @param options.beforeRunId - Test run ID for before (use with afterRunId)\n * @param options.afterRunId - Test run ID for after (use with beforeRunId)\n * @returns Comparison of test metrics\n */\n async compareTestMetrics(options: {\n projectId: string\n testName: string\n beforeCommit?: string\n afterCommit?: string\n beforeRunId?: string\n afterRunId?: string\n }): Promise<CompareTestResponse> {\n if (!this.isUserToken()) {\n throw new Error('compareTestMetrics requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n if (!options.testName) {\n throw new Error('testName is required')\n }\n\n return this.request<CompareTestResponse>(\n `/user/projects/${options.projectId}/compare-test`,\n {\n testName: options.testName,\n ...(options.beforeCommit && { beforeCommit: options.beforeCommit }),\n ...(options.afterCommit && { afterCommit: options.afterCommit }),\n ...(options.beforeRunId && { beforeRunId: options.beforeRunId }),\n ...(options.afterRunId && { afterRunId: options.afterRunId }),\n },\n )\n }\n\n /**\n * Get coverage summary for a project\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.days - Analysis period in days (default: 30)\n * @returns Coverage summary with trends and lowest coverage files\n */\n async getCoverageSummary(options: {\n projectId: string\n days?: number\n }): Promise<CoverageSummaryResponse> {\n if (!this.isUserToken()) {\n throw new Error('getCoverageSummary requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n return this.request<CoverageSummaryResponse>(\n `/user/projects/${options.projectId}/coverage-summary`,\n {\n ...(options.days && { days: options.days }),\n },\n )\n }\n\n /**\n * Get coverage files for a project with filtering\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.filePath - Filter to specific file path\n * @param options.minCoverage - Minimum coverage percentage\n * @param options.maxCoverage - Maximum coverage percentage\n * @param options.limit - Maximum number of results\n * @param options.offset - Pagination offset\n * @param options.sortBy - Sort by 'path' or 'coverage'\n * @param options.sortOrder - Sort order 'asc' or 'desc'\n * @returns List of files with coverage data\n */\n async getCoverageFiles(options: {\n projectId: string\n filePath?: string\n minCoverage?: number\n maxCoverage?: number\n limit?: number\n offset?: number\n sortBy?: 'path' | 'coverage'\n sortOrder?: 'asc' | 'desc'\n }): Promise<CoverageFilesResponse> {\n if (!this.isUserToken()) {\n throw new Error('getCoverageFiles requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n return this.request<CoverageFilesResponse>(\n `/user/projects/${options.projectId}/coverage/files`,\n {\n ...(options.filePath && { filePath: options.filePath }),\n ...(options.minCoverage !== undefined && { minCoverage: options.minCoverage }),\n ...(options.maxCoverage !== undefined && { maxCoverage: options.maxCoverage }),\n ...(options.limit && { limit: options.limit }),\n ...(options.offset && { offset: options.offset }),\n ...(options.sortBy && { sortBy: options.sortBy }),\n ...(options.sortOrder && { sortOrder: options.sortOrder }),\n },\n )\n }\n\n /**\n * Get risk areas (files with low coverage AND test failures)\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.days - Analysis period in days (default: 30)\n * @param options.coverageThreshold - Include files below this coverage (default: 80)\n * @returns List of risk areas sorted by risk score\n */\n async getCoverageRiskAreas(options: {\n projectId: string\n days?: number\n coverageThreshold?: number\n }): Promise<CoverageRiskAreasResponse> {\n if (!this.isUserToken()) {\n throw new Error('getCoverageRiskAreas requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n return this.request<CoverageRiskAreasResponse>(\n `/user/projects/${options.projectId}/coverage/risk-areas`,\n {\n ...(options.days && { days: options.days }),\n ...(options.coverageThreshold !== undefined && { coverageThreshold: options.coverageThreshold }),\n },\n )\n }\n\n /**\n * Get a browser-navigable URL for viewing a test report\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.testRunId - The test run ID (required)\n * @param options.filename - Specific file to open (default: index.html)\n * @returns URL with signed token for browser access\n */\n async getReportBrowserUrl(options: {\n projectId: string\n testRunId: string\n filename?: string\n }): Promise<BrowserUrlResponse> {\n if (!this.isUserToken()) {\n throw new Error('getReportBrowserUrl requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n if (!options.testRunId) {\n throw new Error('testRunId is required')\n }\n\n return this.request<BrowserUrlResponse>(\n `/user/projects/${options.projectId}/reports/${options.testRunId}/browser-url`,\n {\n ...(options.filename && { filename: options.filename }),\n },\n )\n }\n\n /**\n * Get failure clusters for a test run\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.testRunId - The test run ID (required)\n * @returns Failure clusters grouped by error similarity\n */\n async getFailureClusters(options: {\n projectId: string\n testRunId: string\n }): Promise<FailureClustersResponse> {\n if (!this.isUserToken()) {\n throw new Error('getFailureClusters requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n if (!options.testRunId) {\n throw new Error('testRunId is required')\n }\n\n return this.request<FailureClustersResponse>(\n `/user/projects/${options.projectId}/test-runs/${options.testRunId}/failure-clusters`,\n )\n }\n\n /**\n * List upload sessions for a project\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.commitSha - Filter by commit SHA\n * @param options.branch - Filter by branch name\n * @param options.limit - Maximum number of results (default: 10)\n * @param options.offset - Pagination offset (default: 0)\n * @returns Paginated list of upload sessions\n */\n async listUploadSessions(options: {\n projectId: string\n commitSha?: string\n branch?: string\n limit?: number\n offset?: number\n }): Promise<UploadSessionsResponse> {\n if (!this.isUserToken()) {\n throw new Error('listUploadSessions requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n return this.request<UploadSessionsResponse>(\n `/user/projects/${options.projectId}/upload-sessions`,\n {\n ...(options.commitSha && { commitSha: options.commitSha }),\n ...(options.branch && { branch: options.branch }),\n ...(options.limit && { limit: options.limit }),\n ...(options.offset && { offset: options.offset }),\n },\n )\n }\n\n /**\n * Get upload session detail with linked results\n *\n * @param options - Query options\n * @param options.projectId - The project ID (required)\n * @param options.sessionId - The upload session ID (required)\n * @returns Upload session details with linked test runs and coverage reports\n */\n async getUploadSessionDetail(options: {\n projectId: string\n sessionId: string\n }): Promise<UploadSessionDetailResponse> {\n if (!this.isUserToken()) {\n throw new Error('getUploadSessionDetail requires a user API Key (gaf_).')\n }\n\n if (!options.projectId) {\n throw new Error('projectId is required')\n }\n\n if (!options.sessionId) {\n throw new Error('sessionId is required')\n }\n\n return this.request<UploadSessionDetailResponse>(\n `/user/projects/${options.projectId}/upload-sessions/${options.sessionId}`,\n )\n }\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport type { CompareTestResponse } from '../types.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for compare_test_metrics tool\n */\nexport const compareTestMetricsInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n testName: z\n .string()\n .describe('The test name to compare. Can be the short name or full name including describe blocks.'),\n beforeCommit: z\n .string()\n .optional()\n .describe('Commit SHA for the \"before\" measurement. Use with afterCommit.'),\n afterCommit: z\n .string()\n .optional()\n .describe('Commit SHA for the \"after\" measurement. Use with beforeCommit.'),\n beforeRunId: z\n .string()\n .optional()\n .describe('Test run ID for the \"before\" measurement. Use with afterRunId.'),\n afterRunId: z\n .string()\n .optional()\n .describe('Test run ID for the \"after\" measurement. Use with beforeRunId.'),\n}\n\n/**\n * Output schema for compare_test_metrics tool\n */\nexport const compareTestMetricsOutputSchema = {\n testName: z.string(),\n before: z.object({\n testRunId: z.string(),\n commit: z.string().nullable(),\n branch: z.string().nullable(),\n status: z.enum(['passed', 'failed', 'skipped']),\n durationMs: z.number().nullable(),\n createdAt: z.string(),\n }),\n after: z.object({\n testRunId: z.string(),\n commit: z.string().nullable(),\n branch: z.string().nullable(),\n status: z.enum(['passed', 'failed', 'skipped']),\n durationMs: z.number().nullable(),\n createdAt: z.string(),\n }),\n change: z.object({\n durationMs: z.number().nullable(),\n percentChange: z.number().nullable(),\n statusChanged: z.boolean(),\n }),\n}\n\nexport interface CompareTestMetricsInput {\n projectId: string\n testName: string\n beforeCommit?: string\n afterCommit?: string\n beforeRunId?: string\n afterRunId?: string\n}\n\n// Re-export response type from types.ts for convenience\nexport type CompareTestMetricsOutput = CompareTestResponse\n\n/**\n * Execute compare_test_metrics tool\n */\nexport async function executeCompareTestMetrics(\n client: GafferApiClient,\n input: CompareTestMetricsInput,\n): Promise<CompareTestMetricsOutput> {\n // Validate input - check for presence of required pairs\n const hasCommits = input.beforeCommit && input.afterCommit\n const hasRunIds = input.beforeRunId && input.afterRunId\n\n if (!hasCommits && !hasRunIds) {\n throw new Error('Must provide either (beforeCommit + afterCommit) or (beforeRunId + afterRunId)')\n }\n\n // Validate non-empty strings\n if (hasCommits) {\n if (input.beforeCommit!.trim().length === 0 || input.afterCommit!.trim().length === 0) {\n throw new Error('beforeCommit and afterCommit must not be empty strings')\n }\n }\n\n if (hasRunIds) {\n if (input.beforeRunId!.trim().length === 0 || input.afterRunId!.trim().length === 0) {\n throw new Error('beforeRunId and afterRunId must not be empty strings')\n }\n }\n\n const response = await client.compareTestMetrics({\n projectId: input.projectId,\n testName: input.testName,\n beforeCommit: input.beforeCommit,\n afterCommit: input.afterCommit,\n beforeRunId: input.beforeRunId,\n afterRunId: input.afterRunId,\n })\n\n return response\n}\n\n/**\n * Tool metadata\n */\nexport const compareTestMetricsMetadata = {\n name: 'compare_test_metrics',\n title: 'Compare Test Metrics',\n description: `Compare test metrics between two commits or test runs.\n\nUseful for measuring the impact of code changes on test performance or reliability.\n\nParameters:\n- projectId (required): Project ID\n- testName (required): The test name to compare (short name or full name)\n- Option 1 - Compare by commit:\n - beforeCommit: Commit SHA for \"before\" measurement\n - afterCommit: Commit SHA for \"after\" measurement\n- Option 2 - Compare by test run:\n - beforeRunId: Test run ID for \"before\" measurement\n - afterRunId: Test run ID for \"after\" measurement\n\nReturns:\n- testName: The test that was compared\n- before: Metrics from the before commit/run\n - testRunId, commit, branch, status, durationMs, createdAt\n- after: Metrics from the after commit/run\n - testRunId, commit, branch, status, durationMs, createdAt\n- change: Calculated changes\n - durationMs: Duration difference (negative = faster)\n - percentChange: Percentage change (negative = improvement)\n - statusChanged: Whether pass/fail status changed\n\nUse cases:\n- \"Did my fix make this test faster?\"\n- \"Compare test performance between these two commits\"\n- \"Did this test start failing after my changes?\"\n- \"Show me the before/after for the slow test I optimized\"\n\nTip: Use get_test_history first to find the commit SHAs or test run IDs you want to compare.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for find_uncovered_failure_areas tool\n */\nexport const findUncoveredFailureAreasInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n days: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Number of days to analyze for test failures (default: 30)'),\n coverageThreshold: z\n .number()\n .min(0)\n .max(100)\n .optional()\n .describe('Include files with coverage below this percentage (default: 80)'),\n}\n\n/**\n * Output schema for find_uncovered_failure_areas tool\n */\nexport const findUncoveredFailureAreasOutputSchema = {\n hasCoverage: z.boolean(),\n hasTestResults: z.boolean(),\n riskAreas: z.array(z.object({\n filePath: z.string(),\n coverage: z.number(),\n failureCount: z.number(),\n riskScore: z.number(),\n testNames: z.array(z.string()),\n })),\n message: z.string().optional(),\n}\n\nexport interface FindUncoveredFailureAreasInput {\n projectId: string\n days?: number\n coverageThreshold?: number\n}\n\nexport interface FindUncoveredFailureAreasOutput {\n hasCoverage: boolean\n hasTestResults: boolean\n riskAreas: Array<{\n filePath: string\n coverage: number\n failureCount: number\n riskScore: number\n testNames: string[]\n }>\n message?: string\n}\n\n/**\n * Execute find_uncovered_failure_areas tool\n */\nexport async function executeFindUncoveredFailureAreas(\n client: GafferApiClient,\n input: FindUncoveredFailureAreasInput,\n): Promise<FindUncoveredFailureAreasOutput> {\n const response = await client.getCoverageRiskAreas({\n projectId: input.projectId,\n days: input.days,\n coverageThreshold: input.coverageThreshold,\n })\n\n return {\n hasCoverage: response.hasCoverage,\n hasTestResults: response.hasTestResults,\n riskAreas: response.riskAreas,\n message: response.message,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const findUncoveredFailureAreasMetadata = {\n name: 'find_uncovered_failure_areas',\n title: 'Find Uncovered Failure Areas',\n description: `Find areas of code that have both low coverage AND test failures.\n\nThis cross-references test failures with coverage data to identify high-risk\nareas in your codebase that need attention. Files are ranked by a \"risk score\"\ncalculated as: (100 - coverage%) × failureCount.\n\nParameters:\n- projectId: The project to analyze (required)\n- days: Analysis period for test failures (default: 30)\n- coverageThreshold: Include files below this coverage % (default: 80)\n\nReturns:\n- List of risk areas sorted by risk score (highest risk first)\n- Each area includes: file path, coverage %, failure count, risk score, test names\n\nUse this to prioritize which parts of your codebase need better test coverage.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_coverage_for_file tool\n */\nexport const getCoverageForFileInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n filePath: z\n .string()\n .describe('File path to get coverage for. Can be exact path or partial match.'),\n}\n\n/**\n * Output schema for get_coverage_for_file tool\n */\nexport const getCoverageForFileOutputSchema = {\n hasCoverage: z.boolean(),\n files: z.array(z.object({\n path: z.string(),\n lines: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n branches: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n functions: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n })),\n message: z.string().optional(),\n}\n\nexport interface GetCoverageForFileInput {\n projectId: string\n filePath: string\n}\n\nexport interface GetCoverageForFileOutput {\n hasCoverage: boolean\n files: Array<{\n path: string\n lines: { covered: number, total: number, percentage: number }\n branches: { covered: number, total: number, percentage: number }\n functions: { covered: number, total: number, percentage: number }\n }>\n message?: string\n}\n\n/**\n * Execute get_coverage_for_file tool\n */\nexport async function executeGetCoverageForFile(\n client: GafferApiClient,\n input: GetCoverageForFileInput,\n): Promise<GetCoverageForFileOutput> {\n const response = await client.getCoverageFiles({\n projectId: input.projectId,\n filePath: input.filePath,\n limit: 10, // Return up to 10 matching files\n })\n\n return {\n hasCoverage: response.hasCoverage,\n files: response.files.map(f => ({\n path: f.path,\n lines: f.lines,\n branches: f.branches,\n functions: f.functions,\n })),\n message: response.message,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getCoverageForFileMetadata = {\n name: 'get_coverage_for_file',\n title: 'Get Coverage for File',\n description: `Get coverage metrics for a specific file or files matching a path pattern.\n\nParameters:\n- projectId: The project to query (required)\n- filePath: File path to search for (exact or partial match)\n\nReturns:\n- Line coverage (covered/total/percentage)\n- Branch coverage (covered/total/percentage)\n- Function coverage (covered/total/percentage)\n\nThis is the preferred tool for targeted coverage analysis. Use path prefixes to focus on\nspecific areas of the codebase:\n- \"server/services\" - Backend service layer\n- \"server/utils\" - Backend utilities\n- \"src/api\" - API routes\n- \"lib/core\" - Core business logic\n\nBefore querying, explore the codebase to identify critical paths - entry points,\nheavily-imported files, and code handling auth/payments/data mutations.\nPrioritize: high utilization + low coverage = highest impact.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_coverage_summary tool\n */\nexport const getCoverageSummaryInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n days: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Number of days to analyze for trends (default: 30)'),\n}\n\n/**\n * Output schema for get_coverage_summary tool\n */\nexport const getCoverageSummaryOutputSchema = {\n hasCoverage: z.boolean(),\n current: z.object({\n lines: z.number(),\n branches: z.number(),\n functions: z.number(),\n }).optional(),\n trend: z.object({\n direction: z.enum(['up', 'down', 'stable']),\n change: z.number(),\n }).optional(),\n totalReports: z.number(),\n latestReportDate: z.string().nullable().optional(),\n lowestCoverageFiles: z.array(z.object({\n path: z.string(),\n coverage: z.number(),\n })).optional(),\n message: z.string().optional(),\n}\n\nexport interface GetCoverageSummaryInput {\n projectId: string\n days?: number\n}\n\nexport interface GetCoverageSummaryOutput {\n hasCoverage: boolean\n current?: {\n lines: number\n branches: number\n functions: number\n }\n trend?: {\n direction: 'up' | 'down' | 'stable'\n change: number\n }\n totalReports: number\n latestReportDate?: string | null\n lowestCoverageFiles?: Array<{\n path: string\n coverage: number\n }>\n message?: string\n}\n\n/**\n * Execute get_coverage_summary tool\n */\nexport async function executeGetCoverageSummary(\n client: GafferApiClient,\n input: GetCoverageSummaryInput,\n): Promise<GetCoverageSummaryOutput> {\n const response = await client.getCoverageSummary({\n projectId: input.projectId,\n days: input.days,\n })\n\n return {\n hasCoverage: response.hasCoverage,\n current: response.current,\n trend: response.trend,\n totalReports: response.totalReports,\n latestReportDate: response.latestReportDate,\n lowestCoverageFiles: response.lowestCoverageFiles,\n message: response.message,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getCoverageSummaryMetadata = {\n name: 'get_coverage_summary',\n title: 'Get Coverage Summary',\n description: `Get the coverage metrics summary for a project.\n\nReturns:\n- Current coverage percentages (lines, branches, functions)\n- Trend direction (up, down, stable) and change amount\n- Total number of coverage reports\n- Latest report date\n- Top 5 files with lowest coverage\n\nUse this to understand your project's overall test coverage health.\n\nAfter getting the summary, use get_coverage_for_file with path prefixes to drill into\nspecific areas (e.g., \"server/services\", \"src/api\", \"lib/core\"). This helps identify\nhigh-value targets in critical code paths rather than just the files with lowest coverage.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport type { FailureClustersResponse } from '../types.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_failure_clusters tool\n */\nexport const getFailureClustersInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n testRunId: z\n .string()\n .describe('Test run ID. Use list_test_runs to find test run IDs.'),\n}\n\n/**\n * Output schema for get_failure_clusters tool\n */\nexport const getFailureClustersOutputSchema = {\n clusters: z.array(z.object({\n representativeError: z.string(),\n count: z.number(),\n tests: z.array(z.object({\n name: z.string(),\n fullName: z.string(),\n errorMessage: z.string(),\n filePath: z.string().nullable(),\n })),\n similarity: z.number(),\n })),\n totalFailures: z.number(),\n}\n\nexport interface GetFailureClustersInput {\n projectId: string\n testRunId: string\n}\n\n/**\n * Execute get_failure_clusters tool\n */\nexport async function executeGetFailureClusters(\n client: GafferApiClient,\n input: GetFailureClustersInput,\n): Promise<FailureClustersResponse> {\n return client.getFailureClusters({\n projectId: input.projectId,\n testRunId: input.testRunId,\n })\n}\n\n/**\n * Tool metadata\n */\nexport const getFailureClustersMetadata = {\n name: 'get_failure_clusters',\n title: 'Get Failure Clusters',\n description: `Group failed tests by root cause using error message similarity.\n\nParameters:\n- projectId (required): The project ID\n- testRunId (required): The test run ID to analyze\n\nReturns:\n- clusters: Array of failure clusters, each containing:\n - representativeError: The error message representing this cluster\n - count: Number of tests with this same root cause\n - tests: Array of individual failed tests in this cluster\n - name: Short test name\n - fullName: Full test name including describe blocks\n - errorMessage: The specific error message\n - filePath: Test file path (null if not recorded)\n - similarity: Similarity threshold used for clustering (0-1)\n- totalFailures: Total number of failed tests across all clusters\n\nUse cases:\n- \"Group these 15 failures by root cause\" — often reveals 2-3 distinct bugs\n- \"Which error affects the most tests?\" — fix the largest cluster first\n- \"Are these failures related?\" — check if they land in the same cluster\n\nTip: Use get_test_run_details with status='failed' first to see raw failures,\nthen use this tool to understand which failures share the same root cause.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_flaky_tests tool\n */\nexport const getFlakyTestsInputSchema = {\n projectId: z\n .string()\n .optional()\n .describe('Project ID. Required for user API keys (gaf_). Not needed for project tokens — omit and it resolves automatically.'),\n threshold: z\n .number()\n .min(0)\n .max(1)\n .optional()\n .describe('Minimum flip rate to be considered flaky (0-1, default: 0.1 = 10%)'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of flaky tests to return (default: 50)'),\n days: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Analysis period in days (default: 30)'),\n}\n\n/**\n * Output schema for get_flaky_tests tool\n */\nexport const getFlakyTestsOutputSchema = {\n flakyTests: z.array(z.object({\n name: z.string(),\n flipRate: z.number(),\n flipCount: z.number(),\n totalRuns: z.number(),\n lastSeen: z.string(),\n flakinessScore: z.number(),\n })),\n summary: z.object({\n threshold: z.number(),\n totalFlaky: z.number(),\n period: z.number(),\n }),\n}\n\nexport interface GetFlakyTestsInput {\n projectId?: string\n threshold?: number\n limit?: number\n days?: number\n}\n\nexport interface GetFlakyTestsOutput {\n flakyTests: Array<{\n name: string\n flipRate: number\n flipCount: number\n totalRuns: number\n lastSeen: string\n flakinessScore: number\n }>\n summary: {\n threshold: number\n totalFlaky: number\n period: number\n }\n}\n\n/**\n * Execute get_flaky_tests tool\n */\nexport async function executeGetFlakyTests(\n client: GafferApiClient,\n input: GetFlakyTestsInput,\n): Promise<GetFlakyTestsOutput> {\n const response = await client.getFlakyTests({\n projectId: input.projectId,\n threshold: input.threshold,\n limit: input.limit,\n days: input.days,\n })\n\n return {\n flakyTests: response.flakyTests,\n summary: response.summary,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getFlakyTestsMetadata = {\n name: 'get_flaky_tests',\n title: 'Get Flaky Tests',\n description: `Get the list of flaky tests in a project.\n\nA test is considered flaky if it frequently switches between pass and fail states.\nTests are ranked by a composite flakinessScore that factors in flip behavior,\nfailure rate, and duration variability.\n\nReturns:\n- List of flaky tests sorted by flakinessScore (most flaky first), with:\n - name: Test name\n - flipRate: How often the test flips between pass/fail (0-1)\n - flipCount: Number of status transitions\n - totalRuns: Total test executions analyzed\n - lastSeen: When the test last ran\n - flakinessScore: Composite score (0-1) combining flip proximity, failure rate, and duration variability\n- Summary with threshold used and total count\n\nUse this after get_project_health shows flaky tests exist, to identify which\nspecific tests are flaky and need investigation.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_project_health tool\n */\nexport const getProjectHealthInputSchema = {\n projectId: z\n .string()\n .optional()\n .describe('Project ID. Required for user API keys (gaf_). Not needed for project tokens — omit and it resolves automatically.'),\n days: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Number of days to analyze (default: 30)'),\n}\n\n/**\n * Output schema for get_project_health tool\n */\nexport const getProjectHealthOutputSchema = {\n projectName: z.string(),\n healthScore: z.number(),\n passRate: z.number().nullable(),\n testRunCount: z.number(),\n flakyTestCount: z.number(),\n trend: z.enum(['up', 'down', 'stable']),\n period: z.object({\n days: z.number(),\n start: z.string(),\n end: z.string(),\n }),\n}\n\nexport interface GetProjectHealthInput {\n projectId?: string\n days?: number\n}\n\nexport interface GetProjectHealthOutput {\n projectName: string\n healthScore: number\n passRate: number | null\n testRunCount: number\n flakyTestCount: number\n trend: 'up' | 'down' | 'stable'\n period: {\n days: number\n start: string\n end: string\n }\n}\n\n/**\n * Execute get_project_health tool\n */\nexport async function executeGetProjectHealth(\n client: GafferApiClient,\n input: GetProjectHealthInput,\n): Promise<GetProjectHealthOutput> {\n const response = await client.getProjectHealth({\n projectId: input.projectId,\n days: input.days,\n })\n\n return {\n projectName: response.analytics.projectName,\n healthScore: response.analytics.healthScore,\n passRate: response.analytics.passRate,\n testRunCount: response.analytics.testRunCount,\n flakyTestCount: response.analytics.flakyTestCount,\n trend: response.analytics.trend,\n period: response.analytics.period,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getProjectHealthMetadata = {\n name: 'get_project_health',\n title: 'Get Project Health',\n description: `Get the health metrics for a project.\n\nReturns:\n- Health score (0-100): Overall project health based on pass rate and trend\n- Pass rate: Percentage of tests passing\n- Test run count: Number of test runs in the period\n- Flaky test count: Number of tests with inconsistent results\n- Trend: Whether test health is improving (up), declining (down), or stable\n\nUse this to understand the current state of your test suite.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_report_browser_url tool\n */\nexport const getReportBrowserUrlInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n testRunId: z\n .string()\n .describe('The test run ID to get the report URL for. Use list_test_runs to find test run IDs.'),\n filename: z\n .string()\n .optional()\n .describe('Specific file to open (default: index.html or first HTML file)'),\n}\n\n/**\n * Output schema for get_report_browser_url tool\n */\nexport const getReportBrowserUrlOutputSchema = {\n url: z.string(),\n filename: z.string(),\n testRunId: z.string(),\n expiresAt: z.string(),\n expiresInSeconds: z.number(),\n}\n\nexport interface GetReportBrowserUrlInput {\n projectId: string\n testRunId: string\n filename?: string\n}\n\nexport interface GetReportBrowserUrlOutput {\n url: string\n filename: string\n testRunId: string\n expiresAt: string\n expiresInSeconds: number\n}\n\n/**\n * Execute get_report_browser_url tool\n */\nexport async function executeGetReportBrowserUrl(\n client: GafferApiClient,\n input: GetReportBrowserUrlInput,\n): Promise<GetReportBrowserUrlOutput> {\n const response = await client.getReportBrowserUrl({\n projectId: input.projectId,\n testRunId: input.testRunId,\n filename: input.filename,\n })\n\n return {\n url: response.url,\n filename: response.filename,\n testRunId: response.testRunId,\n expiresAt: response.expiresAt,\n expiresInSeconds: response.expiresInSeconds,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getReportBrowserUrlMetadata = {\n name: 'get_report_browser_url',\n title: 'Get Report Browser URL',\n description: `Get a browser-navigable URL for viewing a test report (Playwright, Vitest, etc.).\n\nReturns a signed URL that can be opened directly in a browser without requiring\nthe user to log in. The URL expires after 30 minutes for security.\n\nParameters:\n- projectId: The project the test run belongs to (required)\n- testRunId: The test run to view (required)\n- filename: Specific file to open (optional, defaults to index.html)\n\nReturns:\n- url: Browser-navigable URL with signed token\n- filename: The file being accessed\n- expiresAt: ISO timestamp when the URL expires\n- expiresInSeconds: Time until expiration\n\nThe returned URL can be shared with users who need to view the report.\nNote: URLs expire after 30 minutes for security.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport type { ReportFile, ReportResponse } from '../types.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_report tool\n */\nexport const getReportInputSchema = {\n testRunId: z\n .string()\n .describe('The test run ID to get report files for. Use list_test_runs to find test run IDs.'),\n}\n\n/**\n * Output schema for get_report tool\n */\nexport const getReportOutputSchema = {\n testRunId: z.string(),\n projectId: z.string(),\n projectName: z.string(),\n resultSchema: z.string().optional(),\n files: z.array(z.object({\n filename: z.string(),\n size: z.number(),\n contentType: z.string(),\n downloadUrl: z.string(),\n })),\n urlExpiresInSeconds: z.number().optional(),\n}\n\nexport interface GetReportInput {\n testRunId: string\n}\n\n// Re-export types from types.ts for convenience\nexport type { ReportFile, ReportResponse }\n\n// Output type matches ReportResponse\nexport type GetReportOutput = ReportResponse\n\n/**\n * Execute get_report tool\n */\nexport async function executeGetReport(\n client: GafferApiClient,\n input: GetReportInput,\n): Promise<GetReportOutput> {\n const response = await client.getReport(input.testRunId)\n\n return {\n testRunId: response.testRunId,\n projectId: response.projectId,\n projectName: response.projectName,\n resultSchema: response.resultSchema,\n files: response.files.map(file => ({\n filename: file.filename,\n size: file.size,\n contentType: file.contentType,\n downloadUrl: file.downloadUrl,\n })),\n urlExpiresInSeconds: response.urlExpiresInSeconds,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getReportMetadata = {\n name: 'get_report',\n title: 'Get Report Files',\n description: `Get URLs for report files uploaded with a test run.\n\nIMPORTANT: This tool returns download URLs, not file content. You must fetch the URLs separately.\n\nReturns for each file:\n- filename: The file name (e.g., \"report.html\", \"results.json\", \"junit.xml\")\n- size: File size in bytes\n- contentType: MIME type (e.g., \"text/html\", \"application/json\", \"application/xml\")\n- downloadUrl: Presigned URL to download the file (valid for ~5 minutes)\n\nHow to use the returned URLs:\n\n1. **JSON files** (results.json, coverage.json):\n Use WebFetch with the downloadUrl to retrieve and parse the JSON content.\n Example: WebFetch(url=downloadUrl, prompt=\"Extract test results from this JSON\")\n\n2. **XML files** (junit.xml, xunit.xml):\n Use WebFetch with the downloadUrl to retrieve and parse the XML content.\n Example: WebFetch(url=downloadUrl, prompt=\"Parse the test results from this JUnit XML\")\n\n3. **HTML reports** (Playwright, pytest-html, Vitest):\n These are typically bundled React/JavaScript applications that require a browser.\n They cannot be meaningfully parsed by WebFetch.\n For programmatic analysis, use get_test_run_details instead.\n\nRecommendations:\n- For analyzing test results programmatically: Use get_test_run_details (returns parsed test data)\n- For JSON/XML files: Use this tool + WebFetch on the downloadUrl\n- For HTML reports: Direct users to view in browser, or use get_test_run_details\n\nUse cases:\n- \"What files are in this test run?\" (list available reports)\n- \"Get the coverage data from this run\" (then WebFetch the JSON URL)\n- \"Parse the JUnit XML results\" (then WebFetch the XML URL)`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport type { SlowestTestEntry, SlowestTestsResponse } from '../types.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_slowest_tests tool\n */\nexport const getSlowestTestsInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n days: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Analysis period in days (default: 30)'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of tests to return (default: 20)'),\n framework: z\n .string()\n .optional()\n .describe('Filter by test framework (e.g., \"playwright\", \"vitest\", \"jest\")'),\n branch: z\n .string()\n .optional()\n .describe('Filter by git branch name (e.g., \"main\", \"develop\")'),\n}\n\n/**\n * Output schema for get_slowest_tests tool\n */\nexport const getSlowestTestsOutputSchema = {\n slowestTests: z.array(z.object({\n name: z.string(),\n fullName: z.string(),\n filePath: z.string().optional(),\n framework: z.string().optional(),\n avgDurationMs: z.number(),\n p95DurationMs: z.number(),\n runCount: z.number(),\n })),\n summary: z.object({\n projectId: z.string(),\n projectName: z.string(),\n period: z.number(),\n totalReturned: z.number(),\n }),\n}\n\nexport interface GetSlowestTestsInput {\n projectId: string\n days?: number\n limit?: number\n framework?: string\n branch?: string\n}\n\n// Re-export types from types.ts for convenience\nexport type { SlowestTestEntry, SlowestTestsResponse }\n\n// Output type matches SlowestTestsResponse\nexport type GetSlowestTestsOutput = SlowestTestsResponse\n\n/**\n * Execute get_slowest_tests tool\n */\nexport async function executeGetSlowestTests(\n client: GafferApiClient,\n input: GetSlowestTestsInput,\n): Promise<GetSlowestTestsOutput> {\n const response = await client.getSlowestTests({\n projectId: input.projectId,\n days: input.days,\n limit: input.limit,\n framework: input.framework,\n branch: input.branch,\n })\n\n return {\n slowestTests: response.slowestTests.map(test => ({\n name: test.name,\n fullName: test.fullName,\n filePath: test.filePath,\n framework: test.framework,\n avgDurationMs: test.avgDurationMs,\n p95DurationMs: test.p95DurationMs,\n runCount: test.runCount,\n })),\n summary: response.summary,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getSlowestTestsMetadata = {\n name: 'get_slowest_tests',\n title: 'Get Slowest Tests',\n description: `Get the slowest tests in a project, sorted by P95 duration.\n\nParameters:\n- projectId (required): Project ID to analyze\n- days (optional): Analysis period in days (default: 30, max: 365)\n- limit (optional): Max tests to return (default: 20, max: 100)\n- framework (optional): Filter by framework (e.g., \"playwright\", \"vitest\")\n- branch (optional): Filter by git branch (e.g., \"main\", \"develop\")\n\nReturns:\n- List of slowest tests with:\n - name: Short test name\n - fullName: Full test name including describe blocks\n - filePath: Test file path (if available)\n - framework: Test framework used\n - avgDurationMs: Average test duration in milliseconds\n - p95DurationMs: 95th percentile duration (used for sorting)\n - runCount: Number of times the test ran in the period\n- Summary with project info and period\n\nUse cases:\n- \"Which tests are slowing down my CI pipeline?\"\n- \"Find the slowest Playwright tests to optimize\"\n- \"Show me e2e tests taking over 30 seconds\"\n- \"What are the slowest tests on the main branch?\"`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_test_history tool\n */\nexport const getTestHistoryInputSchema = {\n projectId: z\n .string()\n .optional()\n .describe('Project ID. Required for user API keys (gaf_). Not needed for project tokens — omit and it resolves automatically.'),\n testName: z\n .string()\n .optional()\n .describe('Exact test name to search for'),\n filePath: z\n .string()\n .optional()\n .describe('File path containing the test'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of results (default: 20)'),\n}\n\n/**\n * Output schema for get_test_history tool\n */\nexport const getTestHistoryOutputSchema = {\n history: z.array(z.object({\n testRunId: z.string(),\n createdAt: z.string(),\n branch: z.string().optional(),\n commitSha: z.string().optional(),\n status: z.enum(['passed', 'failed', 'skipped', 'pending']),\n durationMs: z.number(),\n message: z.string().optional(),\n })),\n summary: z.object({\n totalRuns: z.number(),\n passedRuns: z.number(),\n failedRuns: z.number(),\n passRate: z.number().nullable(),\n }),\n}\n\nexport interface GetTestHistoryInput {\n projectId?: string\n testName?: string\n filePath?: string\n limit?: number\n}\n\nexport interface GetTestHistoryOutput {\n history: Array<{\n testRunId: string\n createdAt: string\n branch?: string\n commitSha?: string\n status: 'passed' | 'failed' | 'skipped' | 'pending'\n durationMs: number\n message?: string\n }>\n summary: {\n totalRuns: number\n passedRuns: number\n failedRuns: number\n passRate: number | null\n }\n}\n\n/**\n * Execute get_test_history tool\n */\nexport async function executeGetTestHistory(\n client: GafferApiClient,\n input: GetTestHistoryInput,\n): Promise<GetTestHistoryOutput> {\n if (!input.testName && !input.filePath) {\n throw new Error('Either testName or filePath is required')\n }\n\n const response = await client.getTestHistory({\n projectId: input.projectId,\n testName: input.testName,\n filePath: input.filePath,\n limit: input.limit || 20,\n })\n\n return {\n history: response.history.map(entry => ({\n testRunId: entry.testRunId,\n createdAt: entry.createdAt,\n branch: entry.branch,\n commitSha: entry.commitSha,\n status: entry.test.status,\n durationMs: entry.test.durationMs,\n message: entry.test.message || undefined, // Convert null to undefined for schema compliance\n })),\n summary: {\n totalRuns: response.summary.totalRuns,\n passedRuns: response.summary.passedRuns,\n failedRuns: response.summary.failedRuns,\n passRate: response.summary.passRate,\n },\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getTestHistoryMetadata = {\n name: 'get_test_history',\n title: 'Get Test History',\n description: `Get the pass/fail history for a specific test.\n\nSearch by either:\n- testName: The exact name of the test (e.g., \"should handle user login\")\n- filePath: The file path containing the test (e.g., \"tests/auth.test.ts\")\n\nReturns:\n- History of test runs showing pass/fail status over time\n- Duration of each run\n- Branch and commit information\n- Error messages for failed runs\n- Summary statistics (pass rate, total runs)\n\nUse this to investigate flaky tests or understand test stability.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_test_run_details tool\n */\nexport const getTestRunDetailsInputSchema = {\n testRunId: z\n .string()\n .describe('The test run ID to get details for. Use list_test_runs to find test run IDs.'),\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n status: z\n .enum(['passed', 'failed', 'skipped'])\n .optional()\n .describe('Filter tests by status. Returns only tests matching this status.'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(500)\n .optional()\n .describe('Maximum number of tests to return (default: 100, max: 500)'),\n offset: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Number of tests to skip for pagination (default: 0)'),\n}\n\n/**\n * Output schema for get_test_run_details tool\n */\nexport const getTestRunDetailsOutputSchema = {\n testRunId: z.string(),\n commitSha: z.string().nullable(),\n branch: z.string().nullable(),\n framework: z.string().nullable(),\n createdAt: z.string(),\n summary: z.object({\n passed: z.number(),\n failed: z.number(),\n skipped: z.number(),\n total: z.number(),\n }),\n tests: z.array(z.object({\n name: z.string(),\n fullName: z.string(),\n status: z.enum(['passed', 'failed', 'skipped']),\n durationMs: z.number().nullable(),\n filePath: z.string().nullable(),\n error: z.string().nullable(),\n errorStack: z.string().nullable(),\n })),\n pagination: z.object({\n total: z.number(),\n limit: z.number(),\n offset: z.number(),\n hasMore: z.boolean(),\n }),\n}\n\nexport interface GetTestRunDetailsInput {\n testRunId: string\n projectId: string\n status?: 'passed' | 'failed' | 'skipped'\n limit?: number\n offset?: number\n}\n\nexport interface GetTestRunDetailsOutput {\n testRunId: string\n commitSha: string | null\n branch: string | null\n framework: string | null\n createdAt: string\n summary: {\n passed: number\n failed: number\n skipped: number\n total: number\n }\n tests: Array<{\n name: string\n fullName: string\n status: 'passed' | 'failed' | 'skipped'\n durationMs: number | null\n filePath: string | null\n error: string | null\n errorStack: string | null\n }>\n pagination: {\n total: number\n limit: number\n offset: number\n hasMore: boolean\n }\n}\n\n/**\n * Execute get_test_run_details tool\n */\nexport async function executeGetTestRunDetails(\n client: GafferApiClient,\n input: GetTestRunDetailsInput,\n): Promise<GetTestRunDetailsOutput> {\n const response = await client.getTestRunDetails({\n projectId: input.projectId,\n testRunId: input.testRunId,\n status: input.status,\n limit: input.limit,\n offset: input.offset,\n })\n\n return {\n testRunId: response.testRunId,\n commitSha: response.commitSha,\n branch: response.branch,\n framework: response.framework,\n createdAt: response.createdAt,\n summary: response.summary,\n tests: response.tests,\n pagination: response.pagination,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getTestRunDetailsMetadata = {\n name: 'get_test_run_details',\n title: 'Get Test Run Details',\n description: `Get parsed test results for a specific test run.\n\nParameters:\n- testRunId (required): The test run ID to get details for\n- projectId (required): Project ID the test run belongs to\n- status (optional): Filter by test status: \"passed\", \"failed\", or \"skipped\"\n- limit (optional): Max tests to return (default: 100, max: 500)\n- offset (optional): Pagination offset (default: 0)\n\nReturns:\n- testRunId: The test run ID\n- commitSha: Git commit SHA (null if not recorded)\n- branch: Git branch name (null if not recorded)\n- framework: Test framework (e.g., \"playwright\", \"vitest\")\n- createdAt: When the test run was created (ISO 8601)\n- summary: Overall counts (passed, failed, skipped, total)\n- tests: Array of individual test results with:\n - name: Short test name\n - fullName: Full test name including describe blocks\n - status: Test status (passed, failed, skipped)\n - durationMs: Test duration in milliseconds (null if not recorded)\n - filePath: Test file path (null if not recorded)\n - error: Error message for failed tests (null otherwise)\n - errorStack: Full stack trace for failed tests (null otherwise)\n- pagination: Pagination info (total, limit, offset, hasMore)\n\nUse cases:\n- \"Show me all failed tests from this test run\"\n- \"Get the test results from commit abc123\"\n- \"List tests that took the longest in this run\"\n- \"Find tests with errors in the auth module\"\n\nNote: For aggregate analytics like flaky test detection or duration trends,\nuse get_test_history, get_flaky_tests, or get_slowest_tests instead.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_untested_files tool\n */\nexport const getUntestedFilesInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n maxCoverage: z\n .number()\n .min(0)\n .max(100)\n .optional()\n .describe('Maximum coverage percentage to include (default: 10 for \"untested\")'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of files to return (default: 20)'),\n}\n\n/**\n * Output schema for get_untested_files tool\n */\nexport const getUntestedFilesOutputSchema = {\n hasCoverage: z.boolean(),\n files: z.array(z.object({\n path: z.string(),\n lines: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n branches: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n functions: z.object({\n covered: z.number(),\n total: z.number(),\n percentage: z.number(),\n }),\n })),\n totalCount: z.number(),\n message: z.string().optional(),\n}\n\nexport interface GetUntestedFilesInput {\n projectId: string\n maxCoverage?: number\n limit?: number\n}\n\nexport interface GetUntestedFilesOutput {\n hasCoverage: boolean\n files: Array<{\n path: string\n lines: { covered: number, total: number, percentage: number }\n branches: { covered: number, total: number, percentage: number }\n functions: { covered: number, total: number, percentage: number }\n }>\n totalCount: number\n message?: string\n}\n\n/**\n * Execute get_untested_files tool\n */\nexport async function executeGetUntestedFiles(\n client: GafferApiClient,\n input: GetUntestedFilesInput,\n): Promise<GetUntestedFilesOutput> {\n const maxCoverage = input.maxCoverage ?? 10\n const limit = input.limit ?? 20\n\n const response = await client.getCoverageFiles({\n projectId: input.projectId,\n maxCoverage,\n limit,\n sortBy: 'coverage',\n sortOrder: 'asc', // Lowest coverage first\n })\n\n return {\n hasCoverage: response.hasCoverage,\n files: response.files.map(f => ({\n path: f.path,\n lines: f.lines,\n branches: f.branches,\n functions: f.functions,\n })),\n totalCount: response.pagination.total,\n message: response.message,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const getUntestedFilesMetadata = {\n name: 'get_untested_files',\n title: 'Get Untested Files',\n description: `Get files with little or no test coverage.\n\nReturns files sorted by coverage percentage (lowest first), filtered\nto only include files below a coverage threshold.\n\nParameters:\n- projectId: The project to analyze (required)\n- maxCoverage: Include files with coverage at or below this % (default: 10)\n- limit: Maximum number of files to return (default: 20, max: 100)\n\nReturns:\n- List of files sorted by coverage (lowest first)\n- Each file includes line/branch/function coverage metrics\n- Total count of files matching the criteria\n\nIMPORTANT: Results may be dominated by certain file types (e.g., UI components) that are\nnumerous but not necessarily the highest priority. For targeted analysis of specific code\nareas (backend, services, utilities), use get_coverage_for_file with path prefixes instead.\n\nTo prioritize effectively, explore the codebase to understand which code is heavily utilized\n(entry points, frequently-imported files, critical business logic) and then query coverage\nfor those specific paths.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport type { UploadSessionDetailResponse, UploadSessionsResponse } from '../types.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for get_upload_status tool\n */\nexport const getUploadStatusInputSchema = {\n projectId: z\n .string()\n .describe('Project ID. Use list_projects to find project IDs.'),\n sessionId: z\n .string()\n .optional()\n .describe('Specific upload session ID. If provided, returns detailed status for that session. Otherwise, lists recent sessions.'),\n commitSha: z\n .string()\n .optional()\n .describe('Filter sessions by commit SHA. Useful for checking if results for a specific commit are ready.'),\n branch: z\n .string()\n .optional()\n .describe('Filter sessions by branch name.'),\n}\n\n/**\n * Output schema for get_upload_status tool\n */\nexport const getUploadStatusOutputSchema = {\n sessions: z.array(z.object({\n id: z.string(),\n processingStatus: z.string(),\n commitSha: z.string().nullable(),\n branch: z.string().nullable(),\n pendingFileCount: z.number(),\n failedFileCount: z.number(),\n createdAt: z.string(),\n updatedAt: z.string(),\n })).optional(),\n session: z.object({\n id: z.string(),\n processingStatus: z.string(),\n commitSha: z.string().nullable(),\n branch: z.string().nullable(),\n createdAt: z.string(),\n }).optional(),\n testRuns: z.array(z.object({\n id: z.string(),\n framework: z.string().nullable(),\n summary: z.object({\n passed: z.number(),\n failed: z.number(),\n skipped: z.number(),\n total: z.number(),\n }),\n createdAt: z.string(),\n })).optional(),\n coverageReports: z.array(z.object({\n id: z.string(),\n format: z.string(),\n createdAt: z.string(),\n })).optional(),\n pagination: z.object({\n total: z.number(),\n limit: z.number(),\n offset: z.number(),\n hasMore: z.boolean(),\n }).optional(),\n}\n\nexport interface GetUploadStatusInput {\n projectId: string\n sessionId?: string\n commitSha?: string\n branch?: string\n}\n\nexport type GetUploadStatusOutput = UploadSessionsResponse | UploadSessionDetailResponse\n\n/**\n * Execute get_upload_status tool\n */\nexport async function executeGetUploadStatus(\n client: GafferApiClient,\n input: GetUploadStatusInput,\n): Promise<GetUploadStatusOutput> {\n if (input.sessionId) {\n return client.getUploadSessionDetail({\n projectId: input.projectId,\n sessionId: input.sessionId,\n })\n }\n\n return client.listUploadSessions({\n projectId: input.projectId,\n commitSha: input.commitSha,\n branch: input.branch,\n })\n}\n\n/**\n * Tool metadata\n */\nexport const getUploadStatusMetadata = {\n name: 'get_upload_status',\n title: 'Get Upload Status',\n description: `Check if CI results have been uploaded and processed.\n\nUse this tool to answer \"are my test results ready?\" after pushing code.\n\nParameters:\n- projectId (required): The project ID\n- sessionId (optional): Specific upload session ID for detailed status\n- commitSha (optional): Filter by commit SHA to find uploads for a specific commit\n- branch (optional): Filter by branch name\n\nBehavior:\n- If sessionId is provided: returns detailed status with linked test runs and coverage reports\n- Otherwise: returns a list of recent upload sessions (filtered by commitSha/branch if provided)\n\nProcessing statuses:\n- \"pending\" — upload received, processing not started\n- \"processing\" — files are being parsed\n- \"completed\" — all files processed successfully, results are ready\n- \"error\" — some files failed to process\n\nWorkflow:\n1. After pushing code, call with commitSha to find the upload session\n2. Check processingStatus — if \"completed\", results are ready\n3. If \"processing\" or \"pending\", wait and check again\n4. Once completed, use the linked testRunIds with get_test_run_details\n\nReturns (list mode):\n- sessions: Array of upload sessions with processing status\n- pagination: Pagination info\n\nReturns (detail mode):\n- session: Upload session details\n- testRuns: Linked test run summaries (id, framework, pass/fail counts)\n- coverageReports: Linked coverage report summaries (id, format)`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for list_projects tool\n */\nexport const listProjectsInputSchema = {\n organizationId: z\n .string()\n .optional()\n .describe('Filter by organization ID (optional)'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of projects to return (default: 50)'),\n}\n\n/**\n * Output schema for list_projects tool\n */\nexport const listProjectsOutputSchema = {\n projects: z.array(z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().nullable().optional(),\n organization: z.object({\n id: z.string(),\n name: z.string(),\n slug: z.string(),\n }),\n })),\n total: z.number(),\n}\n\nexport interface ListProjectsInput {\n organizationId?: string\n limit?: number\n}\n\nexport interface ListProjectsOutput {\n projects: Array<{\n id: string\n name: string\n description?: string | null\n organization: {\n id: string\n name: string\n slug: string\n }\n }>\n total: number\n}\n\n/**\n * Execute list_projects tool\n */\nexport async function executeListProjects(\n client: GafferApiClient,\n input: ListProjectsInput,\n): Promise<ListProjectsOutput> {\n const response = await client.listProjects({\n organizationId: input.organizationId,\n limit: input.limit,\n })\n\n return {\n projects: response.projects.map(p => ({\n id: p.id,\n name: p.name,\n description: p.description,\n organization: p.organization,\n })),\n total: response.pagination.total,\n }\n}\n\n/**\n * Tool metadata\n */\nexport const listProjectsMetadata = {\n name: 'list_projects',\n title: 'List Projects',\n description: `List all projects you have access to.\n\nReturns a list of projects with their IDs, names, and organization info.\nUse this to find project IDs for other tools like get_project_health.\n\nRequires a user API Key (gaf_). Get one from Account Settings in the Gaffer dashboard.`,\n}\n","import type { GafferApiClient } from '../api-client.js'\nimport { z } from 'zod'\n\n/**\n * Input schema for list_test_runs tool\n */\nexport const listTestRunsInputSchema = {\n projectId: z\n .string()\n .optional()\n .describe('Project ID. Required for user API keys (gaf_). Not needed for project tokens — omit and it resolves automatically.'),\n commitSha: z\n .string()\n .optional()\n .describe('Filter by commit SHA (exact or prefix match)'),\n branch: z\n .string()\n .optional()\n .describe('Filter by branch name'),\n status: z\n .enum(['passed', 'failed'])\n .optional()\n .describe('Filter by status: \"passed\" (no failures) or \"failed\" (has failures)'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of test runs to return (default: 20)'),\n}\n\n/**\n * Output schema for list_test_runs tool\n */\nexport const listTestRunsOutputSchema = {\n testRuns: z.array(z.object({\n id: z.string(),\n commitSha: z.string().optional(),\n branch: z.string().optional(),\n passedCount: z.number(),\n failedCount: z.number(),\n skippedCount: z.number(),\n totalCount: z.number(),\n createdAt: z.string(),\n })),\n pagination: z.object({\n total: z.number(),\n hasMore: z.boolean(),\n }),\n}\n\nexport interface ListTestRunsInput {\n projectId?: string\n commitSha?: string\n branch?: string\n status?: 'passed' | 'failed'\n limit?: number\n}\n\nexport interface ListTestRunsOutput {\n testRuns: Array<{\n id: string\n commitSha?: string\n branch?: string\n passedCount: number\n failedCount: number\n skippedCount: number\n totalCount: number\n createdAt: string\n }>\n pagination: {\n total: number\n hasMore: boolean\n }\n}\n\n/**\n * Execute list_test_runs tool\n */\nexport async function executeListTestRuns(\n client: GafferApiClient,\n input: ListTestRunsInput,\n): Promise<ListTestRunsOutput> {\n const response = await client.getTestRuns({\n projectId: input.projectId,\n commitSha: input.commitSha,\n branch: input.branch,\n status: input.status,\n limit: input.limit || 20,\n })\n\n return {\n testRuns: response.testRuns.map(run => ({\n id: run.id,\n commitSha: run.commitSha || undefined,\n branch: run.branch || undefined,\n passedCount: run.summary.passed,\n failedCount: run.summary.failed,\n skippedCount: run.summary.skipped,\n totalCount: run.summary.total,\n createdAt: run.createdAt,\n })),\n pagination: {\n total: response.pagination.total,\n hasMore: response.pagination.hasMore,\n },\n }\n}\n\n/**\n * Tool metadata\n */\nexport const listTestRunsMetadata = {\n name: 'list_test_runs',\n title: 'List Test Runs',\n description: `List recent test runs for a project with optional filtering.\n\nFilter by:\n- commitSha: Filter by commit SHA (supports prefix matching)\n- branch: Filter by branch name\n- status: Filter by \"passed\" (no failures) or \"failed\" (has failures)\n\nReturns:\n- List of test runs with:\n - id: Test run ID (can be used with get_test_run for details)\n - commitSha: Git commit SHA\n - branch: Git branch name\n - passedCount/failedCount/skippedCount: Test counts\n - createdAt: When the test run was created\n- Pagination info (total count, hasMore flag)\n\nUse cases:\n- \"What tests failed in commit abc123?\"\n- \"Show me recent test runs on main branch\"\n- \"What's the status of tests on my feature branch?\"`,\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { GafferApiClient } from './api-client.js'\nimport {\n compareTestMetricsInputSchema,\n compareTestMetricsMetadata,\n compareTestMetricsOutputSchema,\n executeCompareTestMetrics,\n} from './tools/compare-test-metrics.js'\nimport {\n executeFindUncoveredFailureAreas,\n findUncoveredFailureAreasInputSchema,\n findUncoveredFailureAreasMetadata,\n findUncoveredFailureAreasOutputSchema,\n} from './tools/find-uncovered-failure-areas.js'\nimport {\n executeGetCoverageForFile,\n getCoverageForFileInputSchema,\n getCoverageForFileMetadata,\n getCoverageForFileOutputSchema,\n} from './tools/get-coverage-for-file.js'\nimport {\n executeGetCoverageSummary,\n getCoverageSummaryInputSchema,\n getCoverageSummaryMetadata,\n getCoverageSummaryOutputSchema,\n} from './tools/get-coverage-summary.js'\nimport {\n executeGetFailureClusters,\n getFailureClustersInputSchema,\n getFailureClustersMetadata,\n getFailureClustersOutputSchema,\n} from './tools/get-failure-clusters.js'\nimport {\n executeGetFlakyTests,\n getFlakyTestsInputSchema,\n getFlakyTestsMetadata,\n getFlakyTestsOutputSchema,\n} from './tools/get-flaky-tests.js'\nimport {\n executeGetProjectHealth,\n getProjectHealthInputSchema,\n getProjectHealthMetadata,\n getProjectHealthOutputSchema,\n} from './tools/get-project-health.js'\nimport {\n executeGetReportBrowserUrl,\n getReportBrowserUrlInputSchema,\n getReportBrowserUrlMetadata,\n getReportBrowserUrlOutputSchema,\n} from './tools/get-report-browser-url.js'\nimport {\n executeGetReport,\n getReportInputSchema,\n getReportMetadata,\n getReportOutputSchema,\n} from './tools/get-report.js'\nimport {\n executeGetSlowestTests,\n getSlowestTestsInputSchema,\n getSlowestTestsMetadata,\n getSlowestTestsOutputSchema,\n} from './tools/get-slowest-tests.js'\nimport {\n executeGetTestHistory,\n getTestHistoryInputSchema,\n getTestHistoryMetadata,\n getTestHistoryOutputSchema,\n} from './tools/get-test-history.js'\nimport {\n executeGetTestRunDetails,\n getTestRunDetailsInputSchema,\n getTestRunDetailsMetadata,\n getTestRunDetailsOutputSchema,\n} from './tools/get-test-run-details.js'\nimport {\n executeGetUntestedFiles,\n getUntestedFilesInputSchema,\n getUntestedFilesMetadata,\n getUntestedFilesOutputSchema,\n} from './tools/get-untested-files.js'\nimport {\n executeGetUploadStatus,\n getUploadStatusInputSchema,\n getUploadStatusMetadata,\n getUploadStatusOutputSchema,\n} from './tools/get-upload-status.js'\nimport {\n executeListProjects,\n listProjectsInputSchema,\n listProjectsMetadata,\n listProjectsOutputSchema,\n} from './tools/list-projects.js'\nimport {\n executeListTestRuns,\n listTestRunsInputSchema,\n listTestRunsMetadata,\n listTestRunsOutputSchema,\n} from './tools/list-test-runs.js'\n\n/**\n * Log error to stderr for observability\n * MCP uses stdout for communication, so stderr is safe for logging\n */\nfunction logError(toolName: string, error: unknown): void {\n const timestamp = new Date().toISOString()\n const message = error instanceof Error ? error.message : 'Unknown error'\n const stack = error instanceof Error ? error.stack : undefined\n console.error(`[${timestamp}] [gaffer-mcp] ${toolName} failed: ${message}`)\n if (stack) {\n console.error(stack)\n }\n}\n\n/**\n * Handle tool error: log it and return MCP error response\n */\nfunction handleToolError(toolName: string, error: unknown): { content: { type: 'text', text: string }[], isError: true } {\n logError(toolName, error)\n const message = error instanceof Error ? error.message : 'Unknown error'\n return {\n content: [{ type: 'text' as const, text: `Error: ${message}` }],\n isError: true,\n }\n}\n\n/**\n * Tool definition for registration helper.\n * Schema types use `any` to accommodate the MCP SDK's complex Zod type requirements.\n */\ninterface ToolDefinition<TInput, TOutput> {\n metadata: { name: string, title: string, description: string }\n inputSchema: any\n outputSchema: any\n execute: (client: GafferApiClient, input: TInput) => Promise<TOutput>\n}\n\n/**\n * Register a tool with the MCP server using a consistent pattern.\n * Reduces boilerplate by handling error wrapping and response formatting.\n */\nfunction registerTool<TInput, TOutput>(\n server: McpServer,\n client: GafferApiClient,\n tool: ToolDefinition<TInput, TOutput>,\n): void {\n server.registerTool(\n tool.metadata.name,\n {\n title: tool.metadata.title,\n description: tool.metadata.description,\n inputSchema: tool.inputSchema,\n outputSchema: tool.outputSchema,\n },\n async (input: TInput) => {\n try {\n const output = await tool.execute(client, input)\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(output, null, 2) }],\n structuredContent: output as unknown as Record<string, unknown>,\n }\n }\n catch (error) {\n return handleToolError(tool.metadata.name, error)\n }\n },\n )\n}\n\n/**\n * Gaffer MCP Server\n *\n * Provides AI assistants with access to test history and health metrics.\n *\n * Supports two authentication modes:\n * 1. User API Keys (gaf_) - Read-only access to all user's projects\n * Set via GAFFER_API_KEY environment variable\n * 2. Project Upload Tokens (gfr_) - Legacy, single project access\n */\nasync function main() {\n // Validate API key is present\n const apiKey = process.env.GAFFER_API_KEY\n if (!apiKey) {\n console.error('Error: GAFFER_API_KEY environment variable is required')\n console.error('')\n console.error('Get your API Key from: https://app.gaffer.sh/account/api-keys')\n console.error('')\n console.error('Then configure Claude Code or Cursor with:')\n console.error(JSON.stringify({\n mcpServers: {\n gaffer: {\n command: 'npx',\n args: ['-y', '@gaffer-sh/mcp'],\n env: {\n GAFFER_API_KEY: 'gaf_your-api-key-here',\n },\n },\n },\n }, null, 2))\n process.exit(1)\n }\n\n // Create API client\n const client = GafferApiClient.fromEnv()\n\n // Create MCP server\n const server = new McpServer(\n {\n name: 'gaffer',\n version: '0.1.0',\n },\n {\n instructions: `Gaffer provides test analytics and coverage data for your projects.\n\n## Authentication\n\n${client.isUserToken()\n ? 'You have access to multiple projects. Use `list_projects` to find project IDs, then pass `projectId` to all tools.'\n : 'Your token is scoped to a single project. Do NOT call `list_projects`. Do NOT pass `projectId` — it is resolved automatically. Note: some tools (coverage, failure clusters, slowest tests, etc.) require a user API key and are not available.'}\n\n## Coverage Analysis Best Practices\n\nWhen helping users improve test coverage, combine coverage data with codebase exploration:\n\n1. **Understand code utilization first**: Before targeting files by coverage percentage, explore which code is critical:\n - Find entry points (route definitions, event handlers, exported functions)\n - Find heavily-imported files (files imported by many others are high-value targets)\n - Identify critical business logic (auth, payments, data mutations)\n\n2. **Prioritize by impact**: Low coverage alone doesn't indicate priority. Consider:\n - High utilization + low coverage = highest priority\n - Large files with 0% coverage have bigger impact than small files\n - Use find_uncovered_failure_areas for files with both low coverage AND test failures\n\n3. **Use path-based queries**: The get_untested_files tool may return many files of a certain type (e.g., UI components). For targeted analysis, use get_coverage_for_file with path prefixes to focus on specific areas of the codebase.\n\n4. **Iterate**: Get baseline → identify targets → write tests → re-check coverage after CI uploads new results.\n\n## Finding Invisible Files\n\nCoverage tools can only report on files that were loaded during test execution. Some files have 0% coverage but don't appear in reports at all - these are \"invisible\" files that were never imported.\n\nTo find invisible files:\n1. Use get_coverage_for_file with a path prefix (e.g., \"server/\") to see what Gaffer tracks\n2. Use the local Glob tool to list all source files in that path\n3. Compare the lists - files in local but NOT in Gaffer are invisible\n4. These files need tests that actually import them\n\nExample: If get_coverage_for_file(\"server/api\") returns user.ts, auth.ts, but Glob finds user.ts, auth.ts, billing.ts - then billing.ts is invisible and needs tests that import it.\n\n## Agentic CI / Test Failure Diagnosis\n\nWhen helping diagnose CI failures or fix failing tests:\n\n1. **Check flakiness first**: Use get_flaky_tests to identify non-deterministic tests.\n Skip flaky tests unless the user specifically wants to stabilize them.\n\n2. **Get failure details**: Use get_test_run_details with status='failed'\n to see error messages and stack traces for failing tests.\n\n3. **Group by root cause**: Use get_failure_clusters to see which failures\n share the same underlying error — fix the root cause, not individual tests.\n\n4. **Check history**: Use get_test_history to understand if the failure is new\n (regression) or recurring (existing bug).\n\n5. **Verify fixes**: After code changes, use compare_test_metrics to confirm\n the specific test now passes.\n\n6. **Prioritize by risk**: Use find_uncovered_failure_areas to identify\n which failing code has the lowest test coverage — fix those first.\n\n## Checking Upload Status\n\nWhen an agent needs to know if CI results are ready:\n\n1. Use get_upload_status with commitSha or branch to find upload sessions\n2. Check processingStatus: \"completed\" means results are ready, \"processing\" means wait\n3. Once completed, use the linked testRunIds to get test results`,\n },\n )\n\n // Register all tools using the helper\n registerTool(server, client, {\n metadata: getProjectHealthMetadata,\n inputSchema: getProjectHealthInputSchema,\n outputSchema: getProjectHealthOutputSchema,\n execute: executeGetProjectHealth,\n })\n\n registerTool(server, client, {\n metadata: getTestHistoryMetadata,\n inputSchema: getTestHistoryInputSchema,\n outputSchema: getTestHistoryOutputSchema,\n execute: executeGetTestHistory,\n })\n\n registerTool(server, client, {\n metadata: getFlakyTestsMetadata,\n inputSchema: getFlakyTestsInputSchema,\n outputSchema: getFlakyTestsOutputSchema,\n execute: executeGetFlakyTests,\n })\n\n registerTool(server, client, {\n metadata: listTestRunsMetadata,\n inputSchema: listTestRunsInputSchema,\n outputSchema: listTestRunsOutputSchema,\n execute: executeListTestRuns,\n })\n\n if (client.isUserToken()) {\n registerTool(server, client, {\n metadata: listProjectsMetadata,\n inputSchema: listProjectsInputSchema,\n outputSchema: listProjectsOutputSchema,\n execute: executeListProjects,\n })\n }\n\n registerTool(server, client, {\n metadata: getReportMetadata,\n inputSchema: getReportInputSchema,\n outputSchema: getReportOutputSchema,\n execute: executeGetReport,\n })\n\n registerTool(server, client, {\n metadata: getSlowestTestsMetadata,\n inputSchema: getSlowestTestsInputSchema,\n outputSchema: getSlowestTestsOutputSchema,\n execute: executeGetSlowestTests,\n })\n\n registerTool(server, client, {\n metadata: getTestRunDetailsMetadata,\n inputSchema: getTestRunDetailsInputSchema,\n outputSchema: getTestRunDetailsOutputSchema,\n execute: executeGetTestRunDetails,\n })\n\n registerTool(server, client, {\n metadata: getFailureClustersMetadata,\n inputSchema: getFailureClustersInputSchema,\n outputSchema: getFailureClustersOutputSchema,\n execute: executeGetFailureClusters,\n })\n\n registerTool(server, client, {\n metadata: compareTestMetricsMetadata,\n inputSchema: compareTestMetricsInputSchema,\n outputSchema: compareTestMetricsOutputSchema,\n execute: executeCompareTestMetrics,\n })\n\n registerTool(server, client, {\n metadata: getCoverageSummaryMetadata,\n inputSchema: getCoverageSummaryInputSchema,\n outputSchema: getCoverageSummaryOutputSchema,\n execute: executeGetCoverageSummary,\n })\n\n registerTool(server, client, {\n metadata: getCoverageForFileMetadata,\n inputSchema: getCoverageForFileInputSchema,\n outputSchema: getCoverageForFileOutputSchema,\n execute: executeGetCoverageForFile,\n })\n\n registerTool(server, client, {\n metadata: findUncoveredFailureAreasMetadata,\n inputSchema: findUncoveredFailureAreasInputSchema,\n outputSchema: findUncoveredFailureAreasOutputSchema,\n execute: executeFindUncoveredFailureAreas,\n })\n\n registerTool(server, client, {\n metadata: getUntestedFilesMetadata,\n inputSchema: getUntestedFilesInputSchema,\n outputSchema: getUntestedFilesOutputSchema,\n execute: executeGetUntestedFiles,\n })\n\n registerTool(server, client, {\n metadata: getReportBrowserUrlMetadata,\n inputSchema: getReportBrowserUrlInputSchema,\n outputSchema: getReportBrowserUrlOutputSchema,\n execute: executeGetReportBrowserUrl,\n })\n\n registerTool(server, client, {\n metadata: getUploadStatusMetadata,\n inputSchema: getUploadStatusInputSchema,\n outputSchema: getUploadStatusOutputSchema,\n execute: executeGetUploadStatus,\n })\n\n // Connect via stdio transport\n const transport = new StdioServerTransport()\n await server.connect(transport)\n}\n\n// Run the server\nmain().catch((error) => {\n console.error('Fatal error:', error)\n process.exit(1)\n})\n"],"mappings":";;;;;;;AAuBA,MAAM,MADU,cAAc,OAAO,KAAK,IAAI,CAC1B,kBAAkB;AAGtC,MAAM,qBAAqB;AAG3B,MAAM,cAAc;AACpB,MAAM,yBAAyB;AAC/B,MAAM,yBAAyB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAI;;;;AAK7D,SAAS,MAAM,IAA2B;AACxC,QAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC;;;;;;;AAaxD,SAAgB,gBAAgB,OAA0B;AACxD,KAAI,MAAM,WAAW,OAAO,CAC1B,QAAO;AAET,QAAO;;;;;;;;;AAUT,IAAa,kBAAb,MAAa,gBAAgB;CAC3B,AAAQ;CACR,AAAQ;CACR,AAAgB;CAEhB,YAAY,QAAsB;AAChC,OAAK,SAAS,OAAO;AACrB,OAAK,UAAU,OAAO,QAAQ,QAAQ,OAAO,GAAG;AAChD,OAAK,YAAY,gBAAgB,OAAO,OAAO;;;;;;;;CASjD,OAAO,UAA2B;EAChC,MAAM,SAAS,QAAQ,IAAI;AAC3B,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,kDAAkD;AAKpE,SAAO,IAAI,gBAAgB;GAAE;GAAQ,SAFrB,QAAQ,IAAI,kBAAkB;GAEA,CAAC;;;;;CAMjD,cAAuB;AACrB,SAAO,KAAK,cAAc;;;;;CAM5B,MAAc,QACZ,UACA,QACY;EACZ,MAAM,MAAM,IAAI,IAAI,UAAU,YAAY,KAAK,QAAQ;AAEvD,MAAI,QACF;QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,CAC/C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.6.1",
5
5
  "description": "MCP server for Gaffer test history - give your AI assistant memory of your tests",
6
6
  "license": "MIT",
7
7
  "author": "Gaffer <hello@gaffer.sh>",
@@ -48,6 +48,7 @@
48
48
  "postbuild": "chmod +x dist/index.js",
49
49
  "dev": "tsdown --watch",
50
50
  "typecheck": "tsc --noEmit",
51
- "release": "bumpp --tag 'mcp-v%s' --commit 'chore(mcp): release v%s' && git push --follow-tags"
51
+ "release": "bumpp --tag 'mcp-v%s' --commit 'chore(mcp): release v%s' && git push --follow-tags",
52
+ "sync": "bash scripts/sync-public-repo.sh"
52
53
  }
53
54
  }