@applitools/mcp 0.4.3 → 0.5.0
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/CHANGELOG.md +20 -0
- package/README.md +7 -5
- package/dist/docs/README.md +7 -5
- package/dist/index.js +198 -115
- package/dist/index.js.map +1 -1
- package/docs/README.md +7 -5
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,26 @@ All notable changes to the Applitools Eyes MCP will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.5.0](https://github.com/Applitools-Dev/sdk/compare/js/mcp@0.4.3...js/mcp@0.5.0) (2026-03-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* improve playwright reporter instructions and stale verifications | AD-13006 ([#3667](https://github.com/Applitools-Dev/sdk/issues/3667)) ([57cc595](https://github.com/Applitools-Dev/sdk/commit/57cc5953c4ac12d5b92ed6888f1007177924e1ae))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* update mcp readme instructions ([#3663](https://github.com/Applitools-Dev/sdk/issues/3663)) ([065d433](https://github.com/Applitools-Dev/sdk/commit/065d4333eddf36a26907e66339f7506db0bd5f59))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Dependencies
|
|
22
|
+
|
|
23
|
+
* @applitools/core-base bumped to 1.32.3
|
|
24
|
+
#### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* pass gzip content encoding | FLD-4293 ([#3649](https://github.com/Applitools-Dev/sdk/issues/3649)) ([b78ebaa](https://github.com/Applitools-Dev/sdk/commit/b78ebaa0bb0d9aeae0d5b7031d320ca10b5f608b))
|
|
27
|
+
|
|
8
28
|
## [0.4.3](https://github.com/Applitools-Dev/sdk/compare/js/mcp@0.4.2...js/mcp@0.4.3) (2026-03-12)
|
|
9
29
|
|
|
10
30
|
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ All without requiring manual, error-prone steps.
|
|
|
25
25
|
* Existing Eyes Playwright Fixtures users
|
|
26
26
|
* Who want to use the MCP server to:
|
|
27
27
|
* Add Ultrafast Grid coverage (cross-browser and device testing)
|
|
28
|
-
*
|
|
28
|
+
* Quickly convert existing tests into visual tests using Appplitools visual AI
|
|
29
29
|
* Retrieve and analyze your visual test results
|
|
30
30
|
|
|
31
31
|
## Requirements & Limitations
|
|
@@ -42,15 +42,15 @@ Recommended: VS Code Extension or Cursor MCP Install
|
|
|
42
42
|
The easiest way to start using Eyes MCP is through the Applitools VS Code extension or by installing the MCP server directly in Cursor.
|
|
43
43
|
|
|
44
44
|
* Runs the MCP server automatically
|
|
45
|
-
* Connects it to
|
|
45
|
+
* Connects it to Copilot or Cursor's AI assistantd
|
|
46
46
|
* Provide context-aware code edits
|
|
47
47
|
* Surface visual test results inside your IDE or MCP client CLI of choice
|
|
48
48
|
|
|
49
|
-
<a href="
|
|
49
|
+
<a href="vscode:extension/applitools.mcp-vscode-extension">
|
|
50
50
|
<img src="https://img.shields.io/badge/Install-VS_Code-007ACC?logo=visualstudiocode&logoColor=white">
|
|
51
51
|
</a>
|
|
52
52
|
|
|
53
|
-
<a href="cursor
|
|
53
|
+
<a href="cursor:extension/applitools.mcp-vscode-extension">
|
|
54
54
|
<img src="https://img.shields.io/badge/Install-Cursor-000000">
|
|
55
55
|
</a>
|
|
56
56
|
<br></br>
|
|
@@ -84,6 +84,7 @@ Standard MCP configuration:
|
|
|
84
84
|
|
|
85
85
|
<details>
|
|
86
86
|
<summary>VS Code</summary>
|
|
87
|
+
|
|
87
88
|
Please see the [VS Code MCP install guide](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server) and use the standard config above.
|
|
88
89
|
|
|
89
90
|
Alternatively, install it via the VS Code CLI:
|
|
@@ -116,12 +117,13 @@ Create or edit the configuration file ~/.copilot/mcp-config.json and add:
|
|
|
116
117
|
<details>
|
|
117
118
|
<summary>Cursor</summary>
|
|
118
119
|
In your user root directory, edit or add the above configuration to your `~/.cursor/mcp.json` file.
|
|
119
|
-
|
|
120
|
+
<br></br>
|
|
120
121
|
Alternatively, go to Cursor Settings -> MCP -> Add new MCP Server. Name it `applitools-mcp`, use `command` type with the command `npx -y @applitools/mcp@latest`.
|
|
121
122
|
</details>
|
|
122
123
|
|
|
123
124
|
<details>
|
|
124
125
|
<summary>Cline</summary>
|
|
126
|
+
|
|
125
127
|
Follow the instruction in the section [Configuring MCP Servers](https://docs.cline.bot/mcp/configuring-mcp-servers)
|
|
126
128
|
|
|
127
129
|
Add the following to your `cline_mcp_settings.json` file:
|
package/dist/docs/README.md
CHANGED
|
@@ -25,7 +25,7 @@ All without requiring manual, error-prone steps.
|
|
|
25
25
|
* Existing Eyes Playwright Fixtures users
|
|
26
26
|
* Who want to use the MCP server to:
|
|
27
27
|
* Add Ultrafast Grid coverage (cross-browser and device testing)
|
|
28
|
-
*
|
|
28
|
+
* Quickly convert existing tests into visual tests using Appplitools visual AI
|
|
29
29
|
* Retrieve and analyze your visual test results
|
|
30
30
|
|
|
31
31
|
## Requirements & Limitations
|
|
@@ -42,15 +42,15 @@ Recommended: VS Code Extension or Cursor MCP Install
|
|
|
42
42
|
The easiest way to start using Eyes MCP is through the Applitools VS Code extension or by installing the MCP server directly in Cursor.
|
|
43
43
|
|
|
44
44
|
* Runs the MCP server automatically
|
|
45
|
-
* Connects it to
|
|
45
|
+
* Connects it to Copilot or Cursor's AI assistantd
|
|
46
46
|
* Provide context-aware code edits
|
|
47
47
|
* Surface visual test results inside your IDE or MCP client CLI of choice
|
|
48
48
|
|
|
49
|
-
<a href="
|
|
49
|
+
<a href="vscode:extension/applitools.mcp-vscode-extension">
|
|
50
50
|
<img src="https://img.shields.io/badge/Install-VS_Code-007ACC?logo=visualstudiocode&logoColor=white">
|
|
51
51
|
</a>
|
|
52
52
|
|
|
53
|
-
<a href="cursor
|
|
53
|
+
<a href="cursor:extension/applitools.mcp-vscode-extension">
|
|
54
54
|
<img src="https://img.shields.io/badge/Install-Cursor-000000">
|
|
55
55
|
</a>
|
|
56
56
|
<br></br>
|
|
@@ -84,6 +84,7 @@ Standard MCP configuration:
|
|
|
84
84
|
|
|
85
85
|
<details>
|
|
86
86
|
<summary>VS Code</summary>
|
|
87
|
+
|
|
87
88
|
Please see the [VS Code MCP install guide](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server) and use the standard config above.
|
|
88
89
|
|
|
89
90
|
Alternatively, install it via the VS Code CLI:
|
|
@@ -116,12 +117,13 @@ Create or edit the configuration file ~/.copilot/mcp-config.json and add:
|
|
|
116
117
|
<details>
|
|
117
118
|
<summary>Cursor</summary>
|
|
118
119
|
In your user root directory, edit or add the above configuration to your `~/.cursor/mcp.json` file.
|
|
119
|
-
|
|
120
|
+
<br></br>
|
|
120
121
|
Alternatively, go to Cursor Settings -> MCP -> Add new MCP Server. Name it `applitools-mcp`, use `command` type with the command `npx -y @applitools/mcp@latest`.
|
|
121
122
|
</details>
|
|
122
123
|
|
|
123
124
|
<details>
|
|
124
125
|
<summary>Cline</summary>
|
|
126
|
+
|
|
125
127
|
Follow the instruction in the section [Configuring MCP Servers](https://docs.cline.bot/mcp/configuring-mcp-servers)
|
|
126
128
|
|
|
127
129
|
Add the following to your `cline_mcp_settings.json` file:
|
package/dist/index.js
CHANGED
|
@@ -22649,6 +22649,10 @@ const handler = (() => {
|
|
|
22649
22649
|
error: (message) => console.error(message),
|
|
22650
22650
|
};
|
|
22651
22651
|
})();
|
|
22652
|
+
// Only perform expensive serialisation when a log sink is explicitly configured.
|
|
22653
|
+
const isVerboseLogging = !!(process.env.APPLITOOLS_LOG_FILE ||
|
|
22654
|
+
process.env.APPLITOOLS_LOG_DIR ||
|
|
22655
|
+
process.env.APPLITOOLS_SHOW_LOGS);
|
|
22652
22656
|
const logger = logger$1.makeLogger({ level: 'all', handler });
|
|
22653
22657
|
const externalLogger = coreBase.makeCore({
|
|
22654
22658
|
agentId: 'mcp-tool-handler',
|
|
@@ -22730,12 +22734,10 @@ async function readDocumentationResource(uri) {
|
|
|
22730
22734
|
}
|
|
22731
22735
|
}
|
|
22732
22736
|
|
|
22733
|
-
const validatedApiKeys = new Set();
|
|
22734
22737
|
const sessionMetadata = {
|
|
22735
22738
|
validationCount: 0,
|
|
22736
22739
|
};
|
|
22737
22740
|
function markApiKeyAsValidated(apiKey, serverUrl) {
|
|
22738
|
-
validatedApiKeys.add(apiKey);
|
|
22739
22741
|
sessionMetadata.lastValidatedApiKey = apiKey;
|
|
22740
22742
|
sessionMetadata.lastValidatedServerUrl = serverUrl;
|
|
22741
22743
|
sessionMetadata.validationCount++;
|
|
@@ -22998,23 +23000,25 @@ function selectFromDetected(detected) {
|
|
|
22998
23000
|
const selected = (_a = supportedMatch !== null && supportedMatch !== void 0 ? supportedMatch : detected[0]) !== null && _a !== void 0 ? _a : {};
|
|
22999
23001
|
return { selected, detected };
|
|
23000
23002
|
}
|
|
23003
|
+
function resolveEffectiveRoot(workingDirectory, activeFile) {
|
|
23004
|
+
const projectRoot = findProjectRoot(workingDirectory);
|
|
23005
|
+
if (!activeFile)
|
|
23006
|
+
return projectRoot;
|
|
23007
|
+
const workspacePackageJsonPath = path.join(projectRoot, 'package.json');
|
|
23008
|
+
if (fs.existsSync(workspacePackageJsonPath) && isMonorepo(workspacePackageJsonPath)) {
|
|
23009
|
+
const nearestPackageDir = findNearestPackageJson(activeFile, projectRoot);
|
|
23010
|
+
if (nearestPackageDir)
|
|
23011
|
+
return nearestPackageDir;
|
|
23012
|
+
}
|
|
23013
|
+
return projectRoot;
|
|
23014
|
+
}
|
|
23001
23015
|
/**
|
|
23002
23016
|
* Detects all automation frameworks at or near the given directory.
|
|
23003
23017
|
* Checks package.json, requirements.txt, pyproject.toml, then filename heuristics.
|
|
23004
23018
|
* Returns the primary selected framework (preferring supported ones) and all detected frameworks.
|
|
23005
23019
|
*/
|
|
23006
23020
|
function getAutomationFramework(workingDirectory, activeFile) {
|
|
23007
|
-
|
|
23008
|
-
// In monorepos, use the nearest sub-package to the active file instead of the root.
|
|
23009
|
-
if (activeFile) {
|
|
23010
|
-
const workspacePackageJsonPath = path.join(projectRoot, 'package.json');
|
|
23011
|
-
if (fs.existsSync(workspacePackageJsonPath) && isMonorepo(workspacePackageJsonPath)) {
|
|
23012
|
-
const nearestPackageDir = findNearestPackageJson(activeFile, projectRoot);
|
|
23013
|
-
if (nearestPackageDir) {
|
|
23014
|
-
projectRoot = nearestPackageDir;
|
|
23015
|
-
}
|
|
23016
|
-
}
|
|
23017
|
-
}
|
|
23021
|
+
const projectRoot = resolveEffectiveRoot(workingDirectory, activeFile);
|
|
23018
23022
|
// 1. Try Node.js package.json detection
|
|
23019
23023
|
const nodeResults = detectAllFrameworksFromPackageJson(path.join(projectRoot, 'package.json'));
|
|
23020
23024
|
if (nodeResults !== null)
|
|
@@ -23059,7 +23063,7 @@ function getAutomationFramework(workingDirectory, activeFile) {
|
|
|
23059
23063
|
|
|
23060
23064
|
var name = "@applitools/mcp";
|
|
23061
23065
|
var mcpName = "io.github.applitools/applitools";
|
|
23062
|
-
var version = "0.
|
|
23066
|
+
var version = "0.5.0";
|
|
23063
23067
|
var description = "Applitools MCP server for AI coding assistants";
|
|
23064
23068
|
var main = "./dist/index.js";
|
|
23065
23069
|
var bin = "./dist/index.js";
|
|
@@ -23099,11 +23103,10 @@ var author = {
|
|
|
23099
23103
|
};
|
|
23100
23104
|
var repository = {
|
|
23101
23105
|
type: "git",
|
|
23102
|
-
url: "https://github.com/applitools/
|
|
23103
|
-
directory: "js/packages/mcp"
|
|
23106
|
+
url: "https://github.com/applitools/mcp"
|
|
23104
23107
|
};
|
|
23105
23108
|
var bugs = {
|
|
23106
|
-
url: "https://github.com/applitools/
|
|
23109
|
+
url: "https://github.com/applitools/mcp/issues"
|
|
23107
23110
|
};
|
|
23108
23111
|
var homepage = "https://applitools.com";
|
|
23109
23112
|
var files = [
|
|
@@ -23180,12 +23183,23 @@ var packageJson = {
|
|
|
23180
23183
|
lavamoat: lavamoat
|
|
23181
23184
|
};
|
|
23182
23185
|
|
|
23186
|
+
/** Recursively truncate arrays to `maxItems` before serialisation to avoid megabyte payloads in telemetry. */
|
|
23187
|
+
function truncateForTelemetry(value, maxItems = 3) {
|
|
23188
|
+
if (Array.isArray(value)) {
|
|
23189
|
+
return value.slice(0, maxItems).map(item => truncateForTelemetry(item, maxItems));
|
|
23190
|
+
}
|
|
23191
|
+
if (value !== null && typeof value === 'object') {
|
|
23192
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, truncateForTelemetry(v, maxItems)]));
|
|
23193
|
+
}
|
|
23194
|
+
return value;
|
|
23195
|
+
}
|
|
23183
23196
|
const createToolHandler = (toolDef, logic) => {
|
|
23184
23197
|
return async (params) => {
|
|
23185
23198
|
const clientInfo = getClientInfo();
|
|
23186
23199
|
log('info', `[MCP] 🟢 Tool Accessed: ${toolDef.name}`);
|
|
23187
23200
|
log('info', `[MCP] 📥 Client: ${(clientInfo === null || clientInfo === void 0 ? void 0 : clientInfo.name) || 'unknown'} v${(clientInfo === null || clientInfo === void 0 ? void 0 : clientInfo.version) || 'unknown'}`);
|
|
23188
|
-
|
|
23201
|
+
if (isVerboseLogging)
|
|
23202
|
+
log('info', `[MCP] 📥 Params:`, JSON.stringify(params, null, 2));
|
|
23189
23203
|
const safeParams = params !== null && params !== void 0 ? params : {};
|
|
23190
23204
|
const workspaceRoot = safeParams.workspaceRoot || getWorkspaceRoot() || process.cwd();
|
|
23191
23205
|
const { selected: frameworkSelected, detected: detectedFrameworks } = getAutomationFramework(workspaceRoot, safeParams.activeFile);
|
|
@@ -23198,7 +23212,7 @@ const createToolHandler = (toolDef, logic) => {
|
|
|
23198
23212
|
automationFrameworkVersion,
|
|
23199
23213
|
sdkLanguage,
|
|
23200
23214
|
};
|
|
23201
|
-
|
|
23215
|
+
externalLog('mcp_tool_invoked', {
|
|
23202
23216
|
ide: getIDE() || 'unknown',
|
|
23203
23217
|
mcp_version: packageJson.version,
|
|
23204
23218
|
tool_name: toolDef.name,
|
|
@@ -23215,19 +23229,20 @@ const createToolHandler = (toolDef, logic) => {
|
|
|
23215
23229
|
try {
|
|
23216
23230
|
const validatedParams = toolDef.input.parse(enrichedParams || {});
|
|
23217
23231
|
const result = await logic(validatedParams);
|
|
23218
|
-
|
|
23232
|
+
if (isVerboseLogging)
|
|
23233
|
+
log('info', `[MCP] 📤 Result:`, JSON.stringify(result, null, 2));
|
|
23219
23234
|
const structuredContentWithoutMessage = { ...result.structuredContent };
|
|
23220
23235
|
if (structuredContentWithoutMessage && 'message' in structuredContentWithoutMessage) {
|
|
23221
23236
|
delete structuredContentWithoutMessage.message;
|
|
23222
23237
|
}
|
|
23223
|
-
|
|
23238
|
+
externalLog('mcp_tool_succeeded', {
|
|
23224
23239
|
ide: getIDE() || 'unknown',
|
|
23225
23240
|
mcp_version: packageJson.version,
|
|
23226
23241
|
tool_name: toolDef.name,
|
|
23227
23242
|
client_name: (clientInfo === null || clientInfo === void 0 ? void 0 : clientInfo.name) || 'unknown',
|
|
23228
23243
|
client_version: (clientInfo === null || clientInfo === void 0 ? void 0 : clientInfo.version) || 'unknown',
|
|
23229
23244
|
transport_mode: TRANSPORT_MODE,
|
|
23230
|
-
params: JSON.stringify(structuredContentWithoutMessage, null, 2).slice(0, 1024),
|
|
23245
|
+
params: JSON.stringify(truncateForTelemetry(structuredContentWithoutMessage), null, 2).slice(0, 1024),
|
|
23231
23246
|
}).catch(() => { });
|
|
23232
23247
|
const handlerResult = result;
|
|
23233
23248
|
if (toolDef.output) {
|
|
@@ -23238,7 +23253,7 @@ const createToolHandler = (toolDef, logic) => {
|
|
|
23238
23253
|
return handlerResult;
|
|
23239
23254
|
}
|
|
23240
23255
|
catch (error) {
|
|
23241
|
-
|
|
23256
|
+
externalLog('mcp_tool_failed', {
|
|
23242
23257
|
ide: getIDE() || 'unknown',
|
|
23243
23258
|
mcp_version: packageJson.version,
|
|
23244
23259
|
tool_name: toolDef.name,
|
|
@@ -23291,14 +23306,42 @@ class InvalidApiKeyError extends Error {
|
|
|
23291
23306
|
}
|
|
23292
23307
|
|
|
23293
23308
|
/** API Client using Applitools req package for Eyes server communication */
|
|
23309
|
+
const DEFAULT_RETRY_CONFIG = [
|
|
23310
|
+
{
|
|
23311
|
+
codes: [
|
|
23312
|
+
'ECONNRESET',
|
|
23313
|
+
'ETIMEDOUT',
|
|
23314
|
+
'ENOTFOUND',
|
|
23315
|
+
'ECONNREFUSED',
|
|
23316
|
+
'UND_ERR_SOCKET',
|
|
23317
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
23318
|
+
'UND_ERR_HEADERS_TIMEOUT',
|
|
23319
|
+
'UND_ERR_BODY_TIMEOUT',
|
|
23320
|
+
],
|
|
23321
|
+
limit: 3,
|
|
23322
|
+
timeout: [1000, 2000, 5000],
|
|
23323
|
+
},
|
|
23324
|
+
{
|
|
23325
|
+
statuses: [500, 502, 503, 504],
|
|
23326
|
+
limit: 3,
|
|
23327
|
+
timeout: [1000, 2000, 5000],
|
|
23328
|
+
},
|
|
23329
|
+
{
|
|
23330
|
+
statuses: [429],
|
|
23331
|
+
limit: 5,
|
|
23332
|
+
timeout: [2000, 4000, 8000, 16000, 32000],
|
|
23333
|
+
},
|
|
23334
|
+
];
|
|
23294
23335
|
/**
|
|
23295
23336
|
* API Client for Eyes server using @applitools/req for automatic retry handling
|
|
23296
23337
|
*/
|
|
23297
23338
|
class ApiClient {
|
|
23298
23339
|
constructor(options) {
|
|
23340
|
+
var _a;
|
|
23299
23341
|
this.baseUrl = options.baseUrl;
|
|
23300
23342
|
this.apiKey = options.apiKey;
|
|
23301
23343
|
this.timeout = options.timeout || 30000;
|
|
23344
|
+
this.retryConfig = (_a = options.retryConfig) !== null && _a !== void 0 ? _a : DEFAULT_RETRY_CONFIG;
|
|
23302
23345
|
}
|
|
23303
23346
|
/**
|
|
23304
23347
|
* Perform a GET request with automatic retry on failures
|
|
@@ -23315,35 +23358,7 @@ class ApiClient {
|
|
|
23315
23358
|
Accept: 'application/json',
|
|
23316
23359
|
},
|
|
23317
23360
|
requestTimeout: this.timeout,
|
|
23318
|
-
retry:
|
|
23319
|
-
// Retry on network errors
|
|
23320
|
-
{
|
|
23321
|
-
codes: [
|
|
23322
|
-
'ECONNRESET',
|
|
23323
|
-
'ETIMEDOUT',
|
|
23324
|
-
'ENOTFOUND',
|
|
23325
|
-
'ECONNREFUSED',
|
|
23326
|
-
'UND_ERR_SOCKET',
|
|
23327
|
-
'UND_ERR_CONNECT_TIMEOUT',
|
|
23328
|
-
'UND_ERR_HEADERS_TIMEOUT',
|
|
23329
|
-
'UND_ERR_BODY_TIMEOUT',
|
|
23330
|
-
],
|
|
23331
|
-
limit: 3,
|
|
23332
|
-
timeout: [1000, 2000, 5000],
|
|
23333
|
-
},
|
|
23334
|
-
// Retry on server errors (500+)
|
|
23335
|
-
{
|
|
23336
|
-
statuses: [500, 502, 503, 504],
|
|
23337
|
-
limit: 3,
|
|
23338
|
-
timeout: [1000, 2000, 5000],
|
|
23339
|
-
},
|
|
23340
|
-
// Retry on 429 (rate limit)
|
|
23341
|
-
{
|
|
23342
|
-
statuses: [429],
|
|
23343
|
-
limit: 5,
|
|
23344
|
-
timeout: [2000, 4000, 8000, 16000, 32000],
|
|
23345
|
-
},
|
|
23346
|
-
],
|
|
23361
|
+
retry: this.retryConfig,
|
|
23347
23362
|
});
|
|
23348
23363
|
// Handle authentication errors
|
|
23349
23364
|
if (response.status === 401) {
|
|
@@ -23378,35 +23393,7 @@ class ApiClient {
|
|
|
23378
23393
|
},
|
|
23379
23394
|
body,
|
|
23380
23395
|
requestTimeout: this.timeout,
|
|
23381
|
-
retry:
|
|
23382
|
-
// Retry on network errors
|
|
23383
|
-
{
|
|
23384
|
-
codes: [
|
|
23385
|
-
'ECONNRESET',
|
|
23386
|
-
'ETIMEDOUT',
|
|
23387
|
-
'ENOTFOUND',
|
|
23388
|
-
'ECONNREFUSED',
|
|
23389
|
-
'UND_ERR_SOCKET',
|
|
23390
|
-
'UND_ERR_CONNECT_TIMEOUT',
|
|
23391
|
-
'UND_ERR_HEADERS_TIMEOUT',
|
|
23392
|
-
'UND_ERR_BODY_TIMEOUT',
|
|
23393
|
-
],
|
|
23394
|
-
limit: 3,
|
|
23395
|
-
timeout: [1000, 2000, 5000],
|
|
23396
|
-
},
|
|
23397
|
-
// Retry on server errors (500+)
|
|
23398
|
-
{
|
|
23399
|
-
statuses: [500, 502, 503, 504],
|
|
23400
|
-
limit: 3,
|
|
23401
|
-
timeout: [1000, 2000, 5000],
|
|
23402
|
-
},
|
|
23403
|
-
// Retry on 429 (rate limit)
|
|
23404
|
-
{
|
|
23405
|
-
statuses: [429],
|
|
23406
|
-
limit: 5,
|
|
23407
|
-
timeout: [2000, 4000, 8000, 16000, 32000],
|
|
23408
|
-
},
|
|
23409
|
-
],
|
|
23396
|
+
retry: this.retryConfig,
|
|
23410
23397
|
};
|
|
23411
23398
|
// Add API key to query for POST requests (Eyes API pattern)
|
|
23412
23399
|
const url = `${this.baseUrl}/${endpoint}${endpoint.includes('?') ? '&' : '?'}apiKey=${this.apiKey}`;
|
|
@@ -23431,6 +23418,40 @@ class ApiClient {
|
|
|
23431
23418
|
}
|
|
23432
23419
|
|
|
23433
23420
|
/** API Key Verification Utility */
|
|
23421
|
+
/**
|
|
23422
|
+
* Tight retry config for API key verification.
|
|
23423
|
+
*
|
|
23424
|
+
* Budget: max 3 retries (4 total attempts) × 2 s per attempt + 3.5 s delays = ~11.5 s worst case.
|
|
23425
|
+
* This is intentionally much shorter than the default config used for batch fetching,
|
|
23426
|
+
* because auth checks should fail fast — there is no value in retrying for minutes.
|
|
23427
|
+
*/
|
|
23428
|
+
const VERIFY_RETRY_CONFIG = [
|
|
23429
|
+
{
|
|
23430
|
+
codes: [
|
|
23431
|
+
'ECONNRESET',
|
|
23432
|
+
'ETIMEDOUT',
|
|
23433
|
+
'ENOTFOUND',
|
|
23434
|
+
'ECONNREFUSED',
|
|
23435
|
+
'UND_ERR_SOCKET',
|
|
23436
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
23437
|
+
'UND_ERR_HEADERS_TIMEOUT',
|
|
23438
|
+
'UND_ERR_BODY_TIMEOUT',
|
|
23439
|
+
],
|
|
23440
|
+
limit: 3,
|
|
23441
|
+
timeout: [200, 500, 1000],
|
|
23442
|
+
},
|
|
23443
|
+
{
|
|
23444
|
+
statuses: [500, 502, 503, 504],
|
|
23445
|
+
limit: 3,
|
|
23446
|
+
timeout: [200, 500, 1000],
|
|
23447
|
+
},
|
|
23448
|
+
// Reduced from 5 retries / 62 s to 3 retries / 1.7 s for rate-limit responses
|
|
23449
|
+
{
|
|
23450
|
+
statuses: [429],
|
|
23451
|
+
limit: 3,
|
|
23452
|
+
timeout: [200, 500, 1000],
|
|
23453
|
+
},
|
|
23454
|
+
];
|
|
23434
23455
|
/**
|
|
23435
23456
|
* Verifies an API key against the Eyes server
|
|
23436
23457
|
* @param params - The API key and server URL to verify
|
|
@@ -23442,6 +23463,8 @@ async function verifyApiKeyWithServer(params) {
|
|
|
23442
23463
|
const client = new ApiClient({
|
|
23443
23464
|
baseUrl: serverUrl,
|
|
23444
23465
|
apiKey: apiKey,
|
|
23466
|
+
timeout: 2000,
|
|
23467
|
+
retryConfig: VERIFY_RETRY_CONFIG,
|
|
23445
23468
|
});
|
|
23446
23469
|
const response = await client.get(`api/auth/access?accessKey=${apiKey}`);
|
|
23447
23470
|
log('debug', `API key verification response: ${JSON.stringify(response)}`);
|
|
@@ -23809,6 +23832,11 @@ You can run this test with the command:
|
|
|
23809
23832
|
npx eyes-setup run-example
|
|
23810
23833
|
\`\`\`
|
|
23811
23834
|
|
|
23835
|
+
**IMPORTANT: When running Playwright tests (including this example), NEVER add \`--reporter=list\`, \`--reporter=dot\`, \`--reporter=line\`, or any other \`--reporter\` flag. Doing so overrides the configured reporters and suppresses the Eyes reporter, which means the HTML report will not contain Eyes results. The "${TOOL_NAMES.EYES_FETCH_VISUAL_RESULTS}" tool will then read a stale report from a previous run and return outdated results.**
|
|
23836
|
+
|
|
23837
|
+
- ✅ CORRECT: \`npx playwright test\` or \`npx eyes-setup run-example\`
|
|
23838
|
+
- ❌ INCORRECT: \`npx playwright test --reporter=list\`
|
|
23839
|
+
|
|
23812
23840
|
Test results will be available on the Applitools dashboard: https://applitools.com/app/test-results. Use the returned URL from the command line after the test ends to access the results directly.
|
|
23813
23841
|
|
|
23814
23842
|
Extract the test results more precisely as special characters appear in the URL and should be preserved exactly as is.
|
|
@@ -24346,45 +24374,50 @@ async function parseReportFile(reportPath) {
|
|
|
24346
24374
|
if (!assignmentMatch) {
|
|
24347
24375
|
throw new Error('No Eyes test results found in the Playwright report');
|
|
24348
24376
|
}
|
|
24349
|
-
// Extract JSON with proper escape handling
|
|
24350
24377
|
const startIndex = assignmentMatch.index + assignmentMatch[0].length;
|
|
24351
|
-
|
|
24352
|
-
|
|
24353
|
-
|
|
24354
|
-
|
|
24355
|
-
|
|
24356
|
-
|
|
24357
|
-
|
|
24358
|
-
|
|
24359
|
-
|
|
24378
|
+
// Walk from startIndex to find the closing brace of the root JSON object,
|
|
24379
|
+
// correctly skipping braces that appear inside JSON string values.
|
|
24380
|
+
// Note: do NOT bound by </script> — that tag can appear verbatim inside a
|
|
24381
|
+
// JSON string value (e.g. a test named "close</script>tag"), which would
|
|
24382
|
+
// truncate the slice mid-JSON and cause a spurious parse error.
|
|
24383
|
+
// The brace walker terminates as soon as depth returns to 0.
|
|
24384
|
+
const bounded = reportHtml.slice(startIndex);
|
|
24385
|
+
let depth = 0;
|
|
24386
|
+
let inStr = false;
|
|
24387
|
+
let esc = false;
|
|
24388
|
+
let endIdx = -1;
|
|
24389
|
+
for (let i = 0; i < bounded.length; i++) {
|
|
24390
|
+
const c = bounded[i];
|
|
24391
|
+
if (esc) {
|
|
24392
|
+
esc = false;
|
|
24360
24393
|
continue;
|
|
24361
24394
|
}
|
|
24362
|
-
if (
|
|
24363
|
-
|
|
24364
|
-
escapeNext = true;
|
|
24395
|
+
if (c === '\\' && inStr) {
|
|
24396
|
+
esc = true;
|
|
24365
24397
|
continue;
|
|
24366
24398
|
}
|
|
24367
|
-
if (
|
|
24368
|
-
|
|
24399
|
+
if (c === '"') {
|
|
24400
|
+
inStr = !inStr;
|
|
24401
|
+
continue;
|
|
24369
24402
|
}
|
|
24370
|
-
|
|
24371
|
-
|
|
24372
|
-
|
|
24373
|
-
|
|
24374
|
-
|
|
24375
|
-
|
|
24376
|
-
braceCount--;
|
|
24377
|
-
if (braceCount === 0) {
|
|
24378
|
-
break;
|
|
24379
|
-
}
|
|
24403
|
+
if (!inStr) {
|
|
24404
|
+
if (c === '{')
|
|
24405
|
+
depth++;
|
|
24406
|
+
else if (c === '}' && --depth === 0) {
|
|
24407
|
+
endIdx = i;
|
|
24408
|
+
break;
|
|
24380
24409
|
}
|
|
24381
24410
|
}
|
|
24382
24411
|
}
|
|
24383
|
-
if (
|
|
24412
|
+
if (endIdx === -1) {
|
|
24384
24413
|
throw new Error('Malformed JSON: unmatched braces');
|
|
24385
24414
|
}
|
|
24386
|
-
|
|
24387
|
-
|
|
24415
|
+
try {
|
|
24416
|
+
return JSON.parse(bounded.slice(0, endIdx + 1));
|
|
24417
|
+
}
|
|
24418
|
+
catch {
|
|
24419
|
+
throw new Error('Malformed JSON: invalid structure in test results map');
|
|
24420
|
+
}
|
|
24388
24421
|
}
|
|
24389
24422
|
|
|
24390
24423
|
function fixEyesUrl(url) {
|
|
@@ -24619,6 +24652,14 @@ IMPORTANT:
|
|
|
24619
24652
|
- \`reportPath: "<workspaceRoot>/eyes-examples/eyes-playwright-report/index.html"\`
|
|
24620
24653
|
- \`workspaceRoot: "<workspaceRoot>"\`
|
|
24621
24654
|
|
|
24655
|
+
**CRITICAL: Do NOT run Playwright with \`--reporter=list\`, \`--reporter=dot\`, \`--reporter=line\`, or any other \`--reporter\` flag that overrides the configured reporters. Doing so suppresses the Eyes reporter, preventing it from writing results to the HTML report. This tool will then read a stale report from a previous run and return outdated results.**
|
|
24656
|
+
|
|
24657
|
+
Always run Playwright without reporter overrides, for example:
|
|
24658
|
+
- ✅ CORRECT: \`npx playwright test\`
|
|
24659
|
+
- ❌ INCORRECT: \`npx playwright test --reporter=list\`
|
|
24660
|
+
|
|
24661
|
+
**Stale report detection (optional):** If you know the batch IDs from the current Playwright run output, pass them via the \`expectedBatchIds\` parameter. This tool will warn you if those batch IDs are not found in the report, indicating the report may be from a previous run.
|
|
24662
|
+
|
|
24622
24663
|
The tool returns structured test results that can be displayed in a table, including:
|
|
24623
24664
|
- Test name
|
|
24624
24665
|
- Visual test status (passed/failed/unresolved/new/aborted)
|
|
@@ -24631,6 +24672,9 @@ const PlaywrightFetchVisualResultsInputSchema = commonInputSchema.extend({
|
|
|
24631
24672
|
.optional()
|
|
24632
24673
|
.describe('Path to the Playwright HTML report (optional, defaults to playwright-report/index.html)'),
|
|
24633
24674
|
serverUrl: string().optional().describe('Optional Applitools server URL (defaults to https://eyes.applitools.com)'),
|
|
24675
|
+
expectedBatchIds: array(string())
|
|
24676
|
+
.optional()
|
|
24677
|
+
.describe('Optional list of batch IDs extracted from the Playwright run output. When provided, the tool verifies these IDs appear in the report to confirm it is current and not stale from a previous run.'),
|
|
24634
24678
|
});
|
|
24635
24679
|
const PlaywrightFetchVisualResultsClientInputSchema = createClientInputSchema(PlaywrightFetchVisualResultsInputSchema);
|
|
24636
24680
|
const VisualTestResultSchema = object({
|
|
@@ -24667,6 +24711,15 @@ const FetchVisualResultsToolResultSchema = object({
|
|
|
24667
24711
|
.optional()
|
|
24668
24712
|
.describe('Aggregated statistics summarizing test results across all batches. Counts tests by their visual comparison status.'),
|
|
24669
24713
|
});
|
|
24714
|
+
function buildStaleReportWarning(expectedBatchIds, processedBatches) {
|
|
24715
|
+
const reportBatchIds = new Set(processedBatches.map(b => b.batchId));
|
|
24716
|
+
const missingBatchIds = expectedBatchIds.filter(id => !reportBatchIds.has(id));
|
|
24717
|
+
if (missingBatchIds.length === 0)
|
|
24718
|
+
return '';
|
|
24719
|
+
return (`⚠️ STALE REPORT WARNING: The following batch IDs from the Playwright run were NOT found in the report: [${missingBatchIds.join(', ')}]. ` +
|
|
24720
|
+
`The report likely reflects a previous run, not the current one.\n` +
|
|
24721
|
+
`To fix this: re-run Playwright WITHOUT any --reporter flag overrides (e.g. npx playwright test), then call this tool again.\n\n`);
|
|
24722
|
+
}
|
|
24670
24723
|
/**
|
|
24671
24724
|
* Main tool function to fetch visual test results
|
|
24672
24725
|
*/
|
|
@@ -24708,6 +24761,12 @@ async function playwrightFetchVisualResults(input) {
|
|
|
24708
24761
|
const result = buildToolResult(processedBatches);
|
|
24709
24762
|
if (warning)
|
|
24710
24763
|
result.message = warning + result.message;
|
|
24764
|
+
// Step 5: Optionally verify expected batch IDs to detect stale reports
|
|
24765
|
+
if (input.expectedBatchIds && input.expectedBatchIds.length > 0) {
|
|
24766
|
+
const staleWarning = buildStaleReportWarning(input.expectedBatchIds, processedBatches);
|
|
24767
|
+
if (staleWarning)
|
|
24768
|
+
result.message = staleWarning + result.message;
|
|
24769
|
+
}
|
|
24711
24770
|
return FetchVisualResultsToolResultSchema.parse(result);
|
|
24712
24771
|
}
|
|
24713
24772
|
catch (error) {
|
|
@@ -24811,7 +24870,9 @@ async function startServer() {
|
|
|
24811
24870
|
client_name: (clientInfo === null || clientInfo === void 0 ? void 0 : clientInfo.name) || 'unknown',
|
|
24812
24871
|
client_version: (clientInfo === null || clientInfo === void 0 ? void 0 : clientInfo.version) || 'unknown',
|
|
24813
24872
|
transport_mode: TRANSPORT_MODE,
|
|
24814
|
-
}).catch(
|
|
24873
|
+
}).catch(error => {
|
|
24874
|
+
throw error;
|
|
24875
|
+
});
|
|
24815
24876
|
};
|
|
24816
24877
|
Object.entries(ALL_TOOLS).forEach(([_key, tool]) => {
|
|
24817
24878
|
server.registerTool(tool.name, {
|
|
@@ -24845,18 +24906,40 @@ async function startServer() {
|
|
|
24845
24906
|
log('info', `[MCP Server] Available tools: ${Object.values(TOOL_NAMES).join(', ')}`);
|
|
24846
24907
|
log('info', `[MCP Server] Available resources: documentation (${RESOURCE_URIS.DOCUMENTATION_README})`);
|
|
24847
24908
|
}
|
|
24848
|
-
process.on('SIGINT',
|
|
24909
|
+
process.on('SIGINT', () => {
|
|
24849
24910
|
log('info', '[MCP Server] Received SIGINT, shutting down gracefully...');
|
|
24850
24911
|
process.exit(0);
|
|
24851
24912
|
});
|
|
24852
|
-
process.on('SIGTERM',
|
|
24913
|
+
process.on('SIGTERM', () => {
|
|
24853
24914
|
log('info', '[MCP Server] Received SIGTERM, shutting down gracefully...');
|
|
24854
24915
|
process.exit(0);
|
|
24855
24916
|
});
|
|
24856
|
-
|
|
24857
|
-
|
|
24858
|
-
|
|
24917
|
+
const REJECTION_LOG_THROTTLE_MS = 1000;
|
|
24918
|
+
/** Exported for unit testing — allows injecting a spy in place of the real log function. */
|
|
24919
|
+
function makeThrottledRejectionHandler(logFn, throttleMs = REJECTION_LOG_THROTTLE_MS) {
|
|
24920
|
+
let lastLogTime = 0;
|
|
24921
|
+
let suppressedCount = 0;
|
|
24922
|
+
return (reason) => {
|
|
24923
|
+
const now = Date.now();
|
|
24924
|
+
if (now - lastLogTime >= throttleMs) {
|
|
24925
|
+
if (suppressedCount > 0) {
|
|
24926
|
+
logFn(`[MCP Server] ${suppressedCount} unhandled rejections suppressed`);
|
|
24927
|
+
suppressedCount = 0;
|
|
24928
|
+
}
|
|
24929
|
+
logFn('[MCP Server] Unhandled rejection:', reason);
|
|
24930
|
+
lastLogTime = now;
|
|
24931
|
+
}
|
|
24932
|
+
else {
|
|
24933
|
+
suppressedCount++;
|
|
24934
|
+
}
|
|
24935
|
+
};
|
|
24936
|
+
}
|
|
24937
|
+
process.on('unhandledRejection', makeThrottledRejectionHandler((...args) => log('error', ...args)));
|
|
24859
24938
|
process.on('uncaughtException', error => {
|
|
24939
|
+
if (error.code === 'EPIPE') {
|
|
24940
|
+
process.stderr.write('[MCP Server] Client disconnected (EPIPE), shutting down gracefully...\n');
|
|
24941
|
+
process.exit(0);
|
|
24942
|
+
}
|
|
24860
24943
|
log('error', '[MCP Server] Uncaught Exception:', error);
|
|
24861
24944
|
});
|
|
24862
24945
|
|