@smartbear/mcp 0.42.0 → 0.44.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.
Files changed (56) hide show
  1. package/dist/bearq/api.js +16 -0
  2. package/dist/bearq/client.js +9 -1
  3. package/dist/bearq/tool/tasks/stop-task.js +6 -3
  4. package/dist/bearq/tool/workflows/get-workflow-run.js +31 -0
  5. package/dist/bearq/tool/workflows/list-workflows.js +28 -0
  6. package/dist/bearq/tool/workflows/run-workflow.js +57 -0
  7. package/dist/bearq/tool/workflows/stop-workflow-run.js +33 -0
  8. package/dist/bugsnag/client.js +14 -2
  9. package/dist/common/config-names.js +12 -0
  10. package/dist/common/info.js +2 -0
  11. package/dist/common/list-integrations.js +53 -0
  12. package/dist/common/server.js +64 -2
  13. package/dist/common/transport-http.js +100 -33
  14. package/dist/common/transport-stdio.js +1 -6
  15. package/dist/package.json.js +1 -1
  16. package/dist/pactflow/client/admin-api.js +3 -8
  17. package/dist/pactflow/client/ai.js +34 -0
  18. package/dist/pactflow/client/contract-api.js +2 -0
  19. package/dist/pactflow/client/http-client.js +7 -2
  20. package/dist/pactflow/client/pacticipant-api.js +37 -0
  21. package/dist/pactflow/client/schemas/admin.js +799 -0
  22. package/dist/pactflow/client/schemas/common.js +201 -0
  23. package/dist/pactflow/client/schemas/contract.js +444 -0
  24. package/dist/pactflow/client/schemas/environment.js +94 -0
  25. package/dist/pactflow/client/schemas/output.js +55 -0
  26. package/dist/pactflow/client/schemas/pacticipant.js +290 -0
  27. package/dist/pactflow/client/schemas/webhook.js +164 -0
  28. package/dist/pactflow/client/tools.js +32 -1
  29. package/dist/pactflow/client.js +21 -3
  30. package/dist/qmetry/client/ai-agent.js +3 -0
  31. package/dist/qmetry/client/api/error-handler.js +7 -2
  32. package/dist/qmetry/client/auto-resolve.js +5 -0
  33. package/dist/qmetry/client/handlers.js +2 -1
  34. package/dist/qmetry/client/project.js +19 -1
  35. package/dist/qmetry/client/testsuite.js +207 -2
  36. package/dist/qmetry/client/tools/ai-agent-tools.js +13 -0
  37. package/dist/qmetry/client/tools/issue-tools.js +7 -3
  38. package/dist/qmetry/client/tools/project-tools.js +34 -1
  39. package/dist/qmetry/client/tools/testcase-tools.js +43 -296
  40. package/dist/qmetry/client/tools/testsuite-tools.js +49 -19
  41. package/dist/qmetry/client/udf.js +14 -2
  42. package/dist/qmetry/client.js +2 -1
  43. package/dist/qmetry/config/constants.js +1 -0
  44. package/dist/qmetry/config/rest-endpoints.js +2 -1
  45. package/dist/qmetry/types/ai-agent.js +3 -0
  46. package/dist/qmetry/types/common.js +40 -2
  47. package/dist/qmetry/types/udf.js +1 -20
  48. package/dist/swagger/client/portal-types.js +11 -5
  49. package/dist/swagger/client/registry-types.js +5 -4
  50. package/dist/swagger/client/tools.js +1 -1
  51. package/dist/zephyr/tool/test-case/create-web-link.js +17 -2
  52. package/dist/zephyr/tool/test-cycle/create-web-link.js +18 -2
  53. package/package.json +4 -2
  54. package/plugin/README.md +42 -0
  55. package/src/pactflow/drift/README.md +91 -0
  56. package/dist/pactflow/client/base.js +0 -488
@@ -1,5 +1,5 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
- import { randomUUID } from "node:crypto";
2
+ import { randomBytes, randomUUID, createHmac } from "node:crypto";
3
3
  import { createServer } from "node:http";
4
4
  import querystring from "node:querystring";
5
5
  import { toNodeHandler, toWebRequest, NodeStreamableHTTPServerTransport } from "@modelcontextprotocol/node";
