@smartbear/mcp 0.28.0 → 0.30.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 (37) hide show
  1. package/README.md +1 -1
  2. package/dist/bearq/client.js +5 -3
  3. package/dist/bearq/tool/environments/list-environments.js +28 -0
  4. package/dist/bearq/tool/tasks/run-regression-tests.js +10 -3
  5. package/dist/bearq/tool/tasks/run-test-cases.js +12 -3
  6. package/dist/bearq/tool/tasks/run-tests-in-functional-areas.js +12 -3
  7. package/dist/bugsnag/client.js +2 -2
  8. package/dist/collaborator/client.js +5 -2
  9. package/dist/common/client-identity.js +20 -0
  10. package/dist/common/info.js +21 -1
  11. package/dist/common/initialize.js +7 -0
  12. package/dist/common/request-context.js +7 -0
  13. package/dist/common/server.js +37 -1
  14. package/dist/common/transport-http.js +13 -13
  15. package/dist/package.json.js +1 -1
  16. package/dist/pactflow/client/tools.js +408 -0
  17. package/dist/pactflow/client.js +5 -12
  18. package/dist/qmetry/client/api/client-api.js +2 -2
  19. package/dist/qmetry/client/automation.js +2 -2
  20. package/dist/qtm4j/http/auth-service.js +2 -2
  21. package/dist/reflect/client.js +7 -3
  22. package/dist/reflect/tool/tests/create-segment.js +18 -0
  23. package/dist/reflect/tool/tests/create-test.js +18 -0
  24. package/dist/reflect/tool/tests/definition.js +190 -0
  25. package/dist/swagger/client/api.js +2 -1
  26. package/dist/swagger/client/functional-testing-api.js +193 -42
  27. package/dist/swagger/client/functional-testing-tools.js +50 -2
  28. package/dist/swagger/client/functional-testing-types.js +27 -0
  29. package/dist/swagger/client/portal-types.js +144 -10
  30. package/dist/swagger/client/registry-types.js +60 -1
  31. package/dist/swagger/client/tool-constants.js +20 -0
  32. package/dist/swagger/client/tools.js +87 -29
  33. package/dist/swagger/client/user-management-types.js +14 -0
  34. package/dist/swagger/client.js +24 -2
  35. package/dist/zephyr/common/auth-service.js +2 -2
  36. package/dist/zephyr/common/rest-api-schemas.js +1 -1
  37. package/package.json +3 -1
