-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.ts
More file actions
212 lines (186 loc) · 9.21 KB
/
index.ts
File metadata and controls
212 lines (186 loc) · 9.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/usr/bin/env node
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { CURRENTS_API_KEY } from "./lib/env.js";
import { logger } from "./lib/logger.js";
// Actions tools
import { listActionsTool } from "./tools/actions/list-actions.js";
import { createActionTool } from "./tools/actions/create-action.js";
import { getActionTool } from "./tools/actions/get-action.js";
import { updateActionTool } from "./tools/actions/update-action.js";
import { deleteActionTool } from "./tools/actions/delete-action.js";
import { enableActionTool } from "./tools/actions/enable-action.js";
import { disableActionTool } from "./tools/actions/disable-action.js";
// Projects tools
import { getProjectsTool } from "./tools/projects/get-projects.js";
import { getProjectTool } from "./tools/projects/get-project.js";
import { getProjectInsightsTool } from "./tools/projects/get-project-insights.js";
// Runs tools
import { getRunsTool } from "./tools/runs/get-runs.js";
import { getRunDetailsTool } from "./tools/runs/get-run.js";
import { findRunTool } from "./tools/runs/find-run.js";
import { cancelRunTool } from "./tools/runs/cancel-run.js";
import { resetRunTool } from "./tools/runs/reset-run.js";
import { deleteRunTool } from "./tools/runs/delete-run.js";
import { cancelRunByGithubCITool } from "./tools/runs/cancel-run-github-ci.js";
// Specs tools
import { getSpecFilesPerformanceTool } from "./tools/specs/get-spec-files-performance.js";
import { getSpecInstancesTool } from "./tools/specs/get-spec-instances.js";
// Tests tools
import { getTestResultsTool } from "./tools/tests/get-test-results.js";
import { getTestsPerformanceTool } from "./tools/tests/get-tests-performance.js";
import { getTestSignatureTool } from "./tools/tests/get-tests-signature.js";
if (CURRENTS_API_KEY === "") {
logger.error("CURRENTS_API_KEY env variable is not set.");
}
const server = new McpServer({
name: "currents",
version: "1.0.0",
});
// Actions API tools
server.tool(
"currents-list-actions",
"List all actions for a project with optional filtering. Actions are rules that automatically modify test behavior (skip, quarantine, tag). Supports filtering by status (active/disabled/archived/expired) and search by name. Requires a projectId.",
listActionsTool.schema,
listActionsTool.handler
);
server.tool(
"currents-create-action",
"Create a new action for a project. Actions define rules that automatically skip, quarantine, or tag tests based on conditions like test title, file path, git branch, etc. Requires projectId, name, action array, and matcher object.",
createActionTool.schema,
createActionTool.handler
);
server.tool(
"currents-get-action",
"Get a single action by ID. The actionId is globally unique, so projectId is not required. Returns full action details including matcher conditions and current status.",
getActionTool.schema,
getActionTool.handler
);
server.tool(
"currents-update-action",
"Update an existing action. The actionId is globally unique. You can update name, description, action array, matcher, or expiration date. All fields are optional.",
updateActionTool.schema,
updateActionTool.handler
);
server.tool(
"currents-delete-action",
"Delete (archive) an action. This is a soft delete - the action will be marked as archived but not permanently removed. The actionId is globally unique.",
deleteActionTool.schema,
deleteActionTool.handler
);
server.tool(
"currents-enable-action",
"Enable a disabled action. Changes the action status from disabled to active, making it apply to matching tests again. The actionId is globally unique.",
enableActionTool.schema,
enableActionTool.handler
);
server.tool(
"currents-disable-action",
"Disable an active action. Changes the action status to disabled, temporarily preventing it from applying to tests. The actionId is globally unique.",
disableActionTool.schema,
disableActionTool.handler
);
// Projects API tools
server.tool(
"currents-get-projects",
"Retrieves projects available in the Currents platform. Supports cursor-based pagination with limit, starting_after, ending_before parameters, or set fetchAll=true for automatic pagination. This is a prerequisite for using any other tools that require project-specific information.",
getProjectsTool.schema,
getProjectsTool.handler
);
server.tool(
"currents-get-project",
"Get a single project by ID. Returns project details including name, creation date, failFast setting, inactivity timeout, and default branch name.",
getProjectTool.schema,
getProjectTool.handler
);
server.tool(
"currents-get-project-insights",
"Get aggregated run and test metrics for a project within a date range. Returns overall metrics and timeline data with configurable resolution (1h/1d/1w). Supports filtering by tags, branches, groups, and authors. Requires projectId, date_start, and date_end.",
getProjectInsightsTool.schema,
getProjectInsightsTool.handler
);
// Runs API tools
server.tool(
"currents-get-runs",
"Retrieves a list of runs for a specific project with optional filtering. Supports filtering by branch, tags (with AND/OR operators), status (PASSED/FAILED/RUNNING/FAILING), completion state, date range, commit author, and search by ciBuildId or commit message. Requires a projectId. If the projectId is not known, first call 'currents-get-projects' and ask the user to select the project.",
getRunsTool.schema,
getRunsTool.handler
);
server.tool(
"currents-get-run-details",
"Retrieves details of a specific test run. Requires a user-provided runId.",
getRunDetailsTool.schema,
getRunDetailsTool.handler
);
server.tool(
"currents-find-run",
"Find a run by query parameters. Returns the most recent completed run matching the criteria. Can search by ciBuildId (exact match) or by branch/tags. Supports pwLastRun flag for Playwright last run info. Requires projectId.",
findRunTool.schema,
findRunTool.handler
);
server.tool(
"currents-cancel-run",
"Cancel a run in progress. This will stop the run and mark it as cancelled. Requires runId.",
cancelRunTool.schema,
cancelRunTool.handler
);
server.tool(
"currents-reset-run",
"Reset failed spec files in a run to allow re-execution. Requires runId and machineId array (1-63 machine IDs). Optionally supports batched orchestration.",
resetRunTool.schema,
resetRunTool.handler
);
server.tool(
"currents-delete-run",
"Delete a run and all associated data. This is a permanent deletion. Requires runId.",
deleteRunTool.schema,
deleteRunTool.handler
);
server.tool(
"currents-cancel-run-github-ci",
"Cancel a run by GitHub Actions workflow run ID and attempt number. Optionally scope by projectId or ciBuildId. Requires githubRunId and githubRunAttempt.",
cancelRunByGithubCITool.schema,
cancelRunByGithubCITool.handler
);
// Specs API tools
server.tool(
"currents-get-spec-instance",
"Retrieves debugging data from a specific execution of a test spec file by instanceId.",
getSpecInstancesTool.schema,
getSpecInstancesTool.handler
);
server.tool(
"currents-get-spec-files-performance",
"Retrieves spec files performance metrics for a specific project within a date range. Supports ordering by avgDuration, failedExecutions, failureRate, flakeRate, flakyExecutions, fullyReported, overallExecutions, suiteSize, timeoutExecutions, or timeoutRate. Supports filtering by tags, branches, groups, and authors. Requires a projectId. If the projectId is not known, first call 'currents-get-projects' and ask the user to select the project.",
getSpecFilesPerformanceTool.schema,
getSpecFilesPerformanceTool.handler
);
// Tests API tools
server.tool(
"currents-get-tests-performance",
"Retrieves aggregated test metrics for a specific project within a date range. Supports ordering by failures, passes, flakiness, duration, executions, title, and various delta metrics. Supports filtering by spec name, test title, tags, branches, groups, authors, minimum executions, and test state. Requires a projectId. If the projectId is not known, first call 'currents-get-projects' and ask the user to select the project.",
getTestsPerformanceTool.schema,
getTestsPerformanceTool.handler
);
server.tool(
"currents-get-tests-signatures",
"Generates a unique test signature based on project, spec file path, and test title. The test title can be a string or array of strings (for nested describe blocks). Requires a projectId. If the projectId is not known, first call 'currents-get-projects' and ask the user to select the project.",
getTestSignatureTool.schema,
getTestSignatureTool.handler
);
server.tool(
"currents-get-test-results",
"Retrieves historical test execution results for a specific test signature. Supports filtering by date range, branch, tags, git author, test status (passed/failed/pending/skipped), and run group. Requires the test signature. If the signature is not known, first call 'currents-get-test-signature'.",
getTestResultsTool.schema,
getTestResultsTool.handler
);
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
logger.debug("🚀 Currents MCP Server is live");
await new Promise(() => {});
}
main().catch((error) => {
logger.error("Fatal error in main():", error);
process.exit(1);
});