@smartbear/mcp 0.38.0 → 0.40.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 (42) hide show
  1. package/dist/package.json.js +1 -1
  2. package/dist/pactflow/client/admin-api.js +491 -0
  3. package/dist/pactflow/client/ai-api.js +139 -0
  4. package/dist/pactflow/client/contract-api.js +366 -0
  5. package/dist/pactflow/client/environment-api.js +156 -0
  6. package/dist/pactflow/client/http-client.js +47 -0
  7. package/dist/pactflow/client/pacticipant-api.js +288 -0
  8. package/dist/pactflow/client/webhook-api.js +113 -0
  9. package/dist/pactflow/client.js +29 -1967
  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 +56 -27
  34. package/dist/swagger/client/functional-testing-tools.js +5 -5
  35. package/dist/swagger/client/functional-testing-types.js +75 -9
  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/package.json +1 -1
@@ -1,7 +1,15 @@
1
1
  import { appendClientIdentity } from "../../common/info.js";
2
2
  import { ToolError } from "../../common/tools.js";
3
+ import { applyBaseUrlTemplating } from "./functional-testing-url-utils.js";
3
4
  const API_HOSTNAME = "api.reflect.run";
4
5
  const FUNCTIONAL_TESTING_API_KEY_HEADER = "X-API-KEY";
