@smartbear/mcp 0.39.0 → 0.41.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 (45) hide show
  1. package/README.md +7 -0
  2. package/dist/common/cache.js +13 -3
  3. package/dist/common/initialize.js +21 -0
  4. package/dist/common/pollyfills.js +70 -1
  5. package/dist/common/request-context.js +28 -2
  6. package/dist/common/server.js +103 -13
  7. package/dist/common/transport-http.js +146 -22
  8. package/dist/common/transport-stdio.js +78 -18
  9. package/dist/package.json.js +1 -1
  10. package/dist/qmetry/client/auto-resolve.js +7 -0
  11. package/dist/qmetry/client/handlers.js +5 -2
  12. package/dist/qmetry/client/issues.js +8 -1
  13. package/dist/qmetry/client/project.js +103 -2
  14. package/dist/qmetry/client/requirement.js +99 -3
  15. package/dist/qmetry/client/testcase.js +51 -2
  16. package/dist/qmetry/client/testsuite.js +7 -1
  17. package/dist/qmetry/client/tools/issue-tools.js +1 -15
  18. package/dist/qmetry/client/tools/project-tools.js +2 -2
  19. package/dist/qmetry/client/tools/requirement-tools.js +124 -11
  20. package/dist/qmetry/client/tools/testcase-tools.js +116 -56
  21. package/dist/qmetry/client/tools/testsuite-tools.js +1 -19
  22. package/dist/qmetry/client/tools/udf-tools.js +15 -4
  23. package/dist/qmetry/client/udf.js +2 -2
  24. package/dist/qmetry/client.js +19 -11
  25. package/dist/qmetry/config/constants.js +3 -0
  26. package/dist/qmetry/config/rest-endpoints.js +4 -2
  27. package/dist/qmetry/types/ai-agent.js +8 -4
  28. package/dist/qmetry/types/common.js +69 -43
  29. package/dist/qmetry/types/requirements.js +7 -1
  30. package/dist/qmetry/types/testcase.js +2 -1
  31. package/dist/qmetry/types/udf.js +5 -12
  32. package/dist/swagger/client/api.js +29 -4
  33. package/dist/swagger/client/functional-testing-api.js +18 -11
  34. package/dist/swagger/client/functional-testing-tools.js +6 -6
  35. package/dist/swagger/client/functional-testing-types.js +65 -2
  36. package/dist/swagger/client/functional-testing-url-utils.js +110 -0
  37. package/dist/swagger/client/registry-types.js +2 -2
  38. package/dist/swagger/client/tools.js +2 -2
  39. package/dist/zephyr/client.js +2 -0
  40. package/dist/zephyr/common/rest-api-schemas.js +345 -4
  41. package/dist/zephyr/tool/folder/get-folders.js +69 -0
  42. package/dist/zephyr/tool/issue-link/get-test-cases.js +7 -2
  43. package/dist/zephyr/tool/issue-link/get-test-cycles.js +7 -2
  44. package/dist/zephyr/tool/issue-link/get-test-executions.js +7 -2
  45. package/package.json +1 -1