package/README.md CHANGED
@@ -35,7 +35,7 @@ See individual guides for suggested prompts and supported tools and resources:
35
35
  - [Portal](https://developer.smartbear.com/smartbear-mcp/docs/swagger-portal-integration) - Portal and product management capabilities
36
36
  - [Studio](https://developer.smartbear.com/smartbear-mcp/docs/swagger-studio-integration) - API and Domain management capabilities, including AI-powered API generation from prompts and automatic standardization
37
37
  - [Contract Testing (PactFlow)](https://developer.smartbear.com/pactflow/default/getting-started) - Contract testing capabilities
38
- - [Functional Testing](https://developer.smartbear.com/smartbear-mcp/docs/functional-testing-integration) - API test discovery capabilities
38
+ - [Functional Testing](https://developer.smartbear.com/smartbear-mcp/docs/swagger-functional-testing-integration) - API test discovery capabilities
39
39
  - [QMetry](https://developer.smartbear.com/smartbear-mcp/docs/qmetry-integration) - QMetry Test Management capabilities
40
40
  - [Zephyr](https://developer.smartbear.com/smartbear-mcp/docs/zephyr-integration) - Zephyr Test Management capabilities
41
41
  - [Collaborator](https://developer.smartbear.com/smartbear-mcp/docs/collaborator-integration) - Review and Remote System Configuration management capabilities
@@ -1,8 +1,9 @@
1
1
  import { z } from "zod";
2
- import { USER_AGENT } from "../common/info.js";
2
+ import { getUserAgent } from "../common/info.js";
3
3
  import { getRequestHeader } from "../common/request-context.js";
4
4
  import { ToolError } from "../common/tools.js";
5
5
  import { DEFAULT_API_BASE_URL, AUTHORIZATION_HEADER } from "./config/constants.js";
6
+ import { ListEnvironments } from "./tool/environments/list-environments.js";
6
7
  import { ChatWithQaLead } from "./tool/tasks/chat-with-qa-lead.js";
7
8
  import { ExpandApplicationModel } from "./tool/tasks/expand-application-model.js";
8
9
  import { GetTask } from "./tool/tasks/get-task.js";
@@ -53,7 +54,7 @@ class BearQClient {
53
54
  return {
54
55
  Authorization: `Bearer ${token}`,
55
56
  "Content-Type": "application/json",
56
- "User-Agent": USER_AGENT
57
+ "User-Agent": getUserAgent()
57
58
  };
58
59
  }
59
60
  async registerTools(register, _getInput) {
@@ -69,7 +70,8 @@ class BearQClient {
69
70
  new GetTask(this),
70
71
  new GetTaskStatus(this),
71
72
  new StopTask(this),
72
- new WaitForTask(this)
73
+ new WaitForTask(this),
74
+ new ListEnvironments(this)
73
75
  ];
74
76
  for (const tool of tools) {
75
77
  register(tool.specification, tool.handle);
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import { Tool, ToolError } from "../../../common/tools.js";
3
+ const inputSchema = z.object({});
4
+ class ListEnvironments extends Tool {
5
+ specification = {
6
+ title: "List Environments",
7
+ toolset: "Environments",
8
+ summary: "Lists the environments configured in the workspace. Use this to discover valid environment names to pass to the test-running tools, and to identify the workspace default.",
9
+ inputSchema,
10
+ readOnly: true
11
+ };
12
+ handle = async (_args) => {
13
+ const res = await fetch(`${this.client.getBaseUrl()}/environments`, {
14
+ method: "GET",
15
+ headers: this.client.getHeaders()
16
+ });
17
+ if (!res.ok)
18
+ throw new ToolError(
19
+ `GET /environments failed: ${res.status} ${res.statusText}`
20
+ );
21
+ return {
22
+ content: [{ type: "text", text: JSON.stringify(await res.json()) }]
23
+ };
24
+ };
25
+ }
26
+ export {
27
+ ListEnvironments
28
+ };
@@ -1,6 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import { Tool, ToolError } from "../../../common/tools.js";
3
- const inputSchema = z.object({});
3
+ const inputSchema = z.object({
4
+ environment: z.string().min(1).optional().describe(
5
+ "Target environment name to run tests against. Omit to use the workspace default."
6
+ )
7
+ });
4
8
  class RunRegressionTests extends Tool {
5
9
  specification = {
6
10
  title: "Run Regression Tests",
@@ -8,11 +12,14 @@ class RunRegressionTests extends Tool {
8
12
  summary: "Runs the full BearQ regression suite — every regression-ready test case in the workspace. Use for CI/CD or pre-release smoke.",
9
13
  inputSchema
10
14
  };
11
- handle = async (_args) => {
15
+ handle = async (args) => {
16
+ const { environment } = inputSchema.parse(args);
17
+ const body = { agent: "tester", mode: "run" };
18
+ if (environment !== void 0) body.environment = environment;
12
19
  const res = await fetch(`${this.client.getBaseUrl()}/tasks`, {
13
20
  method: "POST",
14
21
  headers: this.client.getHeaders(),
15
- body: JSON.stringify({ agent: "tester", mode: "run" })
22
+ body: JSON.stringify(body)
16
23
  });
17
24
  if (!res.ok)
18
25
  throw new ToolError(
@@ -1,7 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import { Tool, ToolError } from "../../../common/tools.js";
3
3
  const inputSchema = z.object({
4
- testCaseIds: z.array(z.number().int().positive()).min(1).describe("IDs of BearQ regression test cases to run.")
4
+ testCaseIds: z.array(z.number().int().positive()).min(1).describe("IDs of BearQ regression test cases to run."),
5
+ environment: z.string().min(1).optional().describe(
6
+ "Target environment name to run tests against. Omit to use the workspace default."
7
+ )
5
8
  });
6
9
  class RunTestCases extends Tool {
7
10
  specification = {
@@ -11,11 +14,17 @@ class RunTestCases extends Tool {
11
14
  inputSchema
12
15
  };
13
16
  handle = async (args) => {
14
- const { testCaseIds } = inputSchema.parse(args);
17
+ const { testCaseIds, environment } = inputSchema.parse(args);
18
+ const body = {
19
+ agent: "tester",
20
+ mode: "run",
21
+ testCaseIds
22
+ };
23
+ if (environment !== void 0) body.environment = environment;
15
24
  const res = await fetch(`${this.client.getBaseUrl()}/tasks`, {
16
25
  method: "POST",
17
26
  headers: this.client.getHeaders(),
18
- body: JSON.stringify({ agent: "tester", mode: "run", testCaseIds })
27
+ body: JSON.stringify(body)
19
28
  });
20
29
  if (!res.ok)
21
30
  throw new ToolError(
@@ -1,7 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import { Tool, ToolError } from "../../../common/tools.js";
3
3
  const inputSchema = z.object({
4
- functionalAreas: z.array(z.union([z.number().int().positive(), z.string().min(1)])).min(1).describe("Functional areas to target, by ID or name.")
4
+ functionalAreas: z.array(z.union([z.number().int().positive(), z.string().min(1)])).min(1).describe("Functional areas to target, by ID or name."),
5
+ environment: z.string().min(1).optional().describe(
6
+ "Target environment name to run tests against. Omit to use the workspace default."
7
+ )
5
8
  });
6
9
  class RunTestsInFunctionalAreas extends Tool {
7
10
  specification = {
@@ -11,11 +14,17 @@ class RunTestsInFunctionalAreas extends Tool {
11
14
  inputSchema
12
15
  };
13
16
  handle = async (args) => {
14
- const { functionalAreas } = inputSchema.parse(args);
17
+ const { functionalAreas, environment } = inputSchema.parse(args);
18
+ const body = {
19
+ agent: "tester",
20
+ mode: "run",
21
+ functionalAreas
22
+ };
23
+ if (environment !== void 0) body.environment = environment;
15
24
  const res = await fetch(`${this.client.getBaseUrl()}/tasks`, {
16
25
  method: "POST",
17
26
  headers: this.client.getHeaders(),
18
- body: JSON.stringify({ agent: "tester", mode: "run", functionalAreas })
27
+ body: JSON.stringify(body)
19
28
  });
20
29
  if (!res.ok)
21
30
  throw new ToolError(
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { USER_AGENT } from "../common/info.js";
2
+ import { getUserAgent } from "../common/info.js";
3
3
  import { getRequestHeader } from "../common/request-context.js";
4
4
  import { ToolError } from "../common/tools.js";
5
5
  import { CurrentUserAPI } from "./client/api/CurrentUser.js";
@@ -123,7 +123,7 @@ class BugsnagClient {
123
123
  );
124
124
  },
125
125
  headers: {
126
- "User-Agent": USER_AGENT,
126
+ "User-Agent": getUserAgent(),
127
127
  "Content-Type": "application/json",
128
128
  "X-Bugsnag-API": "true",
129
129
  "X-Version": "2"
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { USER_AGENT } from "../common/info.js";
2
+ import { getUserAgent } from "../common/info.js";
3
3
  import { getRequestHeader } from "../common/request-context.js";
4
4
  const ConfigurationSchema = z.object({
5
5
  base_url: z.url().describe("Collaborator server base URL"),
@@ -48,7 +48,10 @@ class CollaboratorClient {
48
48
  ];
49
49
  const response = await fetch(url, {
50
50
  method: "POST",
51
- headers: { "Content-Type": "application/json", "User-Agent": USER_AGENT },
51
+ headers: {
52
+ "Content-Type": "application/json",
53
+ "User-Agent": getUserAgent()
54
+ },
52
55
  body: JSON.stringify(body)
53
56
  });
54
57
  if (!response.ok) {
@@ -0,0 +1,20 @@
1
+ import { getRequestContext } from "./request-context.js";
2
+ function toClientIdentity(info, protocolVersion) {
3
+ return {
4
+ name: info?.name,
5
+ version: info?.version,
6
+ protocolVersion
7
+ };
8
+ }
9
+ let processClientIdentity;
10
+ function setProcessClientIdentity(identity) {
11
+ processClientIdentity = identity;
12
+ }
13
+ function getCurrentClientIdentity() {
14
+ return getRequestContext()?.mcpClient ?? processClientIdentity;
15
+ }
16
+ export {
17
+ getCurrentClientIdentity,
18
+ setProcessClientIdentity,
19
+ toClientIdentity
20
+ };
@@ -1,11 +1,31 @@
1
1
  import packageJson from "../package.json.js";
2
+ import { getCurrentClientIdentity } from "./client-identity.js";
2
3
  const MCP_SERVER_NAME = packageJson.config.mcpServerName;
3
4
  const MCP_SERVER_VERSION = packageJson.version;
4
5
  const MCP_TRANSPORT = process.env.MCP_TRANSPORT?.toLowerCase().trim() || "stdio";
5
6
  const USER_AGENT = `${MCP_SERVER_NAME}/${MCP_SERVER_VERSION} ${MCP_TRANSPORT}`;
7
+ function sanitizeUserAgentToken(value) {
8
+ return value.replace(/[()\r\n;]/g, "").trim();
9
+ }
10
+ function clientIdentitySuffix(identity) {
11
+ if (!identity?.name) {
12
+ return "";
13
+ }
14
+ const clientName = sanitizeUserAgentToken(identity.name) || "unknown";
15
+ const version = identity.version ? sanitizeUserAgentToken(identity.version) || "unknown" : "unknown";
16
+ return ` (client: ${clientName}; clientVersion: ${version})`;
17
+ }
18
+ function appendClientIdentity(baseUserAgent) {
19
+ return baseUserAgent + clientIdentitySuffix(getCurrentClientIdentity());
20
+ }
21
+ function getUserAgent() {
22
+ return appendClientIdentity(USER_AGENT);
23
+ }
6
24
  export {
7
25
  MCP_SERVER_NAME,
8
26
  MCP_SERVER_VERSION,
9
27
  MCP_TRANSPORT,
10
- USER_AGENT
28
+ USER_AGENT,
29
+ appendClientIdentity,
30
+ getUserAgent
11
31
  };
@@ -1,8 +1,15 @@
1
+ import { toClientIdentity, setProcessClientIdentity } from "./client-identity.js";
1
2
  function handleInitializeMessage(server, message) {
2
3
  if (typeof message !== "object" || message === null || !("method" in message) || message.method !== "initialize") {
3
4
  return;
4
5
  }
5
6
  const params = message.params;
7
+ const identity = toClientIdentity(
8
+ params?.clientInfo,
9
+ params?.protocolVersion
10
+ );
11
+ server.setMcpClientIdentity(identity);
12
+ setProcessClientIdentity(identity);
6
13
  const clientInfo = params?.clientInfo;
7
14
  if (clientInfo) {
8
15
  server.setClientInfo(clientInfo);
@@ -6,6 +6,12 @@ function withRequestContext(req, fn) {
6
6
  function getRequestContext() {
7
7
  return requestContextStorage.getStore();
8
8
  }
9
+ function setRequestMcpClient(identity) {
10
+ const context = getRequestContext();
11
+ if (context) {
12
+ context.mcpClient = identity;
13
+ }
14
+ }
9
15
  function getRequestHeader(name) {
10
16
  const context = getRequestContext();
11
17
  if (!context?.headers) return void 0;
@@ -16,5 +22,6 @@ export {
16
22
  getRequestContext,
17
23
  getRequestHeader,
18
24
  requestContextStorage,
25
+ setRequestMcpClient,
19
26
  withRequestContext
20
27
  };
@@ -2,6 +2,7 @@ import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mc
2
2
  import { ZodObject, ZodIntersection } from "zod";
3
3
  import Bugsnag from "./bugsnag.js";
4
4
  import { CacheService } from "./cache.js";
5
+ import { toClientIdentity } from "./client-identity.js";
5
6
  import { MCP_SERVER_VERSION, MCP_SERVER_NAME } from "./info.js";
6
7
  import { executeElicitationOrPolyfill, isElicitationPolyfillResult } from "./pollyfills.js";
7
8
  import { ToolError } from "./tools.js";
@@ -13,6 +14,7 @@ class SmartBearMcpServer extends McpServer {
13
14
  clientInfo;
14
15
  clients = [];
15
16
  enabledToolsets;
17
+ mcpClientIdentity;
16
18
  constructor(enabledToolsets) {
17
19
  super(
18
20
  {
@@ -58,6 +60,33 @@ class SmartBearMcpServer extends McpServer {
58
60
  getClients() {
59
61
  return this.clients;
60
62
  }
63
+ /**
64
+ * Record the MCP client identity reported in the `initialize` handshake.
65
+ * Captured once per session by the transport layer.
66
+ */
67
+ setMcpClientIdentity(identity) {
68
+ this.mcpClientIdentity = identity;
69
+ }
70
+ /**
71
+ * Return the MCP client identity for this session. Prefers the value captured
72
+ * at `initialize`; falls back to the SDK's `getClientVersion()` so callers
73
+ * still get an answer if the explicit capture was skipped.
74
+ */
75
+ getMcpClientIdentity() {
76
+ return this.mcpClientIdentity ?? toClientIdentity(this.server.getClientVersion());
77
+ }
78
+ /**
79
+ * Attach MCP client attribution to a Bugsnag event so errors can be segmented
80
+ * by originating client/marketplace.
81
+ */
82
+ addClientMetadata(event) {
83
+ const identity = this.getMcpClientIdentity();
84
+ event.addMetadata("mcpClient", {
85
+ mcp_client_name: identity.name ?? null,
86
+ mcp_client_version: identity.version ?? null,
87
+ mcp_protocol_version: identity.protocolVersion ?? null
88
+ });
89
+ }
61
90
  async cleanupSession(mcpSessionId) {
62
91
  for (const client of this.clients) {
63
92
  await client.cleanupSession?.(mcpSessionId);
@@ -83,7 +112,11 @@ class SmartBearMcpServer extends McpServer {
83
112
  title: toolTitle,
84
113
  description: this.getDescription(params),
85
114
  inputSchema: params.inputSchema ? this.schemaToRawShape(params.inputSchema) : {},
86
- outputSchema: this.schemaToRawShape(params.outputSchema),
115
+ // Pass ZodObject-based schemas through as-is (rather than via schemaToRawShape)
116
+ // so that z.looseObject()'s additionalProperties:true is preserved in the JSON
117
+ // schema sent to clients — extracting `.shape` would rebuild a strict object and
118
+ // cause "additional properties" validation errors on real API responses.
119
+ outputSchema: params.outputSchema instanceof ZodObject ? params.outputSchema : this.schemaToRawShape(params.outputSchema),
87
120
  annotations: this.getAnnotations(toolTitle, params)
88
121
  },
89
122
  async (args, extra) => {
@@ -113,6 +146,7 @@ class SmartBearMcpServer extends McpServer {
113
146
  } else {
114
147
  Bugsnag.notify(e, (event) => {
115
148
  event.addMetadata("app", { tool: toolName });
149
+ this.addClientMetadata(event);
116
150
  event.unhandled = true;
117
151
  });
118
152
  }
@@ -163,6 +197,7 @@ ${result.instructions}`
163
197
  resource: resourceName,
164
198
  url: url2
165
199
  });
200
+ this.addClientMetadata(event);
166
201
  event.unhandled = true;
167
202
  });
168
203
  throw e;
@@ -188,6 +223,7 @@ ${result.instructions}`
188
223
  event.addMetadata("app", {
189
224
  prompt: this.getCapabilityName(client, params.title)
190
225
  });
226
+ this.addClientMetadata(event);
191
227
  event.unhandled = true;
192
228
  });
193
229
  throw e;
@@ -6,7 +6,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
6
6
  import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
7
7
  import { clientRegistry } from "./client-registry.js";
8
8
  import { handleInitializeMessage } from "./initialize.js";
9
- import { withRequestContext } from "./request-context.js";
9
+ import { withRequestContext, setRequestMcpClient } from "./request-context.js";
10
10
  import { SmartBearMcpServer } from "./server.js";
11
11
  import { isDraining, registerShutdownHandler } from "./shutdown.js";
12
12
  import { getEnvVarName } from "./transport-stdio.js";
@@ -269,10 +269,13 @@ async function handleStreamableHttpRequest(req, res, transports) {
269
269
  );
270
270
  return;
271
271
  }
272
- await withRequestContext(
273
- req,
274
- async () => await transport.handleRequest(req, res, parsedBody)
275
- );
272
+ const sessionServer = sessionId ? transports.get(sessionId)?.server : void 0;
273
+ await withRequestContext(req, async () => {
274
+ if (sessionServer) {
275
+ setRequestMcpClient(sessionServer.getMcpClientIdentity());
276
+ }
277
+ return await transport.handleRequest(req, res, parsedBody);
278
+ });
276
279
  } catch (error) {
277
280
  console.error("Error handling StreamableHTTP request:", error);
278
281
  res.writeHead(500, { "Content-Type": "text/plain" });
@@ -285,6 +288,7 @@ async function handleLegacySseRequest(req, res, transports) {
285
288
  return;
286
289
  }
287
290
  const transport = new SSEServerTransport("/message", res);
291
+ transport.onmessage = (message) => handleInitializeMessage(server, message);
288
292
  transports.set(transport.sessionId, { server, transport });
289
293
  res.on("close", () => {
290
294
  transports.delete(transport.sessionId);
@@ -317,14 +321,10 @@ async function handleLegacyMessageRequest(req, res, url, transports) {
317
321
  req.on("end", async () => {
318
322
  try {
319
323
  const parsedBody = JSON.parse(body);
320
- await withRequestContext(
321
- req,
322
- async () => await session.transport.handlePostMessage(
323
- req,
324
- res,
325
- parsedBody
326
- )
327
- );
324
+ await withRequestContext(req, async () => {
325
+ setRequestMcpClient(session.server.getMcpClientIdentity());
326
+ return await session.transport.handlePostMessage(req, res, parsedBody);
327
+ });
328
328
  } catch (error) {
329
329
  console.error("Error handling POST message:", error);
330
330
  res.writeHead(500, { "Content-Type": "text/plain" });
@@ -1,4 +1,4 @@
1
- const version = "0.28.0";
1
+ const version = "0.30.0";
2
2
  const config = { "mcpServerName": "SmartBear MCP Server" };
3
3
  const packageJson = {
4
4
  version,