@gleanwork/mcp-server-tester 1.0.0-beta.0 → 1.0.0-beta.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
@@ -1809,11 +1809,11 @@ function parseNullableDef(def, refs) {
1809
1809
  ]
1810
1810
  };
1811
1811
  }
1812
- const base2 = parseDef(def.innerType._def, {
1812
+ const base3 = parseDef(def.innerType._def, {
1813
1813
  ...refs,
1814
1814
  currentPath: [...refs.currentPath, "anyOf", "0"]
1815
1815
  });
1816
- return base2 && { anyOf: [base2, { type: "null" }] };
1816
+ return base3 && { anyOf: [base3, { type: "null" }] };
1817
1817
  }
1818
1818
  function parseNumberDef(def) {
1819
1819
  const res = {
@@ -3133,6 +3133,7 @@ var StdioConfigSchema = z.object({
3133
3133
  command: z.string().min(1, "command is required for stdio transport"),
3134
3134
  args: z.array(z.string()).optional(),
3135
3135
  cwd: z.string().optional(),
3136
+ env: z.record(z.string(), z.string()).optional(),
3136
3137
  capabilities: MCPHostCapabilitiesSchema.optional(),
3137
3138
  connectTimeoutMs: z.number().positive().optional(),
3138
3139
  requestTimeoutMs: z.number().positive().optional(),
@@ -4379,7 +4380,7 @@ function escapeHtml(text) {
4379
4380
 
4380
4381
  // package.json
4381
4382
  var package_default = {
4382
- version: "1.0.0-beta.0"};
4383
+ version: "1.0.0-beta.1"};
4383
4384
 
4384
4385
  // src/mcp/clientFactory.ts
4385
4386
  function getRetryAfterDelayMs(err) {
@@ -4451,7 +4452,14 @@ async function createMCPClientForConfig(config, options) {
4451
4452
  args: validatedConfig.args ?? [],
4452
4453
  ...validatedConfig.cwd && { cwd: validatedConfig.cwd },
4453
4454
  // Suppress server stderr when quiet mode is enabled
4454
- ...validatedConfig.quiet && { stderr: "ignore" }
4455
+ ...validatedConfig.quiet && { stderr: "ignore" },
4456
+ ...validatedConfig.env && {
4457
+ env: Object.fromEntries(
4458
+ Object.entries({ ...process.env, ...validatedConfig.env }).filter(
4459
+ (entry) => entry[1] !== void 0
4460
+ )
4461
+ )
4462
+ }
4455
4463
  });
4456
4464
  debugClient("Connecting via stdio: %O", {
4457
4465
  command: validatedConfig.command,
@@ -4590,7 +4598,10 @@ async function closeMCPClient(client) {
4590
4598
  try {
4591
4599
  await client.close();
4592
4600
  } catch (error) {
4593
- console.error("[MCP] Error closing client:", error);
4601
+ debugClient(
4602
+ "Error closing client: %s",
4603
+ error instanceof Error ? error.message : String(error)
4604
+ );
4594
4605
  throw error;
4595
4606
  } finally {
4596
4607
  const agent = agentRegistry.get(client);
@@ -5120,7 +5131,7 @@ function validateToolCalls(response, expectation) {
5120
5131
  ).length;
5121
5132
  const recall = requiredCalls.length > 0 ? calledRequiredCount / requiredCalls.length : 1;
5122
5133
  const allowedNames = new Set(expectation.calls.map((c) => c.name));
5123
- const precision = actual.length > 0 && expectation.exclusive === true ? actual.filter((c) => allowedNames.has(c.name)).length / actual.length : 1;
5134
+ const precision = actual.length > 0 ? actual.filter((c) => allowedNames.has(c.name)).length / actual.length : 1;
5124
5135
  const metrics = { precision, recall };
5125
5136
  const order = expectation.order ?? "any";
5126
5137
  if (order === "strict") {
@@ -5523,9 +5534,8 @@ Validation errors: ${JSON.stringify(validation.error.issues)}`
5523
5534
 
5524
5535
  // src/judge/judgeClient.ts
5525
5536
  function createJudge(config = {}) {
5526
- const provider = config.provider ?? "claude";
5537
+ const provider = config.provider ?? "anthropic";
5527
5538
  switch (provider) {
5528
- case "claude":
5529
5539
  case "anthropic":
5530
5540
  return createClaudeAgentJudge(config);
5531
5541
  case "openai":
@@ -6182,6 +6192,106 @@ var test = test$1.extend({
6182
6192
  await use(api);
6183
6193
  }
6184
6194
  });
6195
+
6196
+ // src/fixtures/mcpAuth.ts
6197
+ init_oauthClientProvider();
6198
+ var StaticTokenAuthProvider = class {
6199
+ accessToken;
6200
+ constructor(accessToken) {
6201
+ this.accessToken = accessToken;
6202
+ }
6203
+ get redirectUrl() {
6204
+ throw new Error("StaticTokenAuthProvider does not support OAuth redirects");
6205
+ }
6206
+ get clientMetadata() {
6207
+ return {
6208
+ redirect_uris: [],
6209
+ token_endpoint_auth_method: "none",
6210
+ grant_types: [],
6211
+ response_types: [],
6212
+ client_name: "@gleanwork/mcp-server-tester"
6213
+ };
6214
+ }
6215
+ async clientInformation() {
6216
+ return void 0;
6217
+ }
6218
+ async tokens() {
6219
+ return {
6220
+ access_token: this.accessToken,
6221
+ token_type: "Bearer"
6222
+ };
6223
+ }
6224
+ async saveTokens() {
6225
+ }
6226
+ async redirectToAuthorization() {
6227
+ throw new Error("StaticTokenAuthProvider does not support OAuth redirects");
6228
+ }
6229
+ async saveCodeVerifier() {
6230
+ throw new Error("StaticTokenAuthProvider does not support PKCE");
6231
+ }
6232
+ async codeVerifier() {
6233
+ throw new Error("StaticTokenAuthProvider does not support PKCE");
6234
+ }
6235
+ };
6236
+ var test2 = test$1.extend({
6237
+ /**
6238
+ * Create auth provider based on environment configuration
6239
+ */
6240
+ // eslint-disable-next-line no-empty-pattern
6241
+ mcpAuthProvider: async ({}, use) => {
6242
+ const authConfig = getAuthConfigFromEnv();
6243
+ if (!authConfig) {
6244
+ await use(void 0);
6245
+ return;
6246
+ }
6247
+ if (authConfig.accessToken) {
6248
+ const provider = new StaticTokenAuthProvider(authConfig.accessToken);
6249
+ await use(provider);
6250
+ return;
6251
+ }
6252
+ if (authConfig.oauth) {
6253
+ const provider = createOAuthProvider(authConfig.oauth);
6254
+ await use(provider);
6255
+ return;
6256
+ }
6257
+ await use(void 0);
6258
+ }
6259
+ });
6260
+ function createOAuthProvider(oauthConfig) {
6261
+ if (!oauthConfig.authStatePath) {
6262
+ throw new Error(
6263
+ "OAuth configuration requires authStatePath. Use performOAuthSetup() in globalSetup to create auth state first."
6264
+ );
6265
+ }
6266
+ const providerConfig = {
6267
+ storagePath: oauthConfig.authStatePath,
6268
+ redirectUri: oauthConfig.redirectUri ?? "http://localhost:3000/oauth/callback",
6269
+ clientId: oauthConfig.clientId,
6270
+ clientSecret: oauthConfig.clientSecret
6271
+ };
6272
+ return new PlaywrightOAuthClientProvider(providerConfig);
6273
+ }
6274
+ function getAuthConfigFromEnv() {
6275
+ const accessToken = process.env.MCP_ACCESS_TOKEN;
6276
+ if (accessToken) {
6277
+ return { accessToken };
6278
+ }
6279
+ const oauthServerUrl = process.env.MCP_OAUTH_SERVER_URL;
6280
+ const authStatePath = process.env.MCP_AUTH_STATE_PATH;
6281
+ if (oauthServerUrl || authStatePath) {
6282
+ return {
6283
+ oauth: {
6284
+ serverUrl: oauthServerUrl ?? "",
6285
+ authStatePath,
6286
+ clientId: process.env.MCP_OAUTH_CLIENT_ID,
6287
+ clientSecret: process.env.MCP_OAUTH_CLIENT_SECRET,
6288
+ scopes: process.env.MCP_OAUTH_SCOPES?.split(","),
6289
+ resource: process.env.MCP_OAUTH_RESOURCE
6290
+ }
6291
+ };
6292
+ }
6293
+ return void 0;
6294
+ }
6185
6295
  var LLMHostConfigSchema = z.object({
6186
6296
  provider: z.enum([
6187
6297
  "openai",
@@ -6189,7 +6299,6 @@ var LLMHostConfigSchema = z.object({
6189
6299
  "azure",
6190
6300
  "google",
6191
6301
  "mistral",
6192
- "ollama",
6193
6302
  "deepseek",
6194
6303
  "openrouter",
6195
6304
  "xai",
@@ -6236,7 +6345,7 @@ var EvalExpectBlockSchema = z.object({
6236
6345
  reference: z.unknown().optional(),
6237
6346
  threshold: z.number().min(0).max(1).optional(),
6238
6347
  reps: z.number().int().min(1).optional(),
6239
- provider: z.enum(["claude", "anthropic", "openai", "google"]).optional(),
6348
+ provider: z.enum(["anthropic", "openai", "google"]).optional(),
6240
6349
  model: z.string().optional(),
6241
6350
  apiKeyEnvVar: z.string().optional(),
6242
6351
  maxTokens: z.number().int().positive().optional(),
@@ -6378,10 +6487,6 @@ async function loadModel(provider, model) {
6378
6487
  const { azure } = await import('@ai-sdk/azure');
6379
6488
  return azure(model);
6380
6489
  }
6381
- case "ollama": {
6382
- const { ollama } = await import('@ai-sdk/ollama');
6383
- return ollama(model);
6384
- }
6385
6490
  case "deepseek": {
6386
6491
  const { deepseek } = await import('@ai-sdk/deepseek');
6387
6492
  return deepseek(model);
@@ -6488,7 +6593,6 @@ var allProviders = [
6488
6593
  "azure",
6489
6594
  "google",
6490
6595
  "mistral",
6491
- "ollama",
6492
6596
  "deepseek",
6493
6597
  "openrouter",
6494
6598
  "xai",
@@ -6516,7 +6620,6 @@ function getMissingDependencyMessage(provider) {
6516
6620
  google: "npm install ai @ai-sdk/google",
6517
6621
  azure: "npm install ai @ai-sdk/azure",
6518
6622
  mistral: "npm install ai @ai-sdk/mistral",
6519
- ollama: "npm install ai @ai-sdk/ollama",
6520
6623
  deepseek: "npm install ai @ai-sdk/deepseek",
6521
6624
  openrouter: "npm install ai @openrouter/ai-sdk-provider",
6522
6625
  xai: "npm install ai @ai-sdk/xai",
@@ -6763,15 +6866,17 @@ async function runSingleIteration(evalCase, context, options) {
6763
6866
  function isInfrastructureError(err) {
6764
6867
  let name15;
6765
6868
  let msg;
6869
+ let code = "";
6766
6870
  if (err instanceof Error) {
6767
6871
  name15 = err.name;
6768
6872
  msg = err.message.toLowerCase();
6873
+ code = (err.code ?? "").toLowerCase();
6769
6874
  } else if (typeof err === "string") {
6770
6875
  msg = err.toLowerCase();
6771
6876
  } else {
6772
6877
  return false;
6773
6878
  }
6774
- return name15 === "AbortError" || msg.includes("econnreset") || msg.includes("etimedout") || msg.includes("econnrefused") || msg.includes("rate limit") || msg.includes("429") || msg.includes("503") || msg.includes("network");
6879
+ return name15 === "AbortError" || msg.includes("econnreset") || msg.includes("etimedout") || msg.includes("econnrefused") || msg.includes("rate limit") || msg.includes("429") || msg.includes("503") || msg.includes("network") || code.includes("econnreset") || code.includes("etimedout") || code.includes("econnrefused");
6775
6880
  }
6776
6881
  async function runEvalCase(evalCase, context, options = {}) {
6777
6882
  const iterations = evalCase.iterations ?? 1;
@@ -7212,6 +7317,6 @@ function formatCapabilities(capabilities) {
7212
7317
  return parts.length > 0 ? parts.join(", ") : "none declared";
7213
7318
  }
7214
7319
 
7215
- export { BUILT_IN_RUBRICS, CLIOAuthClient, DiscoveryError, ENV_VAR_NAMES, EvalCaseSchema, EvalDatasetSchema, MCPConfigSchema, MCP_PROTOCOL_VERSION, PlaywrightOAuthClientProvider, SnapshotSanitizers, closeMCPClient, createJudge, createMCPClientForConfig, createMCPFixture, createTokenAuthHeaders, discoverAuthorizationServer, discoverProtectedResource, expect, extractText, getMissingDependencyMessage, getResponseSizeBytes, hasValidTokens, injectTokens, isBuiltInRubric, isHttpConfig, isProviderAvailable, isStdioConfig, isTokenExpired, isTokenExpiringSoon, loadBaseline, loadEvalDataset, loadEvalDatasetFromObject, loadTokens, loadTokensFromEnv, normalizeToolResponse, normalizeWhitespace, performClientCredentialsFlow, performOAuthSetup, performOAuthSetupIfNeeded, resolveRubric, runConformanceChecks, runEvalCase, runEvalDataset, runServerComparison, saveBaseline, simulateLLMHost, test, validateAccessToken, validateError, validateEvalCase, validateEvalDataset, validateJudge, validateMCPConfig, validatePattern, validateResponse, validateSchema, validateSize, validateText, validateToolCallCount, validateToolCalls };
7320
+ export { BUILT_IN_RUBRICS, CLIOAuthClient, DiscoveryError, ENV_VAR_NAMES, EvalCaseSchema, EvalDatasetSchema, MCPConfigSchema, MCP_PROTOCOL_VERSION, PlaywrightOAuthClientProvider, SnapshotSanitizers, closeMCPClient, createJudge, createMCPClientForConfig, createMCPFixture, createTokenAuthHeaders, discoverAuthorizationServer, discoverProtectedResource, expect, extractText, getMissingDependencyMessage, getResponseSizeBytes, hasValidTokens, injectTokens, isBuiltInRubric, isHttpConfig, isProviderAvailable, isStdioConfig, isTokenExpired, isTokenExpiringSoon, loadBaseline, loadEvalDataset, loadEvalDatasetFromObject, loadTokens, loadTokensFromEnv, test2 as mcpAuthTest, normalizeToolResponse, normalizeWhitespace, performClientCredentialsFlow, performOAuthSetup, performOAuthSetupIfNeeded, resolveRubric, runConformanceChecks, runEvalCase, runEvalDataset, runServerComparison, saveBaseline, simulateLLMHost, test, validateAccessToken, validateError, validateEvalCase, validateEvalDataset, validateJudge, validateMCPConfig, validatePattern, validateResponse, validateSchema, validateSize, validateText, validateToolCallCount, validateToolCalls };
7216
7321
  //# sourceMappingURL=index.js.map
7217
7322
  //# sourceMappingURL=index.js.map