@@ -4,7 +4,7 @@ const FUNCTIONAL_TESTING_TOOLS = [
4
4
  {
5
5
  title: "List Tests",
6
6
  toolset: "Functional Testing",
7
- summary: "Lists all API tests available in your Swagger Functional Testing account. Use this tool when you need to discover available tests before running them or checking their status. Do not use this tool to retrieve test execution results or history.",
7
+ summary: "Lists all API tests available in your Swagger Functional Testing account. Use this tool when you need to discover available tests before running them or checking their status. Returns test IDs usable with `swagger_run_test` to execute a single test, or passable to `swagger_create_suite` to group tests into a suite. Do not use this tool to retrieve test execution results or history.",
8
8
  handler: "listFunctionalTestingTests",
9
9
  idempotent: true,
10
10
  ...READ_ONLY
@@ -12,7 +12,7 @@ const FUNCTIONAL_TESTING_TOOLS = [
12
12
  {
13
13
  title: "Create Test",
14
14
  toolset: "Functional Testing",
15
- summary: "Creates a new API test in your Swagger Functional Testing workspace. This tool only creates API tests (not browser or native-mobile tests). Use this when you need to programmatically create a test with a defined set of API request steps. Each step requires a URL and may specify an HTTP method (defaults to GET), request body, headers, redirect handling, and assertions: expected HTTP status code ranges, and expected response body assertions (exact match or field-level rules matched by path). Returns the ID and the URL to definition of the newly created test; the ID can be used with `swagger_run_test` to run it or grouped with other test IDs into a Suite via `swagger_create_suite`.",
15
+ summary: "Creates a new API test in your Swagger Functional Testing workspace. This tool only creates API tests (not browser or native-mobile tests). Use this when you need to programmatically create a test with a defined set of API request steps. Each step requires a URL and may specify an HTTP method (defaults to GET), request body, headers, redirect handling, and assertions: expected HTTP status code ranges, and expected response body assertions (exact match or field-level rules matched by path). Top-level `parameters` are path parameters, not request body parameters. Every step MUST set `baseUrl` to that endpoint's server URL,so it is extracted into a shared parameter. Whenever `baseUrl` is set, also set `apiName` to the name of the API it belongs to. If a `{pathParam}` placeholder appears in more than one step's URL, you MUST define a matching entry in `parameters` so its value is shared across all steps. Returns the ID and the URL to definition of the newly created test; the ID can be used with `swagger_run_test` to run it or grouped with other test IDs into a Suite via `swagger_create_suite`.",
16
16
  inputSchema: CreateFunctionalTestingTestParamsSchema,
17
17
  outputSchema: CreateFunctionalTestingTestResponseSchema,
18
18
  handler: "createFunctionalTestingTest",
@@ -32,7 +32,7 @@ const FUNCTIONAL_TESTING_TOOLS = [
32
32
  {
33
33
  title: "Get Test Status",
34
34
  toolset: "Functional Testing",
35
- summary: "Get the status of a Swagger Functional Testing test execution. It returns information about the execution such as its status (running, passed or failed), run time, as well as the break down of the status of each test step.",
35
+ summary: "Get the status of a Swagger Functional Testing test execution. Returns the execution status (`running`, `passed`, or `failed`), run time, and a per-step breakdown. Poll this tool after calling `swagger_run_test` until status is `passed` or `failed`; `running` means the execution is still in progress.",
36
36
  inputSchema: GetFunctionalTestingExecutionTestSchema,
37
37
  handler: "getFunctionalTestingExecution",
38
38
  idempotent: true,
@@ -50,7 +50,7 @@ const FUNCTIONAL_TESTING_TOOLS = [
50
50
  {
51
51
  title: "Cancel Suite Execution",
52
52
  toolset: "Functional Testing",
53
- summary: "Cancels an ongoing test suite execution in your Swagger Functional Testing workspace. Use this tool when you need to stop a long-running or accidentally triggered suite run. Do not use this tool to cancel individual test runs.",
53
+ summary: "Cancels an ongoing test suite execution in your Swagger Functional Testing workspace. Use this tool when you need to stop a long-running or accidentally triggered suite run. The canceled execution is preserved in run history with status `canceled`. Do not use this tool to cancel individual test runs.",
54
54
  inputSchema: CancelFunctionalTestingSuiteExecutionSchema,
55
55
  handler: "cancelFunctionalTestingSuiteExecution",
56
56
  ...WRITE_DESTRUCTIVE,
@@ -87,7 +87,7 @@ const FUNCTIONAL_TESTING_TOOLS = [
87
87
  {
88
88
  title: "Get Suite Status",
89
89
  toolset: "Functional Testing",
90
- summary: "Get the status of a Swagger Functional Testing suite execution. Returns the overall status (pending, canceled, passed or failed), whether the run is finished, and a per-test breakdown with pass/fail. Use this to poll for the outcome of a suite run triggered by `swagger_run_suite`. Requires the suite's `slug` and the `executionId` returned by `swagger_run_suite`.",
90
+ summary: "Get the status of a Swagger Functional Testing suite execution. Returns the overall status (`pending`, `canceled`, `passed`, or `failed`), whether the run is finished, and a per-test breakdown with pass/fail, runtime, step count, and for failed tests a `failedStepsByIndex` map of step index to error message. `pending` means the execution has not yet finished (queued or actively running). Poll this tool after calling `swagger_run_suite` until `finished` is `true`. Requires the suite's `slug` and the `executionId` returned by `swagger_run_suite`.",
91
91
  inputSchema: GetFunctionalTestingSuiteExecutionSchema,
92
92
  handler: "getFunctionalTestingSuiteExecution",
93
93
  idempotent: true,
@@ -96,7 +96,7 @@ const FUNCTIONAL_TESTING_TOOLS = [
96
96
  {
97
97
  title: "Get Test Execution History",
98
98
  toolset: "Functional Testing",
99
- summary: "Retrieves the execution history for a given test in your Swagger Functional Testing workspace. Returns a list of past runs, each including pass/fail status, run time, creation timestamp, and — for failed runs — a per-step breakdown of failure details. Use this tool when you need to check past run results, identify failures, or assess test reliability over time. Do not use this tool to run a test or retrieve suite-level execution results.",
99
+ summary: "Retrieves the execution history for a given test in your Swagger Functional Testing workspace. Returns the total run count and a list of past runs, each including pass/fail status, run time, creation timestamp, and — for failed runs — a per-step breakdown of failure details. Supports pagination via `limit` (1–100, default 25) and `offset` (default 0). Use this tool when you need to check past run results, identify failures, or assess test reliability over time. Do not use this tool to run a test or retrieve suite-level execution results.",
100
100
  inputSchema: GetFunctionalTestHistoryParamsSchema,
101
101
  handler: "getFunctionalTestingTestHistory",
102
102
  idempotent: true,
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { extractPathParamNames, baseUrlParamName, splitUrlByBaseUrl } from "./functional-testing-url-utils.js";
2
3
  const RunFunctionalTestingTestParamsSchema = z.object({
3
4
  testId: z.string().describe("ID of the Functional Testing test to run").trim().min(1)
4
5
  });
@@ -251,8 +252,20 @@ const CreateFunctionalTestingAssertionsSchema = z.object({
251
252
  bodyType: z.enum(["json", "xml"]).optional().describe('Response body format, defaults to "json"'),
252
253
  bodyRules: z.array(CreateFunctionalTestingBodyRuleSchema).optional().describe("Assertion rules evaluated against the response body")
253
254
  });
255
+ const CreateFunctionalTestingTestParameterSchema = z.object({
256
+ name: z.string().trim().min(1).describe("Path parameter name"),
257
+ value: z.string().optional().describe("Parameter default value")
258
+ });
254
259
  const CreateFunctionalTestingTestStepSchema = z.object({
255
- url: z.url().describe("URL for the API call"),
260
+ url: z.string().trim().min(1).describe(
261
+ "Full URL for the API call. May include OAS-style {pathParam} placeholders, which are always converted into reusable parameters. baseUrl MUST also be set and url must start with it."
262
+ ),
263
+ baseUrl: z.url().optional().describe(
264
+ "Server/common URL for this step's endpoint (e.g. https://petstore.swagger.io/v2). REQUIRED on every step it is extracted into a definition-level parameter and templated into the step url"
265
+ ),
266
+ apiName: z.string().trim().min(1).optional().describe(
267
+ `Name of the API that this step's baseUrl belongs to, e.g. "Petstore". `
268
+ ),
256
269
  httpMethod: z.enum(HTTP_METHODS).describe("HTTP method for the API call (defaults to GET server-side)").optional(),
257
270
  requestBody: z.string().describe("Request body").optional(),
258
271
  requestHeaders: z.array(CreateFunctionalTestingTestHeaderSchema).describe("HTTP headers").optional(),
@@ -265,7 +278,56 @@ const CreateFunctionalTestingTestStepSchema = z.object({
265
278
  const CreateFunctionalTestingTestParamsSchema = z.object({
266
279
  name: z.string().describe("Name for the new test").trim().min(1),
267
280
  description: z.string().trim().describe("Optional description for the test").optional(),
268
- steps: z.array(CreateFunctionalTestingTestStepSchema).describe("Test steps to include in the test").optional()
281
+ steps: z.array(CreateFunctionalTestingTestStepSchema).describe("Test steps to include in the test").optional(),
282
+ parameters: z.array(CreateFunctionalTestingTestParameterSchema).describe(
283
+ "Definition-level path parameters for the test (e.g. base URLs, path params), not request body parameters."
284
+ ).optional()
285
+ }).superRefine((data, ctx) => {
286
+ const allowedNames = /* @__PURE__ */ new Set();
287
+ const pathParamCounts = /* @__PURE__ */ new Map();
288
+ data.steps?.forEach((step, index) => {
289
+ for (const name of extractPathParamNames(step.url)) {
290
+ allowedNames.add(name);
291
+ pathParamCounts.set(name, (pathParamCounts.get(name) ?? 0) + 1);
292
+ }
293
+ if (step.baseUrl) {
294
+ allowedNames.add(baseUrlParamName(step.baseUrl, step.apiName));
295
+ if (splitUrlByBaseUrl(step.url, step.baseUrl) === null) {
296
+ ctx.addIssue({
297
+ code: "custom",
298
+ message: `Step url "${step.url}" must start with its baseUrl "${step.baseUrl}".`,
299
+ path: ["steps", index, "url"]
300
+ });
301
+ }
302
+ } else {
303
+ ctx.addIssue({
304
+ code: "custom",
305
+ message: `Step url "${step.url}" does not set "baseUrl". Every step must set baseUrl to its server/common URL (e.g. https://petstore.swagger.io/v2) so it is extracted into a shared parameter, even when only one step uses that URL.`,
306
+ path: ["steps", index, "baseUrl"]
307
+ });
308
+ }
309
+ });
310
+ const definedParamNames = new Set(
311
+ (data.parameters ?? []).map((p) => p.name)
312
+ );
313
+ for (const [name, count] of pathParamCounts) {
314
+ if (count >= 2 && !definedParamNames.has(name)) {
315
+ ctx.addIssue({
316
+ code: "custom",
317
+ message: `Path parameter "{${name}}" appears in ${count} steps and must be defined in "parameters" so its value is shared across all steps.`,
318
+ path: ["parameters"]
319
+ });
320
+ }
321
+ }
322
+ data.parameters?.forEach((param, index) => {
323
+ if (!allowedNames.has(param.name)) {
324
+ ctx.addIssue({
325
+ code: "custom",
326
+ message: `Parameter "${param.name}" is not a path parameter: it must match a {${param.name}} placeholder in a step's url, or the generated base-URL parameter name for a step's baseUrl. The parameters field only accepts path parameters, not request body parameters.`,
327
+ path: ["parameters", index, "name"]
328
+ });
329
+ }
330
+ });
269
331
  });
270
332
  const CreateFunctionalTestingTestResponseSchema = z.object({
271
333
  id: z.number().describe("ID of the newly created test"),
@@ -281,6 +343,7 @@ export {
281
343
  CreateFunctionalTestingSuiteParamsSchema,
282
344
  CreateFunctionalTestingSuiteResponseSchema,
283
345
  CreateFunctionalTestingTestHeaderSchema,
346
+ CreateFunctionalTestingTestParameterSchema,
284
347
  CreateFunctionalTestingTestParamsSchema,
285
348
  CreateFunctionalTestingTestResponseSchema,
286
349
  CreateFunctionalTestingTestStepSchema,
@@ -0,0 +1,110 @@
1
+ const MAX_SANITIZED_NAME_LENGTH = 25;
2
+ function extractPathParamNames(url) {
3
+ return Array.from(url.matchAll(/{([^}]+)}/g), (m) => m[1]);
4
+ }
5
+ function convertPathVarsToReflectVars(value, resolveName = (name) => name) {
6
+ return value.replace(
7
+ /{([^}]+)}/g,
8
+ (_match, name) => `\${var(${resolveName(name)})}`
9
+ );
10
+ }
11
+ function sanitizeForParamName(value) {
12
+ return value.replace(/[^a-zA-Z0-9]/g, "").substring(0, MAX_SANITIZED_NAME_LENGTH);
13
+ }
14
+ function hostnameFor(url) {
15
+ try {
16
+ return new URL(url).hostname;
17
+ } catch {
18
+ return url;
19
+ }
20
+ }
21
+ function normalizeBaseUrl(baseUrl) {
22
+ return baseUrl.replace(/\/+$/, "");
23
+ }
24
+ function baseUrlParamName(baseUrl, apiName) {
25
+ const suffix = sanitizeForParamName(apiName || hostnameFor(baseUrl));
26
+ return `baseURL${suffix}`;
27
+ }
28
+ function splitUrlByBaseUrl(url, baseUrl) {
29
+ const normalizedBase = normalizeBaseUrl(baseUrl);
30
+ if (url === normalizedBase) {
31
+ return { normalizedBase, remainder: "/" };
32
+ }
33
+ if (url.startsWith(`${normalizedBase}/`)) {
34
+ return { normalizedBase, remainder: url.slice(normalizedBase.length) };
35
+ }
36
+ return null;
37
+ }
38
+ function generateUniqueParamName(base, usedNames) {
39
+ if (!usedNames.has(base)) {
40
+ return base;
41
+ }
42
+ let counter = 2;
43
+ while (usedNames.has(`${base}${counter}`)) {
44
+ counter++;
45
+ }
46
+ return `${base}${counter}`;
47
+ }
48
+ function applyBaseUrlTemplating(steps, callerParameters) {
49
+ const usedNames = new Set(
50
+ (callerParameters ?? []).map((p) => p.name)
51
+ );
52
+ const paramNamesByKey = /* @__PURE__ */ new Map();
53
+ const generatedParams = [];
54
+ const getOrCreateParamName = (key, desiredName, value) => {
55
+ let paramName = paramNamesByKey.get(key);
56
+ if (paramName) {
57
+ return paramName;
58
+ }
59
+ if (usedNames.has(desiredName)) {
60
+ paramName = desiredName;
61
+ paramNamesByKey.set(key, paramName);
62
+ return paramName;
63
+ }
64
+ paramName = generateUniqueParamName(desiredName, usedNames);
65
+ paramNamesByKey.set(key, paramName);
66
+ usedNames.add(paramName);
67
+ generatedParams.push({ name: paramName, value });
68
+ return paramName;
69
+ };
70
+ const resultSteps = steps?.map((step) => {
71
+ const { baseUrl, apiName, url, ...rest } = step;
72
+ let prefix = "";
73
+ let remainder = url;
74
+ if (baseUrl) {
75
+ const split = splitUrlByBaseUrl(url, baseUrl);
76
+ if (split === null) {
77
+ throw new Error(
78
+ `Step url "${url}" must start with its baseUrl "${baseUrl}"`
79
+ );
80
+ }
81
+ const paramName = getOrCreateParamName(
82
+ `baseUrl:${split.normalizedBase}`,
83
+ baseUrlParamName(baseUrl, apiName),
84
+ split.normalizedBase
85
+ );
86
+ prefix = `\${var(${paramName})}`;
87
+ remainder = split.remainder;
88
+ }
89
+ const templatedRemainder = convertPathVarsToReflectVars(
90
+ remainder,
91
+ (pathParamName) => getOrCreateParamName(`pathParam:${pathParamName}`, pathParamName, "")
92
+ );
93
+ return { ...rest, url: `${prefix}${templatedRemainder}` };
94
+ });
95
+ return {
96
+ steps: resultSteps,
97
+ parameters: [...generatedParams, ...callerParameters ?? []]
98
+ };
99
+ }
100
+ export {
101
+ applyBaseUrlTemplating,
102
+ baseUrlParamName,
103
+ convertPathVarsToReflectVars,
104
+ extractPathParamNames,
105
+ generateUniqueParamName,
106
+ hostnameFor,
107
+ normalizeBaseUrl,
108
+ sanitizeForParamName,
109
+ splitUrlByBaseUrl
110
+ };
@@ -32,7 +32,7 @@ const CreateApiParamsSchema = z.object({
32
32
  owner: z.string().describe("Organization name (owner of the API)"),
33
33
  apiName: z.string().describe("API name"),
34
34
  definition: z.string().describe(
35
- "API definition content (OpenAPI/AsyncAPI specification in JSON or YAML format). Format is automatically detected. API is created with fixed values: version 1.0.0, private visibility, automock disabled, and no project assignment."
35
+ "API definition content (OpenAPI/AsyncAPI specification in JSON or YAML format). Format is automatically detected. On create, fixed values are used: version 1.0.0, private visibility, automock disabled, and no project assignment. On update, the API's existing visibility is preserved."
36
36
  )
37
37
  });
38
38
  const ScanStandardizationParamsSchema = z.object({
@@ -109,7 +109,7 @@ const CreateApiFromPromptOutputSchema = z.looseObject({
109
109
  specType: z.string().optional(),
110
110
  version: z.string().optional(),
111
111
  url: z.string().optional(),
112
- operation: z.enum(["create", "update"]).optional()
112
+ operation: z.literal("create").optional()
113
113
  });
114
114
  const StandardizationErrorSchema = z.object({
115
115
  line: z.number().optional(),
@@ -231,11 +231,11 @@ const TOOLS = [
231
231
  {
232
232
  title: "Create API from Prompt",
233
233
  toolset: "Registry API",
234
- summary: "Generate and save an API definition based on a prompt using SmartBear AI. This tool automatically applies organization governance and standardization rules during API generation. The specType parameter determines the format of the generated definition. Use: 'openapi20' for OpenAPI 2.0, 'openapi30x' for OpenAPI 3.0.x, 'openapi31x' for OpenAPI 3.1.x, 'asyncapi2xx' for AsyncAPI 2.x, 'asyncapi30x' for AsyncAPI 3.0.x. Use this tool when creating APIs that comply with governance policies or when generating APIs from natural language descriptions. Use this tool when users ask to create, generate, or design APIs with governance or standardization requirements. Returns HTTP 201 for creation, HTTP 200 for update. Response includes 'operation' field indicating whether it was a 'create' or 'update' operation along with API details and SwaggerHub URL.",
234
+ summary: "Generate and save a new API or a new version of an existing API based on a prompt using SmartBear AI. This tool automatically applies organization governance and standardization rules during API generation. The specType parameter determines the format of the generated definition. Use: 'openapi20' for OpenAPI 2.0, 'openapi30x' for OpenAPI 3.0.x, 'openapi31x' for OpenAPI 3.1.x, 'asyncapi2xx' for AsyncAPI 2.x, 'asyncapi30x' for AsyncAPI 3.0.x. Use this tool when creating APIs that comply with governance policies or when generating APIs from natural language descriptions. Use this tool when users ask to create, generate, or design APIs with governance or standardization requirements. Fails with a conflict error if the API version already exists. Returns API details and SwaggerHub URL.",
235
235
  inputSchema: CreateApiFromPromptParamsSchema,
236
236
  outputSchema: CreateApiFromPromptOutputSchema,
237
237
  handler: "createApiFromPrompt",
238
- ...WRITE_DESTRUCTIVE,
238
+ ...WRITE,
239
239
  openWorld: true
240
240
  },
241
241
  {
@@ -3,6 +3,7 @@ import { getRequestHeader } from "../common/request-context.js";
3
3
  import { ApiClient } from "./common/api-client.js";
4
4
  import { GetEnvironments } from "./tool/environment/get-environments.js";
5
5
  import { CreateFolder } from "./tool/folder/create-folder.js";
6
+ import { GetFolders } from "./tool/folder/get-folders.js";
6
7
  import { GetTestCases as GetTestCases$1 } from "./tool/issue-link/get-test-cases.js";
7
8
  import { GetTestCycles as GetTestCycles$1 } from "./tool/issue-link/get-test-cycles.js";
8
9
  import { GetTestExecutions as GetTestExecutions$1 } from "./tool/issue-link/get-test-executions.js";
@@ -98,6 +99,7 @@ class ZephyrClient {
98
99
  new CreateTestSteps(this),
99
100
  new CreateTestCaseIssueLink(this),
100
101
  new CreateTestCycleIssueLink(this),
102
+ new GetFolders(this),
101
103
  new CreateFolder(this),
102
104
  new CreateTestScript(this),
103
105
  new UpdateTestExecution(this),