@@ -7,12 +7,64 @@ import { createMcpHandler, isLegacyRequest, isInitializeRequest } from "@modelco
7
7
  import { SSEServerTransport } from "@modelcontextprotocol/server-legacy/sse";
8
8
  import { initAnalytics, isToolsListRequest, trackToolsListed, createAnalyticsSession, flushAnalytics } from "./analytics.js";
9
9
  import { clientRegistry } from "./client-registry.js";
10
+ import { getHeaderName, getEnvVarName } from "./config-names.js";
11
+ import { MCP_SERVER_VERSION } from "./info.js";
10
12
  import { extractModernClientMeta, handleInitializeMessage } from "./initialize.js";
11
13
  import { withRequestHeaders, withRequestContext, setRequestMcpClient, setModernRequestClient } from "./request-context.js";
12
14
  import { SmartBearMcpServer } from "./server.js";
13
15
  import { registerShutdownHandler, isDraining } from "./shutdown.js";
14
- import { getEnvVarName } from "./transport-stdio.js";
16
+ import "node:module";
17
+ import "@modelcontextprotocol/server/stdio";
15
18
  import { isOptionalType, getTypeDescription } from "./zod-utils.js";
19
+ const IDENTITY_KEY = randomBytes(32);
20
+ function resolveCredentialIdentity(server) {
21
+ const parts = [];
22
+ for (const client of server.getClients()) {
23
+ const token = client.getAuthToken?.();
24
+ if (token) {
25
+ parts.push(
26
+ `${client.capabilityPrefix}:${token.replace(/^Bearer\s+/i, "")}`
27
+ );
28
+ }
29
+ }
30
+ if (parts.length === 0) {
31
+ return null;
32
+ }
33
+ return createHmac("sha256", IDENTITY_KEY).update(parts.join("\0")).digest("hex");
34
+ }
35
+ function requestIdentity(req, server) {
36
+ return withRequestContext(req, () => resolveCredentialIdentity(server));
37
+ }
38
+ function writeSessionNotFound(res) {
39
+ res.writeHead(404, { "Content-Type": "application/json" });
40
+ res.end(
41
+ JSON.stringify({
42
+ jsonrpc: "2.0",
43
+ error: {
44
+ code: -32001,
45
+ message: "Session not found"
46
+ },
47
+ id: null
48
+ })
49
+ );
50
+ }
51
+ function authorizeSessionRequest(req, res, entry, notFound = writeSessionNotFound) {
52
+ if (!entry.identity) {
53
+ return true;
54
+ }
55
+ const current = requestIdentity(req, entry.server);
56
+ if (current === entry.identity) {
57
+ return true;
58
+ }
59
+ req.resume();
60
+ if (current === null) {
61
+ res.writeHead(401, unauthorizedHeaders(req.headers, req.headers.host));
62
+ res.end("Unauthorized: credentials are required on every request");
63
+ } else {
64
+ notFound(res);
65
+ }
66
+ return false;
67
+ }
16
68
  const PROBE_HEADERS = {
17
69
  "Content-Type": "application/json",
18
70
  "Cache-Control": "no-store"
@@ -20,7 +72,13 @@ const PROBE_HEADERS = {
20
72
  function handleHealthRequest(res) {
21
73
  res.writeHead(200, PROBE_HEADERS);
22
74
  res.end(
23
- JSON.stringify({ status: "ok", timestamp: (/* @__PURE__ */ new Date()).toISOString() })
75
+ JSON.stringify({
76
+ status: "ok",
77
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
78
+ version: MCP_SERVER_VERSION,
79
+ // No regional deployments exist yet; hardcoded until that lands.
80
+ region: null
81
+ })
24
82
  );
25
83
  }
26
84
  function handleReadyRequest(res, draining = isDraining) {
@@ -236,18 +294,23 @@ async function createNewTransport(req, res, transports) {
236
294
  if (!server) {
237
295
  return null;
238
296
  }
297
+ const identity = requestIdentity(req, server) ?? void 0;
239
298
  const transport = new NodeStreamableHTTPServerTransport({
240
299
  sessionIdGenerator: () => randomUUID(),
241
300
  onsessioninitialized: (newSessionId) => {
242
- console.log(`[MCP] New session initialized: ${newSessionId}`);
243
- transports.set(newSessionId, { server, transport });
301
+ console.log(
302
+ `[MCP] New session initialized: ${redactSessionId(newSessionId)}`
303
+ );
304
+ transports.set(newSessionId, { server, transport, identity });
244
305
  attachSessionAnalytics(server, newSessionId, "streamable-http");
245
306
  }
246
307
  });
247
308
  transport.onmessage = (message) => handleSessionMessage(server, message);
248
309
  transport.onclose = () => {
249
310
  if (transport.sessionId) {
250
- console.log(`[MCP] Session closed: ${transport.sessionId}`);
311
+ console.log(
312
+ `[MCP] Session closed: ${redactSessionId(transport.sessionId)}`
313
+ );
251
314
  transports.delete(transport.sessionId);
252
315
  endSessionAnalytics(server);
253
316
  server.cleanupSession(transport.sessionId);
@@ -256,6 +319,9 @@ async function createNewTransport(req, res, transports) {
256
319
  await server.connect(transport);
257
320
  return transport;
258
321
  }
322
+ function redactSessionId(sessionId) {
323
+ return `${sessionId.slice(0, 8)}...`;
324
+ }
259
325
  function handleSessionMessage(server, message) {
260
326
  handleInitializeMessage(server, message);
261
327
  if (isToolsListRequest(message)) {
@@ -342,19 +408,13 @@ function extractModernClientMetaFromBody(parsedBody) {
342
408
  async function handleStreamableHttpRequest(req, res, transports, preParsed) {
343
409
  try {
344
410
  const sessionId = req.headers["mcp-session-id"];
345
- if (sessionId && !transports.has(sessionId)) {
411
+ const sessionEntry = sessionId ? transports.get(sessionId) : void 0;
412
+ if (sessionId && !sessionEntry) {
346
413
  req.resume();
347
- res.writeHead(404, { "Content-Type": "application/json" });
348
- res.end(
349
- JSON.stringify({
350
- jsonrpc: "2.0",
351
- error: {
352
- code: -32001,
353
- message: "Session not found"
354
- },
355
- id: null
356
- })
357
- );
414
+ writeSessionNotFound(res);
415
+ return;
416
+ }
417
+ if (sessionEntry && !authorizeSessionRequest(req, res, sessionEntry)) {
358
418
  return;
359
419
  }
360
420
  const parsedBody = preParsed ? preParsed.body : await parseRequestBody(req);
@@ -403,9 +463,10 @@ async function handleLegacySseRequest(req, res, transports) {
403
463
  if (!server) {
404
464
  return;
405
465
  }
466
+ const identity = requestIdentity(req, server) ?? void 0;
406
467
  const transport = new SSEServerTransport("/message", res);
407
468
  transport.onmessage = (message) => handleSessionMessage(server, message);
408
- transports.set(transport.sessionId, { server, transport });
469
+ transports.set(transport.sessionId, { server, transport, identity });
409
470
  attachSessionAnalytics(server, transport.sessionId, "sse");
410
471
  res.on("close", () => {
411
472
  transports.delete(transport.sessionId);
@@ -414,6 +475,10 @@ async function handleLegacySseRequest(req, res, transports) {
414
475
  });
415
476
  await server.connect(transport);
416
477
  }
478
+ function writeLegacySessionNotFound(res) {
479
+ res.writeHead(404, { "Content-Type": "text/plain" });
480
+ res.end("Session not found");
481
+ }
417
482
  async function handleLegacyMessageRequest(req, res, url, transports) {
418
483
  const sessionId = url.searchParams.get("sessionId");
419
484
  if (!sessionId) {
@@ -423,8 +488,7 @@ async function handleLegacyMessageRequest(req, res, url, transports) {
423
488
  }
424
489
  const session = transports.get(sessionId);
425
490
  if (!session) {
426
- res.writeHead(404, { "Content-Type": "text/plain" });
427
- res.end("Session not found");
491
+ writeLegacySessionNotFound(res);
428
492
  return;
429
493
  }
430
494
  if (!(session.transport instanceof SSEServerTransport)) {
@@ -432,6 +496,9 @@ async function handleLegacyMessageRequest(req, res, url, transports) {
432
496
  res.end("Invalid transport for this endpoint");
433
497
  return;
434
498
  }
499
+ if (!authorizeSessionRequest(req, res, session, writeLegacySessionNotFound)) {
500
+ return;
501
+ }
435
502
  let body = "";
436
503
  req.on("data", (chunk) => {
437
504
  body += chunk.toString();
@@ -521,18 +588,21 @@ async function buildConfiguredServer(getConfig, headers, host, res, era) {
521
588
  const headerHelp = getHttpHeadersHelp();
522
589
  const errorMessage = headerHelp.length > 0 ? `Configuration error: ${error instanceof Error ? error.message : String(error)}. Please provide valid headers:
523
590
  ${headerHelp.join("\n")}` : "No clients support HTTP header configuration.";
524
- const responseHeaders = {
525
- "Content-Type": "text/plain"
526
- };
527
- if (process.env.BASE_URL || host) {
528
- responseHeaders["WWW-Authenticate"] = `OAuth resource_metadata="${getBaseUrlFromHeaders(headers)}/.well-known/oauth-protected-resource"`;
529
- }
530
- res.writeHead(401, responseHeaders);
591
+ res.writeHead(401, unauthorizedHeaders(headers, host));
531
592
  res.end(errorMessage);
532
593
  return null;
533
594
  }
534
595
  return server;
535
596
  }
597
+ function unauthorizedHeaders(headers, host) {
598
+ const responseHeaders = {
599
+ "Content-Type": "text/plain"
600
+ };
601
+ if (process.env.BASE_URL || host) {
602
+ responseHeaders["WWW-Authenticate"] = `OAuth resource_metadata="${getBaseUrlFromHeaders(headers)}/.well-known/oauth-protected-resource"`;
603
+ }
604
+ return responseHeaders;
605
+ }
536
606
  async function newServer(req, res) {
537
607
  return buildConfiguredServer(
538
608
  (clientPrefix, key) => getConfigValue(clientPrefix, key, req),
@@ -551,11 +621,6 @@ async function newServerFromWebRequest(request, res) {
551
621
  "modern"
552
622
  );
553
623
  }
554
- function getHeaderName(clientPrefix, key) {
555
- return `${clientPrefix}-${key.split("_").map(
556
- (part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()
557
- ).join("-")}`;
558
- }
559
624
  function getQueryStringName(clientPrefix, key) {
560
625
  return `${clientPrefix.toLowerCase()}${key.split("_").map(
561
626
  (part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()
@@ -586,6 +651,7 @@ function getHttpHeadersHelp() {
586
651
  }
587
652
  export {
588
653
  attachSessionAnalytics,
654
+ authorizeSessionRequest,
589
655
  drainHttpTransport,
590
656
  endSessionAnalytics,
591
657
  getBaseUrl,
@@ -598,5 +664,6 @@ export {
598
664
  handleStreamableHttpRequest,
599
665
  newServer,
600
666
  newServerFromWebRequest,
667
+ resolveCredentialIdentity,
601
668
  runHttpMode
602
669
  };
@@ -2,6 +2,7 @@ import { enableCompileCache } from "node:module";
2
2
  import { StdioServerTransport, serveStdio } from "@modelcontextprotocol/server/stdio";
3
3
  import { setProcessClientIdentity, toClientIdentity } from "./client-identity.js";
4
4
  import { clientRegistry } from "./client-registry.js";
5
+ import { getEnvVarName } from "./config-names.js";
5
6
  import { USER_AGENT } from "./info.js";
6
7
  import { handleInitializeMessage, extractModernClientMeta } from "./initialize.js";
7
8
  import { SmartBearMcpServer } from "./server.js";
@@ -36,9 +37,6 @@ async function buildStdioServer(era = "legacy") {
36
37
  message.length > 0 ? `No clients configured. Please provide valid environment variables for at least one client:
37
38
  ${message.join("\n")}` : "No clients support environment variable configuration."
38
39
  );
39
- for (const entry of clientRegistry.getAll()) {
40
- await server.addClient(entry);
41
- }
42
40
  }
43
41
  return server;
44
42
  }
@@ -119,9 +117,6 @@ async function runStdioMode() {
119
117
  }
120
118
  });
121
119
  }
122
- function getEnvVarName(clientPrefix, key) {
123
- return `${clientPrefix.toUpperCase().replace(/-/g, "_")}_${key.toUpperCase()}`;
124
- }
125
120
  export {
126
121
  buildStdioServer,
127
122
  createInitializeCaptureTap,
@@ -1,4 +1,4 @@
1
- const version = "0.42.0";
1
+ const version = "0.44.0";
2
2
  const config = { "mcpServerName": "SmartBear MCP Server" };
3
3
  const packageJson = {
4
4
  version,
@@ -205,10 +205,7 @@ class AdminApi {
205
205
  /**
206
206
  * Fully replaces the roles assigned to a user (admin).
207
207
  */
208
- async setUserRoles({
209
- userId,
210
- roles
211
- }) {
208
+ async setUserRoles({ userId, roles }) {
212
209
  return await this.http.fetch(
213
210
  `${this.http.baseUrl}/admin/users/${encodeURIComponent(userId)}/roles`,
214
211
  { method: "PUT", body: { roles }, errorContext: "Set User Roles" }
@@ -217,10 +214,7 @@ class AdminApi {
217
214
  /**
218
215
  * Grants a single additional role to a user without affecting their existing roles (admin).
219
216
  */
220
- async addRoleToUser({
221
- userId,
222
- roleId
223
- }) {
217
+ async addRoleToUser({ userId, roleId }) {
224
218
  return await this.http.fetch(
225
219
  `${this.http.baseUrl}/admin/users/${encodeURIComponent(userId)}/roles/${encodeURIComponent(roleId)}`,
226
220
  { method: "PUT", body: {}, errorContext: "Add Role to User" }
@@ -337,6 +331,7 @@ class AdminApi {
337
331
  {
338
332
  method: "PATCH",
339
333
  body: operations,
334
+ headers: { "Content-Type": "application/json-patch+json" },
340
335
  errorContext: "Patch Team Users"
341
336
  }
342
337
  );
@@ -132,17 +132,51 @@ z.object({
132
132
  ),
133
133
  aiEnabled: z.boolean()
134
134
  }).describe("Entitlements information.");
135
+ const GenerationOutputSchema = z.looseObject({
136
+ id: z.string().nullish(),
137
+ code: z.string().optional(),
138
+ language: z.string().optional(),
139
+ requiresPromptExecution: z.literal(true).optional(),
140
+ prompt: z.string().optional(),
141
+ instructions: z.string().optional()
142
+ });
143
+ const RefineOutputSchema = z.looseObject({
144
+ recommendations: z.array(
145
+ z.looseObject({
146
+ recommendation: z.string(),
147
+ diff: z.string().nullish(),
148
+ confidence: z.number().nullish()
149
+ })
150
+ ).optional(),
151
+ requiresPromptExecution: z.literal(true).optional(),
152
+ prompt: z.string().optional(),
153
+ instructions: z.string().optional()
154
+ });
155
+ const EntitlementsOutputSchema = z.looseObject({
156
+ aiEnabled: z.boolean().optional(),
157
+ organizationEntitlements: z.looseObject({}).optional(),
158
+ userEntitlements: z.looseObject({}).optional()
159
+ });
160
+ const AI_OUTPUT_SCHEMAS = {
161
+ generate: GenerationOutputSchema,
162
+ review: RefineOutputSchema,
163
+ checkAIEntitlements: EntitlementsOutputSchema
164
+ };
135
165
  export {
166
+ AI_OUTPUT_SCHEMAS,
136
167
  AiCreditsSchema,
137
168
  EndpointMatcherSchema,
169
+ EntitlementsOutputSchema,
138
170
  FileInputSchema,
139
171
  GenerationInputSchema,
140
172
  GenerationLanguages,
173
+ GenerationOutputSchema,
141
174
  HttpMethods,
142
175
  OpenAPISchema,
143
176
  OpenAPIWithMatcherSchema,
144
177
  OrganizationEntitlementsSchema,
145
178
  RefineInputSchema,
179
+ RefineOutputSchema,
146
180
  RemoteOpenAPIDocumentSchema,
147
181
  RequestResponsePairSchema,
148
182
  UserEntitlementsSchema
@@ -279,6 +279,7 @@ class ContractApi {
279
279
  `${this.http.baseUrl}/integrations`,
280
280
  {
281
281
  method: "GET",
282
+ headers: { Accept: "application/hal+json" },
282
283
  errorContext: "List Integrations"
283
284
  }
284
285
  );
@@ -304,6 +305,7 @@ class ContractApi {
304
305
  `${this.http.baseUrl}/integrations/team/${encodeURIComponent(teamId)}`,
305
306
  {
306
307
  method: "GET",
308
+ headers: { Accept: "application/hal+json" },
307
309
  errorContext: "Get Integrations by Team"
308
310
  }
309
311
  );
@@ -5,11 +5,16 @@ class HttpClient {
5
5
  this.getHeaders = getHeaders;
6
6
  }
7
7
  async fetch(url, options) {
8
- const { method = "GET", body, errorContext = "Request" } = options ?? {};
8
+ const {
9
+ method = "GET",
10
+ body,
11
+ headers,
12
+ errorContext = "Request"
13
+ } = options ?? {};
9
14
  try {
10
15
  const response = await fetch(url, {
11
16
  method,
12
- headers: this.getHeaders(),
17
+ headers: { ...this.getHeaders(), ...headers },
13
18
  ...body !== void 0 ? { body: JSON.stringify(body) } : {}
14
19
  });
15
20
  if (!response.ok) {
@@ -63,6 +63,41 @@ class PacticipantApi {
63
63
  { method: "GET", errorContext: "List Versions" }
64
64
  );
65
65
  }
66
+ /**
67
+ * Retrieves all versions of a pacticipant that have ever been deployed or released, with optional pagination.
68
+ */
69
+ async listDeployedOrReleasedVersions({
70
+ pacticipantName,
71
+ pageNumber,
72
+ pageSize
73
+ }) {
74
+ const queryParams = new URLSearchParams();
75
+ if (pageNumber) queryParams.set("page", String(pageNumber));
76
+ if (pageSize) queryParams.set("size", String(pageSize));
77
+ const qs = queryParams.toString();
78
+ return await this.http.fetch(
79
+ `${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/deployed-or-released/versions${qs ? `?${qs}` : ""}`,
80
+ { method: "GET", errorContext: "List Deployed or Released Versions" }
81
+ );
82
+ }
83
+ /**
84
+ * Retrieves the versions of a pacticipant associated with an environment, with optional pagination.
85
+ */
86
+ async listEnvironmentVersions({
87
+ pacticipantName,
88
+ environmentId,
89
+ pageNumber,
90
+ pageSize
91
+ }) {
92
+ const queryParams = new URLSearchParams();
93
+ if (pageNumber) queryParams.set("page", String(pageNumber));
94
+ if (pageSize) queryParams.set("size", String(pageSize));
95
+ const qs = queryParams.toString();
96
+ return await this.http.fetch(
97
+ `${this.http.baseUrl}/pacticipants/${encodeURIComponent(pacticipantName)}/environments/${encodeURIComponent(environmentId)}/versions${qs ? `?${qs}` : ""}`,
98
+ { method: "GET", errorContext: "List Environment Versions" }
99
+ );
100
+ }
66
101
  /**
67
102
  * Retrieves metadata for a specific version of a pacticipant.
68
103
  */
@@ -265,6 +300,8 @@ class PacticipantApi {
265
300
  getPacticipant: this.getPacticipant.bind(this),
266
301
  listBranches: this.listBranches.bind(this),
267
302
  listVersions: this.listVersions.bind(this),
303
+ listDeployedOrReleasedVersions: this.listDeployedOrReleasedVersions.bind(this),
304
+ listEnvironmentVersions: this.listEnvironmentVersions.bind(this),
268
305
  getVersion: this.getVersion.bind(this),
269
306
  getLatestVersion: this.getLatestVersion.bind(this),
270
307
  updatePacticipant: this.updatePacticipant.bind(this),