@gleanwork/mcp-server-tester 1.0.0-beta.0 → 1.0.0-beta.2

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/cli/index.js CHANGED
@@ -80,7 +80,7 @@ function JsonPreview({ data, maxLines = 15 }) {
80
80
 
81
81
  // package.json
82
82
  var package_default = {
83
- version: "1.0.0-beta.0"};
83
+ version: "1.0.0-beta.2"};
84
84
 
85
85
  // src/cli/templates/index.ts
86
86
  function getPlaywrightConfigTemplate(answers) {
@@ -564,6 +564,7 @@ var StdioConfigSchema = z.object({
564
564
  command: z.string().min(1, "command is required for stdio transport"),
565
565
  args: z.array(z.string()).optional(),
566
566
  cwd: z.string().optional(),
567
+ env: z.record(z.string(), z.string()).optional(),
567
568
  capabilities: MCPHostCapabilitiesSchema.optional(),
568
569
  connectTimeoutMs: z.number().positive().optional(),
569
570
  requestTimeoutMs: z.number().positive().optional(),
@@ -857,7 +858,14 @@ async function createMCPClientForConfig(config, options) {
857
858
  args: validatedConfig.args ?? [],
858
859
  ...validatedConfig.cwd && { cwd: validatedConfig.cwd },
859
860
  // Suppress server stderr when quiet mode is enabled
860
- ...validatedConfig.quiet && { stderr: "ignore" }
861
+ ...validatedConfig.quiet && { stderr: "ignore" },
862
+ ...validatedConfig.env && {
863
+ env: Object.fromEntries(
864
+ Object.entries({ ...process.env, ...validatedConfig.env }).filter(
865
+ (entry) => entry[1] !== void 0
866
+ )
867
+ )
868
+ }
861
869
  });
862
870
  debugClient("Connecting via stdio: %O", {
863
871
  command: validatedConfig.command,
@@ -996,7 +1004,10 @@ async function closeMCPClient(client) {
996
1004
  try {
997
1005
  await client.close();
998
1006
  } catch (error) {
999
- console.error("[MCP] Error closing client:", error);
1007
+ debugClient(
1008
+ "Error closing client: %s",
1009
+ error instanceof Error ? error.message : String(error)
1010
+ );
1000
1011
  throw error;
1001
1012
  } finally {
1002
1013
  const agent = agentRegistry.get(client);
@@ -206,7 +206,7 @@ type RubricSpec = BuiltInRubric | {
206
206
  };
207
207
 
208
208
  /** Valid LLM judge provider kinds. */
209
- type ProviderKind = 'claude' | 'anthropic' | 'openai' | 'google';
209
+ type ProviderKind = 'anthropic' | 'openai' | 'google';
210
210
 
211
211
  /**
212
212
  * Tool call validators for llm_host simulation results.
@@ -464,7 +464,18 @@ function applySanitizers(value, sanitizers) {
464
464
  continue;
465
465
  }
466
466
  if (isRegexSanitizer(sanitizer)) {
467
- const pattern = sanitizer.pattern instanceof RegExp ? sanitizer.pattern : new RegExp(sanitizer.pattern, "g");
467
+ let pattern;
468
+ if (sanitizer.pattern instanceof RegExp) {
469
+ pattern = sanitizer.pattern;
470
+ } else {
471
+ try {
472
+ pattern = new RegExp(sanitizer.pattern, "g");
473
+ } catch {
474
+ throw new Error(
475
+ `toMatchToolSnapshot: invalid regex pattern "${sanitizer.pattern}" in sanitizer`
476
+ );
477
+ }
478
+ }
468
479
  const replacement = sanitizer.replacement ?? "[SANITIZED]";
469
480
  result = result.replace(pattern, replacement);
470
481
  continue;
@@ -950,9 +961,8 @@ Validation errors: ${JSON.stringify(validation.error.issues)}`
950
961
 
951
962
  // src/judge/judgeClient.ts
952
963
  function createJudge(config = {}) {
953
- const provider = config.provider ?? "claude";
964
+ const provider = config.provider ?? "anthropic";
954
965
  switch (provider) {
955
- case "claude":
956
966
  case "anthropic":
957
967
  return createClaudeAgentJudge(config);
958
968
  case "openai":
@@ -1215,7 +1225,7 @@ function validateToolCalls(response, expectation) {
1215
1225
  ).length;
1216
1226
  const recall = requiredCalls.length > 0 ? calledRequiredCount / requiredCalls.length : 1;
1217
1227
  const allowedNames = new Set(expectation.calls.map((c) => c.name));
1218
- const precision = actual.length > 0 && expectation.exclusive === true ? actual.filter((c) => allowedNames.has(c.name)).length / actual.length : 1;
1228
+ const precision = actual.length > 0 ? actual.filter((c) => allowedNames.has(c.name)).length / actual.length : 1;
1219
1229
  const metrics = { precision, recall };
1220
1230
  const order = expectation.order ?? "any";
1221
1231
  if (order === "strict") {
@@ -1360,6 +1370,7 @@ var StdioConfigSchema = z.object({
1360
1370
  command: z.string().min(1, "command is required for stdio transport"),
1361
1371
  args: z.array(z.string()).optional(),
1362
1372
  cwd: z.string().optional(),
1373
+ env: z.record(z.string(), z.string()).optional(),
1363
1374
  capabilities: MCPHostCapabilitiesSchema.optional(),
1364
1375
  connectTimeoutMs: z.number().positive().optional(),
1365
1376
  requestTimeoutMs: z.number().positive().optional(),
@@ -1423,7 +1434,7 @@ var debugHttp = createDebug(`${NAMESPACE}:http`);
1423
1434
 
1424
1435
  // package.json
1425
1436
  var package_default = {
1426
- version: "1.0.0-beta.0"};
1437
+ version: "1.0.0-beta.2"};
1427
1438
  var debug = createDebug("mcp-server-tester:oauth-flow");
1428
1439
  async function generatePKCE() {
1429
1440
  const codeVerifier = oauth.generateRandomCodeVerifier();
@@ -1657,7 +1668,14 @@ async function createMCPClientForConfig(config, options) {
1657
1668
  args: validatedConfig.args ?? [],
1658
1669
  ...validatedConfig.cwd && { cwd: validatedConfig.cwd },
1659
1670
  // Suppress server stderr when quiet mode is enabled
1660
- ...validatedConfig.quiet && { stderr: "ignore" }
1671
+ ...validatedConfig.quiet && { stderr: "ignore" },
1672
+ ...validatedConfig.env && {
1673
+ env: Object.fromEntries(
1674
+ Object.entries({ ...process.env, ...validatedConfig.env }).filter(
1675
+ (entry) => entry[1] !== void 0
1676
+ )
1677
+ )
1678
+ }
1661
1679
  });
1662
1680
  debugClient("Connecting via stdio: %O", {
1663
1681
  command: validatedConfig.command,
@@ -1796,7 +1814,10 @@ async function closeMCPClient(client) {
1796
1814
  try {
1797
1815
  await client.close();
1798
1816
  } catch (error) {
1799
- console.error("[MCP] Error closing client:", error);
1817
+ debugClient(
1818
+ "Error closing client: %s",
1819
+ error instanceof Error ? error.message : String(error)
1820
+ );
1800
1821
  throw error;
1801
1822
  } finally {
1802
1823
  const agent = agentRegistry.get(client);