@applitools/mcp 0.10.5 → 0.10.6

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 CHANGED
@@ -5,6 +5,25 @@ 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.10.6](https://github.com/Applitools-Dev/sdk/compare/js/mcp@0.10.5...js/mcp@0.10.6) (2026-11-18)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * report key sources in tool telemetry | AD-17993 ([#4468](https://github.com/Applitools-Dev/sdk/issues/4468)) ([80a46b7](https://github.com/Applitools-Dev/sdk/commit/80a46b761b7fa42a1f29d84dd5229a5f62afe9df))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * @applitools/eyes-results bumped to 0.2.11
19
+
20
+ * @applitools/req bumped to 1.11.9
21
+
22
+ * @applitools/core-base bumped to 1.44.1
23
+
24
+ * @applitools/test-server bumped to 1.4.11
25
+
26
+
8
27
  ## [0.10.5](https://github.com/Applitools-Dev/sdk/compare/js/mcp@0.10.4...js/mcp@0.10.5) (2026-11-16)
9
28
 
10
29
 
package/dist/index.js CHANGED
@@ -3924,7 +3924,7 @@ function loadEnvFile(workingDirectory) {
3924
3924
  }
3925
3925
  }
3926
3926
  if (apiKey) {
3927
- return { apiKey, serverUrl, foundIn: '.env' };
3927
+ return { apiKey, serverUrl, foundIn: '.env', keyFrom: 'env_file' };
3928
3928
  }
3929
3929
  }