6
+ function renameSuiteIdToSlug(data) {
7
+ if ("suiteId" in data) {
8
+ const { suiteId, ...rest } = data;
9
+ return { ...rest, slug: suiteId };
10
+ }
11
+ return data;
12
+ }
5
13
  class FunctionalTestingAPI {
6
14
  constructor(getToken, userAgent, baseUrl) {
7
15
  this.getToken = getToken;
@@ -54,15 +62,20 @@ class FunctionalTestingAPI {
54
62
  return response;
55
63
  }
56
64
  async createTest(args) {
57
- const {
58
- type: _type,
59
- steps,
60
- ...rest
61
- } = args;
62
- const sanitizedSteps = steps?.map((step) => {
63
- const { type: _stepType, ...stepRest } = step;
64
- return { ...stepRest, type: "api" };
65
- });
65
+ const { steps, parameters, ...rest } = args;
66
+ let templatedSteps;
67
+ let mergedParameters;
68
+ try {
69
+ ({ steps: templatedSteps, parameters: mergedParameters } = applyBaseUrlTemplating(steps, parameters));
70
+ } catch (error) {
71
+ throw new ToolError(
72
+ error instanceof Error ? error.message : String(error)
73
+ );
74
+ }
75
+ const sanitizedSteps = templatedSteps?.map((step) => ({
76
+ ...step,
77
+ type: "api"
78
+ }));
66
79
  const response = await this.ftFetch(
67
80
  `tests`,
68
81
  {
@@ -71,7 +84,8 @@ class FunctionalTestingAPI {
71
84
  body: JSON.stringify({
72
85
  ...rest,
73
86
  type: "api",
74
- steps: sanitizedSteps
87
+ steps: sanitizedSteps,
88
+ ...mergedParameters.length > 0 ? { parameters: mergedParameters } : {}
75
89
  })
76
90
  },
77
91
  errorMessageFor(`create Functional Testing test`)
@@ -125,9 +139,9 @@ class FunctionalTestingAPI {
125
139
  return data;
126
140
  }
127
141
  async listSuiteExecutions(args) {
128
- if (!args.suiteId) throw new ToolError("suiteId argument is required");
142
+ if (!args.slug) throw new ToolError("slug argument is required");
129
143
  const response = await this.ftFetch(
130
- `suites/${encodeURIComponent(args.suiteId)}/executions`,
144
+ `suites/${encodeURIComponent(args.slug)}/executions`,
131
145
  {
132
146
  method: "GET",
133
147
  headers: this.getFtHeaders()
@@ -135,12 +149,12 @@ class FunctionalTestingAPI {
135
149
  handleStatus(
136
150
  /* @__PURE__ */ new Map([
137
151
  // Defensive: the Reflect API currently returns 200 with an empty
138
- // `executions.data` list for an unknown suiteId rather than a 404, so this
152
+ // `executions.data` list for an unknown slug rather than a 404, so this
139
153
  // branch is not expected to fire today. Kept in case the API starts
140
154
  // returning 404 for missing suites.
141
155
  [
142
156
  404,
143
- "Test suite not found. Verify the suiteId is correct and belongs to your workspace."
157
+ "Test suite not found. Verify the slug is correct and belongs to your workspace."
144
158
  ]
145
159
  ]),
146
160
  errorMessageFor("list suite executions")
@@ -148,7 +162,7 @@ class FunctionalTestingAPI {
148
162
  );
149
163
  const data = await response.json();
150
164
  return {
151
- ...data,
165
+ slug: args.slug,
152
166
  executions: {
153
167
  data: data.executions.data.map(
154
168
  ({ executionId, status, isFinished, url }) => ({
@@ -175,7 +189,11 @@ class FunctionalTestingAPI {
175
189
  },
176
190
  errorMessageFor("create Functional Testing suite")
177
191
  );
178
- return response.json();
192
+ const data = await response.json();
193
+ return {
194
+ slug: data.slug,
195
+ url: data.url
196
+ };
179
197
  }
180
198
  async listSuites() {
181
199
  const response = await this.ftFetch(
@@ -186,15 +204,22 @@ class FunctionalTestingAPI {
186
204
  },
187
205
  errorMessageFor("list Functional Testing suites")
188
206
  );
189
- return response.json();
207
+ const data = await response.json();
208
+ return {
209
+ suites: data.suites.data.map(({ name, suiteId, created }) => ({
210
+ name,
211
+ slug: suiteId,
212
+ created
213
+ }))
214
+ };
190
215
  }
191
216
  async cancelSuiteExecution(args) {
192
- if (!args.suiteId) throw new ToolError("suiteId argument is required");
217
+ if (!args.slug) throw new ToolError("slug argument is required");
193
218
  if (!args.executionId) {
194
219
  throw new ToolError("executionId argument is required");
195
220
  }
196
221
  const response = await this.ftFetch(
197
- `suites/${encodeURIComponent(args.suiteId)}/executions/${encodeURIComponent(args.executionId)}/cancel`,
222
+ `suites/${encodeURIComponent(args.slug)}/executions/${encodeURIComponent(args.executionId)}/cancel`,
198
223
  {
199
224
  method: "PATCH",
200
225
  headers: this.getFtHeaders()
@@ -203,7 +228,7 @@ class FunctionalTestingAPI {
203
228
  /* @__PURE__ */ new Map([
204
229
  [
205
230
  404,
206
- "Suite execution not found. Verify the suiteId and executionId are correct and belong to your workspace."
231
+ "Suite execution not found. Verify the slug and executionId are correct and belong to your workspace."
207
232
  ],
208
233
  [
209
234
  409,
@@ -213,15 +238,17 @@ class FunctionalTestingAPI {
213
238
  errorMessageFor("cancel suite execution")
214
239
  )
215
240
  );
216
- return response.json();
241
+ return renameSuiteIdToSlug(
242
+ await response.json()
243
+ );
217
244
  }
218
245
  async runSuite(args) {
219
- if (!args.suiteId) throw new ToolError("suiteId argument is required");
246
+ if (!args.slug) throw new ToolError("slug argument is required");
220
247
  const body = args.tunnelAgentName ? JSON.stringify({
221
248
  overrides: { agent: { name: args.tunnelAgentName } }
222
249
  }) : void 0;
223
250
  const response = await this.ftFetch(
224
- `suites/${args.suiteId}/executions`,
251
+ `suites/${args.slug}/executions`,
225
252
  {
226
253
  method: "POST",
227
254
  headers: this.getFtHeaders(),
@@ -229,15 +256,17 @@ class FunctionalTestingAPI {
229
256
  },
230
257
  errorMessageFor("run suite")
231
258
  );
232
- return response.json();
259
+ return renameSuiteIdToSlug(
260
+ await response.json()
261
+ );
233
262
  }
234
263
  async getSuiteExecution(args) {
235
- if (!args.suiteId) throw new ToolError("suiteId argument is required");
264
+ if (!args.slug) throw new ToolError("slug argument is required");
236
265
  if (!args.executionId) {
237
266
  throw new ToolError("executionId argument is required");
238
267
  }
239
268
  const response = await this.ftFetch(
240
- `suites/${args.suiteId}/executions/${args.executionId}`,
269
+ `suites/${args.slug}/executions/${args.executionId}`,
241
270
  {
242
271
  method: "GET",
243
272
  headers: this.getFtHeaders()
@@ -255,7 +284,7 @@ class FunctionalTestingAPI {
255
284
  }
256
285
  }
257
286
  }
258
- return data;
287
+ return renameSuiteIdToSlug(data);
259
288
  }
260
289
  async getTestHistory(args) {
261
290
  if (!args.testId) throw new ToolError("testId argument is required");
@@ -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",
@@ -59,7 +59,7 @@ const FUNCTIONAL_TESTING_TOOLS = [
59
59
  {
60
60
  title: "Create Suite",
61
61
  toolset: "Functional Testing",
62
- summary: "Creates a new test suite in your Swagger Functional Testing workspace with a specified name and `runApiTests`, one or more required ordered blocks of tests. Use this tool when you need to group existing tests into a suite for collective execution. Within a block, tests run sequentially by default — set `parallel: true` on a block to run its tests in parallel instead. Blocks themselves always run one after another. Set `maxRetryAttempts` (0-3) on a block to automatically retry its failed tests before they count as failed. Optionally accepts `agentName` to save a tunnel agent override for future runs of the suite.",
62
+ summary: "Creates a new test suite in your Swagger Functional Testing workspace with a specified name and `runApiTests`, one or more required ordered blocks of tests. Use this tool when you need to group existing tests into a suite for collective execution. Within a block, tests run sequentially by default — set `parallel: true` on a block to run its tests in parallel instead. Blocks themselves always run one after another. Set `maxRetryAttempts` (0-3) on a block to automatically retry its failed tests before they count as failed. Optionally accepts `agentName` to save a tunnel agent override for future runs of the suite. Returns `slug`, which identifies the suite for other suite tools (e.g. `swagger_run_suite`).",
63
63
  inputSchema: CreateFunctionalTestingSuiteParamsSchema,
64
64
  outputSchema: CreateFunctionalTestingSuiteResponseSchema,
65
65
  handler: "createFunctionalTestingSuite",
@@ -69,7 +69,7 @@ const FUNCTIONAL_TESTING_TOOLS = [
69
69
  {
70
70
  title: "List Suites",
71
71
  toolset: "Functional Testing",
72
- summary: "Lists all test suites available in your Swagger Functional Testing workspace. Use this tool when you need to discover available suites before running them or checking their execution history. Do not use this tool to retrieve individual tests or test suite execution results.",
72
+ summary: "Lists all test suites available in your Swagger Functional Testing workspace. Use this tool when you need to discover available suites before running them or checking their execution history. Each suite's `slug` identifies it for other suite tools (e.g. `swagger_run_suite`). Do not use this tool to retrieve individual tests or test suite execution results.",
73
73
  handler: "listFunctionalTestingSuites",
74
74
  idempotent: true,
75
75
  ...READ_ONLY
@@ -77,7 +77,7 @@ const FUNCTIONAL_TESTING_TOOLS = [
77
77
  {
78
78
  title: "Run Suite",
79
79
  toolset: "Functional Testing",
80
- summary: "Runs a specific test suite in your Swagger Functional Testing workspace. The execution is asynchronous — it returns an executionId, not results directly. Use `swagger_get_suite_status` with your suiteId and executionId to track progress and retrieve the final per-test results. Optionally accepts a `tunnelAgentName` argument to override the suite's saved tunnel for this run. Do not use this tool to run a single test — use `swagger_run_test` instead.",
80
+ summary: "Runs a specific test suite in your Swagger Functional Testing workspace. The execution is asynchronous — it returns an executionId, not results directly. Use `swagger_get_suite_status` with your slug and executionId to track progress and retrieve the final per-test results. Optionally accepts a `tunnelAgentName` argument to override the suite's saved tunnel for this run. Do not use this tool to run a single test — use `swagger_run_test` instead.",
81
81
  inputSchema: RunFunctionalTestingSuiteParamsSchema,
82
82
  handler: "runFunctionalTestingSuite",
83
83
  ...WRITE,
@@ -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 both `suiteId` and the `executionId` arguments 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. 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`.",
91
91
  inputSchema: GetFunctionalTestingSuiteExecutionSchema,
92
92
  handler: "getFunctionalTestingSuiteExecution",
93
93
  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
  });
@@ -6,10 +7,10 @@ const GetFunctionalTestingExecutionTestSchema = z.object({
6
7
  executionId: z.string().describe("ID of the Functional Testing execution").trim().min(1)
7
8
  });
8
9
  const ListFunctionalTestingSuiteExecutionsSchema = z.object({
9
- suiteId: z.string().describe("ID of the Functional Testing suite to list executions for").trim().min(1)
10
+ slug: z.string().describe("Slug of the Functional Testing suite to list executions for.").trim().min(1)
10
11
  });
11
12
  const CancelFunctionalTestingSuiteExecutionSchema = z.object({
12
- suiteId: z.string().describe("ID of the Functional Testing suite the execution belongs to").trim().min(1),
13
+ slug: z.string().describe("Slug of the Functional Testing suite the execution belongs to.").trim().min(1),
13
14
  executionId: z.string().describe("ID of the Functional Testing suite execution to cancel").trim().min(1)
14
15
  });
15
16
  const RunApiTestsBlockSchema = z.object({
@@ -25,7 +26,9 @@ const RunApiTestsBlockSchema = z.object({
25
26
  )
26
27
  });
27
28
  const CreateFunctionalTestingSuiteParamsSchema = z.object({
28
- name: z.string().describe("Name for the new suite").trim().min(1),
29
+ name: z.string().describe(
30
+ "Name for the new suite. Use the name explicitly provided by the user, or if none was given, a descriptive name derived from the purpose or context of the tests being grouped into this suite. This must be a human-readable name, not a numeric ID or test ID."
31
+ ).trim().min(1),
29
32
  agentName: z.string().trim().min(1).optional().describe(
30
33
  "Tunnel agent name to save as this suite's tunnel override for future runs."
31
34
  ),
@@ -47,18 +50,19 @@ const CreateFunctionalTestingSuiteParamsSchema = z.object({
47
50
  });
48
51
  });
49
52
  const CreateFunctionalTestingSuiteResponseSchema = z.object({
50
- id: z.number().describe("ID of the newly created suite"),
51
- slug: z.string().describe("Slug of the newly created suite"),
53
+ slug: z.string().describe(
54
+ "Slug of the newly created suite. Use this value as the `slug` argument for other Functional Testing suite tools (e.g. `swagger_run_suite`)."
55
+ ),
52
56
  url: z.string().describe("Link to the created suite in Swagger Functional Testing UI")
53
57
  });
54
58
  const RunFunctionalTestingSuiteParamsSchema = z.object({
55
- suiteId: z.string().describe("ID of the Functional Testing suite to run").trim().min(1),
59
+ slug: z.string().describe("Slug of the Functional Testing suite to run.").trim().min(1),
56
60
  tunnelAgentName: z.string().describe(
57
61
  "Optional tunnel agent name to override the suite's saved tunnel for this run. When omitted, the suite's saved tunnel overrides are used, falling back to each test's saved tunnel."
58
62
  ).trim().min(1).optional()
59
63
  });
60
64
  const GetFunctionalTestingSuiteExecutionSchema = z.object({
61
- suiteId: z.string().describe("ID of the Functional Testing suite").trim().min(1),
65
+ slug: z.string().describe("Slug of the Functional Testing suite.").trim().min(1),
62
66
  executionId: z.string().describe("ID of the Functional Testing suite execution").trim().min(1)
63
67
  });
64
68
  const GetFunctionalTestHistoryParamsSchema = z.object({
@@ -248,8 +252,20 @@ const CreateFunctionalTestingAssertionsSchema = z.object({
248
252
  bodyType: z.enum(["json", "xml"]).optional().describe('Response body format, defaults to "json"'),
249
253
  bodyRules: z.array(CreateFunctionalTestingBodyRuleSchema).optional().describe("Assertion rules evaluated against the response body")
250
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
+ });
251
259
  const CreateFunctionalTestingTestStepSchema = z.object({
252
- 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
+ ),
253
269
  httpMethod: z.enum(HTTP_METHODS).describe("HTTP method for the API call (defaults to GET server-side)").optional(),
254
270
  requestBody: z.string().describe("Request body").optional(),
255
271
  requestHeaders: z.array(CreateFunctionalTestingTestHeaderSchema).describe("HTTP headers").optional(),
@@ -262,7 +278,56 @@ const CreateFunctionalTestingTestStepSchema = z.object({
262
278
  const CreateFunctionalTestingTestParamsSchema = z.object({
263
279
  name: z.string().describe("Name for the new test").trim().min(1),
264
280
  description: z.string().trim().describe("Optional description for the test").optional(),
265
- 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
+ });
266
331
  });
267
332
  const CreateFunctionalTestingTestResponseSchema = z.object({
268
333
  id: z.number().describe("ID of the newly created test"),
@@ -278,6 +343,7 @@ export {
278
343
  CreateFunctionalTestingSuiteParamsSchema,
279
344
  CreateFunctionalTestingSuiteResponseSchema,
280
345
  CreateFunctionalTestingTestHeaderSchema,
346
+ CreateFunctionalTestingTestParameterSchema,
281
347
  CreateFunctionalTestingTestParamsSchema,
282
348
  CreateFunctionalTestingTestResponseSchema,
283
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),