3930
3930
  catch {
@@ -3970,6 +3970,7 @@ function loadConfigFile(configPath, fileName, workingDirectory) {
3970
3970
  // Search for apiKey and serverUrl in the file content
3971
3971
  let apiKey;
3972
3972
  let serverUrl;
3973
+ let keyFrom = 'config';
3973
3974
  // Pattern 1: apiKey: 'value' or apiKey: "value" (hardcoded values)
3974
3975
  const apiKeyMatch = content.match(/apiKey\s*:\s*['"]([^'"]+)['"]/i);
3975
3976
  if (apiKeyMatch) {
@@ -3983,12 +3984,14 @@ function loadConfigFile(configPath, fileName, workingDirectory) {
3983
3984
  // Pattern 3: Resolve environment variable references in config file
3984
3985
  if (!apiKey) {
3985
3986
  apiKey = resolveEnvVarFromContent(content, 'APPLITOOLS_API_KEY', workingDirectory);
3987
+ // The same check resolveEnvVarFromContent makes before falling back to this directory's .env.
3988
+ keyFrom = process.env.APPLITOOLS_API_KEY ? 'environment' : 'env_file';
3986
3989
  }
3987
3990
  if (!serverUrl) {
3988
3991
  serverUrl = resolveEnvVarFromContent(content, 'APPLITOOLS_SERVER_URL', workingDirectory);
3989
3992
  }
3990
3993
  if (apiKey) {
3991
- return { apiKey, serverUrl, foundIn: fileName };
3994
+ return { apiKey, serverUrl, foundIn: fileName, keyFrom };
3992
3995
  }
3993
3996
  }
3994
3997
  catch {
@@ -4030,12 +4033,22 @@ function findApiKey(workingDirectory = process.cwd()) {
4030
4033
  apiKey: envApiKey,
4031
4034
  serverUrl: envServerUrl,
4032
4035
  foundIn: 'environment variable',
4036
+ keyFrom: 'environment',
4033
4037
  };
4034
4038
  }
4035
4039
  // Not found
4036
4040
  return {};
4037
4041
  }
4038
4042
 
4043
+ // Saved the first time a .env overrides a workspace name, so the launch value comes back once no
4044
+ // chosen .env defines it. Kept here so credential loading can read it without importing env-loader.
4045
+ const workspaceLaunchValues = new Map();
4046
+ /** Whether a workspace name's current value is the chosen `.env`'s override, the launch value, or absent. */
4047
+ function workspaceValueSource(name) {
4048
+ if (!process.env[name])
4049
+ return 'unset';
4050
+ return workspaceLaunchValues.has(name) ? 'env_file' : 'process_env';
4051
+ }
4039
4052
  let currentClientInfo = undefined;
4040
4053
  let currentCredentials = undefined;
4041
4054
  let ide = undefined;
@@ -4075,6 +4088,7 @@ function loadCredentials(workingDirectory) {
4075
4088
  apiKey: storedCredentials.apiKey,
4076
4089
  serverUrl: storedCredentials.serverUrl,
4077
4090
  source: 'server-context',
4091
+ keySource: storedCredentials.keySource,
4078
4092
  };
4079
4093
  }
4080
4094
  const workingDir = workingDirectory || process.cwd();
@@ -4082,7 +4096,14 @@ function loadCredentials(workingDirectory) {
4082
4096
  const apiKey = configResult.apiKey;
4083
4097
  const serverUrl = configResult.serverUrl || process.env.APPLITOOLS_SERVER_URL || DEFAULT_SERVER_URL;
4084
4098
  const source = configResult.foundIn;
4085
- return { apiKey, serverUrl, source };
4099
+ return { apiKey, serverUrl, source, keySource: apiKey ? keySourceOf(configResult) : undefined };
4100
+ }
4101
+ function keySourceOf({ keyFrom, foundIn }) {
4102
+ if (keyFrom === 'environment')
4103
+ return workspaceValueSource('APPLITOOLS_API_KEY');
4104
+ if (keyFrom === 'env_file')
4105
+ return 'env_file';
4106
+ return (foundIn === null || foundIn === void 0 ? void 0 : foundIn.startsWith('playwright.config')) ? 'playwright_config' : 'applitools_config';
4086
4107
  }
4087
4108
  /** Load and store credentials in server context */
4088
4109
  function loadAndStoreCredentials(workingDirectory) {
@@ -4091,6 +4112,7 @@ function loadAndStoreCredentials(workingDirectory) {
4091
4112
  setCredentials({
4092
4113
  apiKey: result.apiKey,
4093
4114
  serverUrl: result.serverUrl,
4115
+ keySource: result.keySource,
4094
4116
  });
4095
4117
  return true;
4096
4118
  }
@@ -4242,23 +4264,21 @@ const loadEnvOnce = utils__namespace.general.cachify((startDir, source) => {
4242
4264
  }
4243
4265
  return loaded;
4244
4266
  }, ([startDir]) => startDir, 30000);
4245
- // Saved the first time a .env overrides a name, so the launch value comes back once no chosen .env defines it.
4246
- const launchValues = new Map();
4247
4267
  function syncWorkspaceKeys(workspaceRoot, source) {
4248
4268
  const loaded = loadEnvOnce(workspaceRoot, source);
4249
4269
  for (const name of WORKSPACE_ENV_NAMES) {
4250
4270
  const value = loaded === null || loaded === void 0 ? void 0 : loaded.parsed[name];
4251
4271
  if (loaded && value) {
4252
- if (!launchValues.has(name))
4253
- launchValues.set(name, process.env[name]);
4272
+ if (!workspaceLaunchValues.has(name))
4273
+ workspaceLaunchValues.set(name, process.env[name]);
4254
4274
  if (process.env[name] === value)
4255
4275
  continue;
4256
4276
  process.env[name] = value;
4257
4277
  log$1('info', `[MCP Server] ${name} set from ${loaded.path} (triggered by ${source})`);
4258
4278
  }
4259
- else if (launchValues.has(name)) {
4260
- const launchValue = launchValues.get(name);
4261
- launchValues.delete(name);
4279
+ else if (workspaceLaunchValues.has(name)) {
4280
+ const launchValue = workspaceLaunchValues.get(name);
4281
+ workspaceLaunchValues.delete(name);
4262
4282
  if (launchValue === undefined)
4263
4283
  delete process.env[name];
4264
4284
  else
@@ -4589,11 +4609,20 @@ function countGateRejection() {
4589
4609
  function gateRejectionCount() {
4590
4610
  return gateRejections;
4591
4611
  }
4612
+ /** Where each key setting in use came from, as fixed enum values only — never a path, file name or key. */
4613
+ function keySources() {
4614
+ var _a;
4615
+ return {
4616
+ api_key_source: (_a = loadCredentials().keySource) !== null && _a !== void 0 ? _a : 'unset',
4617
+ read_key_source: workspaceValueSource('APPLITOOLS_READ_KEY'),
4618
+ write_key_source: workspaceValueSource('APPLITOOLS_WRITE_KEY'),
4619
+ };
4620
+ }
4592
4621
 
4593
4622
  var name = "@applitools/mcp";
4594
4623
  var mcpName = "io.github.applitools/applitools";
4595
- var mcpRegistryVersion = "1.0.17";
4596
- var version = "0.10.5";
4624
+ var mcpRegistryVersion = "1.0.18";
4625
+ var version = "0.10.6";
4597
4626
  var description = "Applitools MCP server for AI coding assistants";
4598
4627
  var main = "./dist/index.js";
4599
4628
  var bin = "./dist/index.js";
@@ -4842,6 +4871,8 @@ const createToolHandler = (toolDef, logic) => {
4842
4871
  const safeParams = params !== null && params !== void 0 ? params : {};
4843
4872
  const workspaceRoot = safeParams.workspaceRoot || getWorkspaceRoot() || process.cwd();
4844
4873
  syncWorkspaceKeys(workspaceRoot, toolDef.name);
4874
+ // Read before any await, while the process-wide key slot still holds this call's keys.
4875
+ const sources = keySources();
4845
4876
  const { selected: frameworkSelected, detected: detectedFrameworks } = getAutomationFramework(workspaceRoot, safeParams.activeFile);
4846
4877
  const { name: automationFramework, version: automationFrameworkVersion } = frameworkSelected;
4847
4878
  const { selected: sdkLanguage, detected: detectedLanguages } = getSdkLanguage(workspaceRoot);
@@ -4853,7 +4884,7 @@ const createToolHandler = (toolDef, logic) => {
4853
4884
  sdkLanguage,
4854
4885
  };
4855
4886
  const { batchId, sessionId } = extractScopeIds(safeParams);
4856
- const telemetry = {};
4887
+ const telemetry = { ...sources };
4857
4888
  const callInputs = reportedInputs(safeParams);
4858
4889
  const outcomeJsonParams = () => jsonParams({ ...telemetry, gate_rejections: gateRejectionCount() }, callInputs);
4859
4890
  externalLog('mcp_tool_invoked', {
@@ -4867,7 +4898,7 @@ const createToolHandler = (toolDef, logic) => {
4867
4898
  session_id: sessionId,
4868
4899
  // The backend attributes every event to the authenticating key's account, so no key goes out here.
4869
4900
  params: JSON.stringify({ ...params, apiKey: undefined }, null, 2).slice(0, 1024),
4870
- json_params: jsonParams({}, callInputs),
4901
+ json_params: jsonParams(sources, callInputs),
4871
4902
  automation_framework: automationFramework,
4872
4903
  automation_framework_version: automationFrameworkVersion,
4873
4904
  sdk_language: sdkLanguage,
@@ -5189,9 +5220,12 @@ const VerifyApiKeyInputSchema = zod.z.object({
5189
5220
  .describe('If true, save the validated API key and server URL as the default configuration in cache'),
5190
5221
  });
5191
5222
  // A key that fails validation is the one telemetry case where a key is reported, masked so that
5192
- // a short value is never shown.
5193
- function reportUnvalidatedKey(apiKey) {
5194
- recordToolTelemetry({ api_key_masked: apiKey.length <= 7 ? '***' : `${apiKey.slice(0, 3)}***${apiKey.slice(-3)}` });
5223
+ // a short value is never shown; its source replaces the pinned key's so both fields describe it.
5224
+ function reportUnvalidatedKey(apiKey, keySource) {
5225
+ recordToolTelemetry({
5226
+ api_key_source: keySource,
5227
+ api_key_masked: apiKey.length <= 7 ? '***' : `${apiKey.slice(0, 3)}***${apiKey.slice(-3)}`,
5228
+ });
5195
5229
  }
5196
5230
  /** Verify API key handler function */
5197
5231
  async function verifyApiKey(input = {}) {
@@ -5203,12 +5237,14 @@ async function verifyApiKey(input = {}) {
5203
5237
  let apiKey = input.apiKey;
5204
5238
  let serverUrl = input.serverUrl;
5205
5239
  let foundIn;
5240
+ let keySource = input.apiKey ? 'tool_argument' : undefined;
5206
5241
  // Load credentials if not provided as input
5207
5242
  if (!apiKey || !serverUrl) {
5208
5243
  const credentialResult = loadCredentials(workingDirectory);
5209
5244
  apiKey = apiKey || credentialResult.apiKey;
5210
5245
  serverUrl = serverUrl || credentialResult.serverUrl; // loadCredentials always provides serverUrl (with default)
5211
5246
  foundIn = credentialResult.source;
5247
+ keySource !== null && keySource !== void 0 ? keySource : (keySource = credentialResult.keySource);
5212
5248
  }
5213
5249
  // Validate API key presence
5214
5250
  if (!apiKey || apiKey.trim() === '') {
@@ -5223,7 +5259,7 @@ async function verifyApiKey(input = {}) {
5223
5259
  new URL(finalServerUrl);
5224
5260
  }
5225
5261
  catch {
5226
- reportUnvalidatedKey(apiKey);
5262
+ reportUnvalidatedKey(apiKey, keySource);
5227
5263
  return {
5228
5264
  message: wrapText('Eyes authentication failed. Invalid server URL format. Please verify that your server URL is correct.', 'suffix'),
5229
5265
  };
@@ -5232,7 +5268,7 @@ async function verifyApiKey(input = {}) {
5232
5268
  assertTrustedEyesUrl(finalServerUrl);
5233
5269
  }
5234
5270
  catch (error) {
5235
- reportUnvalidatedKey(apiKey);
5271
+ reportUnvalidatedKey(apiKey, keySource);
5236
5272
  return {
5237
5273
  message: wrapText(`Eyes authentication failed: ${error.message}. ` +
5238
5274
  'Correct the server URL where it is set: the serverUrl argument, APPLITOOLS_SERVER_URL or the project config file.', 'suffix'),
@@ -5244,7 +5280,9 @@ async function verifyApiKey(input = {}) {
5244
5280
  // Mark as validated in session memory
5245
5281
  markApiKeyAsValidated(apiKey, finalServerUrl);
5246
5282
  // Store credentials in server context for external logging
5247
- setCredentials({ apiKey, serverUrl: finalServerUrl });
5283
+ setCredentials({ apiKey, serverUrl: finalServerUrl, keySource });
5284
+ // This call's events were seeded before the key was pinned; report the pinned key's source instead.
5285
+ recordToolTelemetry({ api_key_source: keySource });
5248
5286
  const successMessage = foundIn
5249
5287
  ? `Eyes authentication successful! API key found in ${foundIn}`
5250
5288
  : 'Eyes authentication successful!';
@@ -5254,7 +5292,7 @@ async function verifyApiKey(input = {}) {
5254
5292
  }
5255
5293
  catch {
5256
5294
  // Return invalid for any error (401, network, etc.)
5257
- reportUnvalidatedKey(apiKey);
5295
+ reportUnvalidatedKey(apiKey, keySource);
5258
5296
  return {
5259
5297
  message: wrapText('Eyes authentication failed. Please verify that your API Key or server URL is correct. Visit our documentation to learn how to retrieve these values: https://applitools.com/docs/eyes/playwright#set-your-applitools-api-key', 'suffix'),
5260
5298
  };