@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
@@ -34,7 +34,6 @@ const SkipWarningEnum = z.enum(["0", "1"]);
34
34
  const CommonFields = {
35
35
  projectKey: z.string().describe("Project key - unique identifier for the project").default(QMETRY_DEFAULTS.PROJECT_KEY),
36
36
  projectKeyOptional: z.string().optional().describe("Project key - unique identifier for the project").default(QMETRY_DEFAULTS.PROJECT_KEY),
37
- baseUrl: z.string().url().optional().describe("The base URL for the QMetry instance (must be a valid URL)"),
38
37
  start: z.number().optional().describe("Start index for pagination - defaults to 0").default(0),
39
38
  page: z.number().optional().describe("Page number to return (starts from 1)").default(1),
40
39
  limit: z.number().optional().describe("Number of records (default 10).").default(10),
@@ -60,10 +59,10 @@ const CommonFields = {
60
59
  "Requirement version number (required for fetching specific requirement version details). This is the internal numeric identifier for the version."
61
60
  ),
62
61
  tcViewId: z.number().optional().describe(
63
- "ViewId for test cases - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.TC.viewId automatically. Manual viewId only needed if you want to override the automatic resolution."
62
+ "ViewId for test cases - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.TC.viewId automatically."
64
63
  ),
65
64
  rqViewId: z.number().optional().describe(
66
- "ViewId for requirements - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.RQ.viewId automatically. Manual viewId only needed if you want to override the automatic resolution."
65
+ "ViewId for requirements - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.RQ.viewId automatically."
67
66
  ),
68
67
  rqFolderPath: z.string().optional().describe(
69
68
  'Folder path for requirements - SYSTEM AUTOMATICALLY SETS TO ROOT. Leave empty unless you want specific folder. System will automatically use empty string "" (root directory). Only specify if user wants specific folder like "Automation/Regression".'
@@ -85,13 +84,13 @@ const CommonFields = {
85
84
  ),
86
85
  gridName: z.string().optional().describe("Grid Name to be displayed (default 'TESTEXECUTIONLIST')"),
87
86
  teViewId: z.number().optional().describe(
88
- "ViewId for test execution - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.TE.viewId automatically. Manual viewId only needed if you want to override the automatic resolution."
87
+ "ViewId for test execution - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.TE.viewId automatically."
89
88
  ),
90
89
  tsfeViewId: z.number().optional().describe(
91
- "ViewId for test suite folders - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.TSFS.viewId automatically. Manual viewId only needed if you want to override the automatic resolution."
90
+ "ViewId for test suite folders - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.TSFS.viewId automatically."
92
91
  ),
93
92
  tsViewId: z.number().optional().describe(
94
- "ViewId for test suites - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.TS.viewId automatically. Manual viewId only needed if you want to override the automatic resolution."
93
+ "ViewId for test suites - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.TS.viewId automatically."
95
94
  ),
96
95
  tsrunID: z.coerce.string().describe(
97
96
  "Test Suite Run ID. CRITICAL: the parameter name is 'tsrunID' — do NOT use 'testSuiteRunId', 'tsRunID', 'testSuiteRunID', or any other variant. Accepts a string or number (e.g. 731600 or '731600' — both are valid). To get this value: Call 'Fetch Executions by Test Suite' → use data[<index>].tsRunID from the response."
@@ -125,7 +124,6 @@ const CommonFields = {
125
124
  };
126
125
  const ProjectListArgsSchema = z.object({
127
126
  projectKey: CommonFields.projectKeyOptional,
128
- baseUrl: CommonFields.baseUrl,
129
127
  params: z.object({
130
128
  showArchive: z.boolean().optional().describe(
131
129
  "Whether to include archived records in the results. When true, returns both active and archived items. When false, returns only active (non-archived) items. "
@@ -145,7 +143,6 @@ const ReleasesCyclesArgsSchema = z.object({
145
143
  });
146
144
  const BuildArgsSchema = z.object({
147
145
  projectKey: CommonFields.projectKeyOptional,
148
- baseUrl: CommonFields.baseUrl,
149
146
  start: CommonFields.start,
150
147
  page: CommonFields.page,
151
148
  limit: CommonFields.limit,
@@ -153,7 +150,6 @@ const BuildArgsSchema = z.object({
153
150
  });
154
151
  const PlatformArgsSchema = z.object({
155
152
  projectKey: CommonFields.projectKeyOptional,
156
- baseUrl: CommonFields.baseUrl,
157
153
  start: CommonFields.start,
158
154
  page: CommonFields.page,
159
155
  limit: CommonFields.limit,
@@ -164,7 +160,6 @@ const PlatformArgsSchema = z.object({
164
160
  });
165
161
  const CreateReleaseArgsSchema = z.object({
166
162
  projectKey: CommonFields.projectKeyOptional,
167
- baseUrl: CommonFields.baseUrl,
168
163
  release: z.object({
169
164
  name: z.string().describe("Release name (required)"),
170
165
  description: z.string().optional().describe("Release description"),
@@ -186,7 +181,6 @@ const CreateReleaseArgsSchema = z.object({
186
181
  });
187
182
  const CreateCycleArgsSchema = z.object({
188
183
  projectKey: CommonFields.projectKeyOptional,
189
- baseUrl: CommonFields.baseUrl,
190
184
  cycle: z.object({
191
185
  name: z.string().describe("Cycle name (required)"),
192
186
  startDate: z.string().optional().describe(
@@ -203,7 +197,6 @@ const CreateCycleArgsSchema = z.object({
203
197
  });
204
198
  const UpdateCycleArgsSchema = z.object({
205
199
  projectKey: CommonFields.projectKeyOptional,
206
- baseUrl: CommonFields.baseUrl,
207
200
  cycle: z.object({
208
201
  name: z.string().optional().describe("Cycle name (optional for update)"),
209
202
  startDate: z.string().optional().describe(
@@ -290,8 +283,11 @@ const CreateTestCaseArgsSchema = z.object({
290
283
  tcFolderID: z.string().optional().describe(
291
284
  "Test Case folder ID - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific folder ID. System will fetch project info using the projectKey and extract rootFolders.TC.id automatically. Manual folder ID only needed if you want to target a specific sub-folder."
292
285
  ),
293
- steps: z.array(CreateTestCaseStepSchema).optional().describe(
294
- "STEPS INCLUSION RULE — read before deciding whether to include this field:\n\nDEFAULT BEHAVIOR: OMIT 'steps' entirely from the payload. Do NOT include steps: [] (empty array).\nA test case without steps is valid and is the normal case when the user did not mention steps.\n\nINCLUDE 'steps' ONLY in these two scenarios:\n SCENARIO 1 — User explicitly mentions steps in their prompt.\n Examples: 'create test case with steps', 'step 1: open browser, step 2: click login',\n 'add these steps: ...', 'include steps', 'create with following steps'.\n When user provides step text, parse each step into { orderId, description, inputData?, expectedOutcome? }.\n\n SCENARIO 2 — Any field in 'stepSystemFields' OR 'stepFields' from Fetch UDF Layout has isMandatory=true.\n stepSystemFields = built-in step fields (description, expectedOutcome, etc.).\n stepFields = step-level UDF fields (custom fields configured per project).\n If EITHER array has isMandatory=true on any entry, the backend REQUIRES at least 1 step.\n In this case you MUST include at least 1 step even if the user did not mention steps.\n Also fill mandatory step UDF fields from stepFields in step.UDF — use stepDefaultValues if defaults exist, else placeholder.\n Ask the user for step content OR create a placeholder step with description='Step 1'.\n\nNEVER include 'steps' in any other scenario — omitting it keeps the payload clean and avoids BE errors.\nNEVER send steps: [] (empty array) — either omit the field or send at least 1 valid step object.\n\nStep object fields:\n orderId (required): sequential integer starting at 1\n description (required): step action text\n inputData (optional): test data for this step\n expectedOutcome (optional): what should happen after this step\n UDF (optional): step-level custom fields\n tcStepID (omit on create — only used when updating existing steps)"
286
+ skipSteps: z.boolean().optional().describe(
287
+ "Set to true ONLY when the user explicitly says they do NOT want steps created (e.g. 'create test case without steps', 'no steps', 'skip steps'). When true, the 'steps' field must be omitted entirely. When false or absent (the default), steps MUST always be included — auto-generate them from context if the user did not provide them."
288
+ ),
289
+ steps: z.array(CreateTestCaseStepSchema).min(1).optional().describe(
290
+ "STEPS RULE — include this field unless the user explicitly says NOT to create steps.\n\nNEVER send steps: [] (empty array) — always send at least 1 valid step object.\nOmit this field entirely (and set skipSteps: true) ONLY when the user explicitly asks to skip steps.\n\nHOW TO POPULATE:\n - If user explicitly provides steps: parse each step into { orderId, description, inputData?, expectedOutcome? }.\n - If user does NOT provide steps (and did not say to skip them): auto-generate meaningful steps based on the test case name, description, and context.\n Use your knowledge to infer 2-5 logical, realistic steps for the feature or flow being tested.\n Example: name='Login Test Case' → [{orderId:1, description:'Navigate to login page'}, {orderId:2, description:'Enter credentials'}, {orderId:3, description:'Submit and verify success'}]\n - If user explicitly said NOT to create steps: omit this field and set skipSteps: true.\n\nSTEP DEFAULT VALUES:\n After building the steps array, check 'stepDefaultValues' from Fetch UDF Layout.\n stepDefaultValues shape: { fieldName: defaultValue }\n For each step: for each key in stepDefaultValues, if the user did NOT explicitly provide a value for that field → add it to step.UDF with the default value.\n Auto-apply silently — do NOT ask the user.\n\nStep object fields:\n orderId (required): sequential integer starting at 1\n description (required): step action text\n inputData (optional): test data for this step\n expectedOutcome (optional): what should happen after this step\n UDF (optional): step-level custom fields — auto-fill defaults from stepDefaultValues\n tcStepID (omit on create — only used when updating existing steps)"
295
291
  ),
296
292
  name: z.string(),
297
293
  priority: z.number().optional(),
@@ -318,7 +314,6 @@ const CreateTestCaseArgsSchema = z.object({
318
314
  });
319
315
  const UpdateTestCaseArgsSchema = z.object({
320
316
  projectKey: CommonFields.projectKeyOptional,
321
- baseUrl: CommonFields.baseUrl,
322
317
  tcID: CommonFields.tcID,
323
318
  tcVersionID: CommonFields.tcVersionID,
324
319
  tcVersion: z.number().optional().describe(
@@ -363,7 +358,6 @@ const UpdateTestCaseArgsSchema = z.object({
363
358
  });
364
359
  const TestCaseListArgsSchema = z.object({
365
360
  projectKey: CommonFields.projectKeyOptional,
366
- baseUrl: CommonFields.baseUrl,
367
361
  viewId: CommonFields.tcViewId,
368
362
  folderPath: CommonFields.tcFolderPath,
369
363
  folderID: CommonFields.folderID,
@@ -382,7 +376,6 @@ const TestCaseListArgsSchema = z.object({
382
376
  });
383
377
  const TestCaseDetailsArgsSchema = z.object({
384
378
  projectKey: CommonFields.projectKeyOptional,
385
- baseUrl: CommonFields.baseUrl,
386
379
  tcID: CommonFields.tcID,
387
380
  start: CommonFields.start,
388
381
  page: CommonFields.page,
@@ -390,14 +383,12 @@ const TestCaseDetailsArgsSchema = z.object({
390
383
  });
391
384
  const TestCaseVersionDetailsArgsSchema = z.object({
392
385
  projectKey: CommonFields.projectKeyOptional,
393
- baseUrl: CommonFields.baseUrl,
394
386
  id: CommonFields.id,
395
387
  version: CommonFields.version,
396
388
  scope: CommonFields.scope
397
389
  });
398
390
  const TestCaseStepsArgsSchema = z.object({
399
391
  projectKey: CommonFields.projectKeyOptional,
400
- baseUrl: CommonFields.baseUrl,
401
392
  id: CommonFields.id,
402
393
  version: CommonFields.versionOptional,
403
394
  start: CommonFields.start,
@@ -406,7 +397,6 @@ const TestCaseStepsArgsSchema = z.object({
406
397
  });
407
398
  const TestCaseStepsWithUdfArgsSchema = z.object({
408
399
  projectKey: CommonFields.projectKeyOptional,
409
- baseUrl: CommonFields.baseUrl,
410
400
  tcID: CommonFields.tcID,
411
401
  viewId: CommonFields.tcViewId,
412
402
  version: CommonFields.versionOptional,
@@ -416,7 +406,6 @@ const TestCaseStepsWithUdfArgsSchema = z.object({
416
406
  });
417
407
  const TestCaseExecutionsArgsSchema = z.object({
418
408
  projectKey: CommonFields.projectKeyOptional,
419
- baseUrl: CommonFields.baseUrl,
420
409
  tcid: CommonFields.tcID,
421
410
  tcversion: CommonFields.versionOptional,
422
411
  start: CommonFields.start,
@@ -427,7 +416,6 @@ const TestCaseExecutionsArgsSchema = z.object({
427
416
  });
428
417
  const RequirementListArgsSchema = z.object({
429
418
  projectKey: CommonFields.projectKeyOptional,
430
- baseUrl: CommonFields.baseUrl,
431
419
  viewId: CommonFields.rqViewId,
432
420
  folderPath: CommonFields.rqFolderPath,
433
421
  start: CommonFields.start,
@@ -448,13 +436,58 @@ const RequirementListArgsSchema = z.object({
448
436
  });
449
437
  const RequirementDetailsArgsSchema = z.object({
450
438
  projectKey: CommonFields.projectKeyOptional,
451
- baseUrl: CommonFields.baseUrl,
452
439
  id: CommonFields.rqID,
453
440
  version: CommonFields.rqVersion
454
441
  });
442
+ const RequirementAttachmentsSchema = z.object({
443
+ ADD: z.array(z.unknown()).describe("Attachments to add."),
444
+ REMOVE: z.array(z.unknown()).describe("Attachments to remove.")
445
+ }).optional().describe(
446
+ "Attachment changes. ADD and REMOVE are both required arrays (use empty arrays for no change)."
447
+ );
448
+ const CreateRequirementArgsSchema = z.object({
449
+ name: z.string().describe("Requirement name (required)."),
450
+ priority: z.number().optional().describe("Priority ID of the requirement."),
451
+ component: z.array(z.number()).optional().describe("Component (Label) IDs associated with the requirement."),
452
+ requirementOwner: z.number().optional().describe("Owner ID of the requirement."),
453
+ requirementState: z.number().optional().describe("State ID of the requirement."),
454
+ releaseCycleMapping: z.array(
455
+ z.object({
456
+ release: z.number(),
457
+ cycle: z.array(z.number()),
458
+ version: z.number()
459
+ })
460
+ ).optional().describe("Release/cycle mapping for the requirement."),
461
+ description: z.string().optional().describe("Description of the requirement."),
462
+ associateRelCyc: z.boolean().optional().describe("Whether to associate the release/cycle mapping."),
463
+ rqFolderId: z.string().optional().describe(
464
+ "Requirement folder ID - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific folder ID. System will fetch project info using the projectKey and extract rootFolders.RQ.id automatically. Manual folder ID only needed if you want to target a specific sub-folder."
465
+ ),
466
+ scope: z.string().optional().describe("Scope of the requirement, usually 'project'.").default("project"),
467
+ udfFields: UdfFieldsSchema
468
+ });
469
+ const UpdateRequirementArgsSchema = z.object({
470
+ rqId: z.number().describe(
471
+ "Requirement numeric ID (required). This is the internal numeric identifier, not the entity key like 'MAC-RQ-730'."
472
+ ),
473
+ rqVersionId: z.number().describe("Requirement version ID (required for update)."),
474
+ updateWithVersion: z.boolean().optional().describe(
475
+ "Pass 'true' to create a new version of the requirement instead of updating the existing version in place."
476
+ ),
477
+ name: z.string().optional().describe("Name of the requirement."),
478
+ description: z.string().optional().describe("Description of the requirement."),
479
+ component: z.array(z.number()).optional().describe("Component (Label) IDs associated with the requirement."),
480
+ requirementOwner: z.number().optional().describe("Owner ID of the requirement."),
481
+ requirementState: z.number().optional().describe("State ID of the requirement."),
482
+ priority: z.number().optional().describe("Priority ID of the requirement."),
483
+ attachments: RequirementAttachmentsSchema,
484
+ udfFields: UdfFieldsSchema,
485
+ UDF: z.record(z.string(), UdfWrapperFieldSchema).optional().describe(
486
+ "UDF wrapper required for update operations. Keys = UDF field names. Each value must include fieldID and value. Also set matching flat key in udfFields for the LOOKUPLIST Alias display. Example: { custom_text: { fieldID: 1001, value: 'new value' } }"
487
+ )
488
+ });
455
489
  const RequirementsLinkedToTestCaseArgsSchema = z.object({
456
490
  projectKey: CommonFields.projectKeyOptional,
457
- baseUrl: CommonFields.baseUrl,
458
491
  tcID: CommonFields.tcID,
459
492
  getLinked: z.boolean().optional().describe(
460
493
  "True to get only requirements that are linked with this test case, false to get requirements which are not linked with this test case. Defaults to true (get linked requirements)."
@@ -472,9 +505,16 @@ const LinkRequirementToTestCaseArgsSchema = z.object({
472
505
  "Comma-separated values of versionId of the Requirement (e.g. '236124,236125')"
473
506
  )
474
507
  });
508
+ const LinkTestcaseToIssuesArgsSchema = z.object({
509
+ tcID: z.string().describe(
510
+ "EntityKey of the Test Case to link issues to (e.g. '8d7b-TC-63'). CRITICAL: the parameter name is 'tcID' — do NOT use 'testCaseId' or 'tcId'."
511
+ ),
512
+ dfIDs: z.array(z.coerce.number()).describe(
513
+ "Array of numeric defect/issue IDs to link to the test case (e.g. [2039, 2038, 2037])."
514
+ )
515
+ });
475
516
  const TestCasesLinkedToRequirementArgsSchema = z.object({
476
517
  projectKey: CommonFields.projectKeyOptional,
477
- baseUrl: CommonFields.baseUrl,
478
518
  rqID: CommonFields.rqID,
479
519
  getLinked: z.boolean().optional().describe(
480
520
  "True to get only test cases that are linked with this requirement, false to get test cases which are not linked with this requirement. Defaults to true (get linked test cases)."
@@ -539,7 +579,6 @@ const UpdateTestSuiteArgsSchema = z.object({
539
579
  });
540
580
  const TestSuiteListArgsSchema = z.object({
541
581
  projectKey: CommonFields.projectKeyOptional,
542
- baseUrl: CommonFields.baseUrl,
543
582
  viewId: CommonFields.tsViewId,
544
583
  folderPath: CommonFields.tsFolderPath,
545
584
  start: CommonFields.start,
@@ -555,20 +594,17 @@ const TestSuiteListArgsSchema = z.object({
555
594
  });
556
595
  const FetchTestSuiteDetailsArgsSchema = z.object({
557
596
  projectKey: CommonFields.projectKeyOptional,
558
- baseUrl: CommonFields.baseUrl,
559
597
  id: z.number().int().positive().describe("Test Suite ID (numeric ID)"),
560
598
  scope: CommonFields.scope
561
599
  });
562
600
  const FetchIssueDetailsArgsSchema = z.object({
563
601
  projectKey: CommonFields.projectKeyOptional,
564
- baseUrl: CommonFields.baseUrl,
565
602
  defectId: z.number().int().positive().describe(
566
603
  "Issue DefectId (numeric ID) — use data[<index>].id from Fetch Issues/Defects response. The field in the list API response is named 'id', not 'DefectId'."
567
604
  )
568
605
  });
569
606
  const TestSuitesForTestCaseArgsSchema = z.object({
570
607
  projectKey: CommonFields.projectKeyOptional,
571
- baseUrl: CommonFields.baseUrl,
572
608
  tsFolderID: CommonFields.tsFolderID.optional(),
573
609
  viewId: CommonFields.tsfeViewId,
574
610
  start: CommonFields.start,
@@ -597,7 +633,6 @@ const RequirementsLinkedTestCasesToTestSuiteArgsSchema = z.object({
597
633
  }).strip();
598
634
  const IssuesLinkedToTestCaseArgsSchema = z.object({
599
635
  projectKey: CommonFields.projectKeyOptional,
600
- baseUrl: CommonFields.baseUrl,
601
636
  tcID: CommonFields.tcID,
602
637
  getLinked: CommonFields.getLinked.optional().default(true),
603
638
  start: CommonFields.start,
@@ -607,7 +642,6 @@ const IssuesLinkedToTestCaseArgsSchema = z.object({
607
642
  });
608
643
  const TestCasesByTestSuiteArgsSchema = z.object({
609
644
  projectKey: CommonFields.projectKeyOptional,
610
- baseUrl: CommonFields.baseUrl,
611
645
  tsID: CommonFields.tsID,
612
646
  getLinked: CommonFields.getLinked.optional().default(true),
613
647
  start: CommonFields.start,
@@ -617,7 +651,6 @@ const TestCasesByTestSuiteArgsSchema = z.object({
617
651
  });
618
652
  const ExecutionsByTestSuiteArgsSchema = z.object({
619
653
  projectKey: CommonFields.projectKeyOptional,
620
- baseUrl: CommonFields.baseUrl,
621
654
  tsID: CommonFields.tsID,
622
655
  // API payload param - sent in request body (REQUIRED)
623
656
  tsFolderID: CommonFields.tsFolderID.optional(),
@@ -630,7 +663,6 @@ const ExecutionsByTestSuiteArgsSchema = z.object({
630
663
  });
631
664
  const TestCaseRunsByTestSuiteRunArgsSchema = z.object({
632
665
  projectKey: CommonFields.projectKeyOptional,
633
- baseUrl: CommonFields.baseUrl,
634
666
  tsrunID: CommonFields.tsrunID,
635
667
  // API payload param - sent in request body (REQUIRED)
636
668
  viewId: CommonFields.teViewId,
@@ -645,7 +677,6 @@ const TestCaseRunsByTestSuiteRunArgsSchema = z.object({
645
677
  });
646
678
  const LinkedIssuesByTestCaseRunArgsSchema = z.object({
647
679
  projectKey: CommonFields.projectKeyOptional,
648
- baseUrl: CommonFields.baseUrl,
649
680
  entityId: CommonFields.entityId,
650
681
  // API payload param - sent in request body (REQUIRED)
651
682
  getLinked: CommonFields.getLinked,
@@ -658,7 +689,6 @@ const LinkedIssuesByTestCaseRunArgsSchema = z.object({
658
689
  });
659
690
  const CreateIssueArgsSchema = z.object({
660
691
  projectKey: CommonFields.projectKeyOptional,
661
- baseUrl: CommonFields.baseUrl,
662
692
  issueType: z.number().describe("Issue type ID (e.g. Bug, Enhancement, etc.)"),
663
693
  issuePriority: z.number().describe("Issue priority ID (e.g. High, Medium, Low, etc.)"),
664
694
  summary: z.string().describe("Summary or title of the defect/issue"),
@@ -698,9 +728,8 @@ const UpdateIssueArgsSchema = z.object({
698
728
  });
699
729
  const IssuesListArgsSchema = z.object({
700
730
  projectKey: CommonFields.projectKeyOptional,
701
- baseUrl: CommonFields.baseUrl,
702
731
  viewId: z.number().optional().describe(
703
- "ViewId for issues - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.IS.viewId automatically. Manual viewId only needed if you want to override the automatic resolution."
732
+ "ViewId for issues - SYSTEM AUTOMATICALLY RESOLVES THIS. Leave empty unless you have a specific viewId. System will fetch project info using the projectKey and extract latestViews.IS.viewId automatically."
704
733
  ),
705
734
  start: CommonFields.start,
706
735
  page: CommonFields.page,
@@ -713,7 +742,6 @@ const IssuesListArgsSchema = z.object({
713
742
  });
714
743
  const LinkIssuesToTestcaseRunArgsSchema = z.object({
715
744
  projectKey: CommonFields.projectKeyOptional,
716
- baseUrl: CommonFields.baseUrl,
717
745
  issueIds: z.array(z.union([z.string(), z.number()])).describe("ID of issues to be linked to Testcase Run"),
718
746
  tcrId: z.coerce.number().describe(
719
747
  "ID of Testcase Run to link issues with. CRITICAL: parameter name is 'tcrId' — do NOT use 'tcRunId', 'testCaseRunId', or other variants. Accepts a string or number."
@@ -721,7 +749,6 @@ const LinkIssuesToTestcaseRunArgsSchema = z.object({
721
749
  });
722
750
  const IssueExecutionsArgsSchema = z.object({
723
751
  projectKey: CommonFields.projectKeyOptional,
724
- baseUrl: CommonFields.baseUrl,
725
752
  linkedAssetId: z.coerce.number().describe(
726
753
  "Numeric defect ID of the QMetry issue. CRITICAL: parameter name is 'linkedAssetId' — do NOT use 'issueId', 'defectId', 'id', or other variants. Accepts a string or number. To get this ID, call the Fetch Defects or Issues tool and use data[<index>].id from the response."
727
754
  ),
@@ -735,7 +762,6 @@ const IssueExecutionsArgsSchema = z.object({
735
762
  });
736
763
  const LinkPlatformsToTestSuiteArgsSchema = z.object({
737
764
  projectKey: CommonFields.projectKeyOptional,
738
- baseUrl: CommonFields.baseUrl,
739
765
  qmTsId: z.coerce.number().describe(
740
766
  "Id of Test Suite (required). CRITICAL: the parameter name is 'qmTsId' — do NOT use 'tsId', 'testSuiteId', 'tsID', or other variants. Accepts a string or number. To get the qmTsId - Call API 'Testsuite/Fetch Testsuite'. From the response, get value -> data[<index>].id"
741
767
  ),
@@ -745,7 +771,6 @@ const LinkPlatformsToTestSuiteArgsSchema = z.object({
745
771
  });
746
772
  const BulkUpdateExecutionStatusArgsSchema = z.object({
747
773
  projectKey: CommonFields.projectKeyOptional,
748
- baseUrl: CommonFields.baseUrl,
749
774
  entityIDs: z.coerce.string().describe(
750
775
  "Comma-separated IDs of Test Case Runs to update. CRITICAL: the parameter name is 'entityIDs' — do NOT use 'tcRunIDs', 'testCaseRunIds', 'runIds', or other variants. Accepts a number or string (e.g., 66095087 or '66095087' for single, '66095069,66095075' for bulk). To get the entityIDs - Call API 'Execution/Fetch Testcase Run ID'. From the response, get value -> data[<index>].tcRunID"
751
776
  ),
@@ -850,14 +875,12 @@ const ImportAutomationResultsPayloadSchema = z.object({
850
875
  });
851
876
  const FetchAutomationStatusPayloadSchema = z.object({
852
877
  projectKey: CommonFields.projectKeyOptional,
853
- baseUrl: CommonFields.baseUrl,
854
878
  requestID: z.coerce.number().describe(
855
879
  "Numeric request ID from import automation response. CRITICAL: parameter name is 'requestID' — do NOT use 'requestId', 'jobId', or other variants. Accepts a string or number."
856
880
  )
857
881
  });
858
882
  z.object({
859
883
  projectKey: CommonFields.projectKeyOptional,
860
- baseUrl: CommonFields.baseUrl,
861
884
  query: z.string().describe(
862
885
  "SQL query to execute against QMetry analytics. Supports tables like requirements, testcases, testexecutions, testsuites, issues, and their relationship tables (requirementtestcase, testexecutionissue, etc.). Use JOINs to combine data across entities for custom reporting."
863
886
  ),
@@ -872,6 +895,7 @@ export {
872
895
  CreateCycleArgsSchema,
873
896
  CreateIssueArgsSchema,
874
897
  CreateReleaseArgsSchema,
898
+ CreateRequirementArgsSchema,
875
899
  CreateTestCaseArgsSchema,
876
900
  CreateTestCaseStepSchema,
877
901
  CreateTestSuiteArgsSchema,
@@ -892,6 +916,7 @@ export {
892
916
  LinkPlatformsToTestSuiteArgsSchema,
893
917
  LinkRequirementToTestCaseArgsSchema,
894
918
  LinkTestCasesToTestSuiteArgsSchema,
919
+ LinkTestcaseToIssuesArgsSchema,
895
920
  LinkedIssuesByTestCaseRunArgsSchema,
896
921
  PlatformArgsSchema,
897
922
  ProjectArgsSchema,
@@ -915,6 +940,7 @@ export {
915
940
  TestSuitesForTestCaseArgsSchema,
916
941
  UpdateCycleArgsSchema,
917
942
  UpdateIssueArgsSchema,
943
+ UpdateRequirementArgsSchema,
918
944
  UpdateTestCaseArgsSchema,
919
945
  UpdateTestCaseRemoveStepSchema,
920
946
  UpdateTestSuiteArgsSchema
@@ -22,8 +22,14 @@ const DEFAULT_FETCH_REQUIREMENTS_LINKED_TO_TESTCASE_PAYLOAD = {
22
22
  getLinked: true,
23
23
  rqFolderPath: ""
24
24
  };
25
+ const DEFAULT_CREATE_REQUIREMENT_PAYLOAD = {
26
+ scope: "project"
27
+ };
28
+ const DEFAULT_UPDATE_REQUIREMENT_PAYLOAD = {};
25
29
  export {
30
+ DEFAULT_CREATE_REQUIREMENT_PAYLOAD,
26
31
  DEFAULT_FETCH_REQUIREMENTS_LINKED_TO_TESTCASE_PAYLOAD,
27
32
  DEFAULT_FETCH_REQUIREMENTS_PAYLOAD,
28
- DEFAULT_FETCH_REQUIREMENT_DETAILS_PAYLOAD
33
+ DEFAULT_FETCH_REQUIREMENT_DETAILS_PAYLOAD,
34
+ DEFAULT_UPDATE_REQUIREMENT_PAYLOAD
29
35
  };
@@ -11,7 +11,8 @@ const DEFAULT_FETCH_TESTCASES_PAYLOAD = {
11
11
  isFilterSaveRequired: false
12
12
  };
13
13
  const DEFAULT_CREATE_TESTCASES_PAYLOAD = {
14
- scope: "project"
14
+ scope: "project",
15
+ steps: []
15
16
  };
16
17
  const DEFAULT_UPDATE_TESTCASES_PAYLOAD = {};
17
18
  const DEFAULT_FETCH_TESTCASE_DETAILS_PAYLOAD = {
@@ -1,12 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import { CommonFields } from "./common.js";
3
3
  z.object({
4
- projectKey: CommonFields.projectKey,
5
- baseUrl: CommonFields.baseUrl
4
+ projectKey: CommonFields.projectKey
6
5
  });
7
6
  z.object({
8
- projectKey: CommonFields.projectKeyOptional,
9
- baseUrl: CommonFields.baseUrl
7
+ projectKey: CommonFields.projectKeyOptional
10
8
  });
11
9
  const UdfFieldValueSchema = z.object({
12
10
  fieldID: z.number().int().positive().describe(
@@ -29,7 +27,6 @@ const UdfFieldValueSchema = z.object({
29
27
  });
30
28
  const BulkUpdateTestRunUdfsArgsSchema = z.object({
31
29
  projectKey: CommonFields.projectKeyOptional,
32
- baseUrl: CommonFields.baseUrl,
33
30
  tcRunIDs: z.array(z.number().int().positive()).min(1).describe(
34
31
  "Array of Test Case Run IDs to update UDF values for. To get tcRunIDs — Call 'Fetch Test Case Runs by Test Suite Run' tool. From the response, get value of data[<index>].tcRunID. Example: [41572006, 41572009, 41572013]"
35
32
  ),
@@ -38,12 +35,10 @@ const BulkUpdateTestRunUdfsArgsSchema = z.object({
38
35
  )
39
36
  });
40
37
  const FetchTestRunUdfMetadataArgsSchema = z.object({
41
- projectKey: CommonFields.projectKeyOptional,
42
- baseUrl: CommonFields.baseUrl
38
+ projectKey: CommonFields.projectKeyOptional
43
39
  });
44
40
  const FetchCascadeChildValuesArgsSchema = z.object({
45
41
  projectKey: CommonFields.projectKeyOptional,
46
- baseUrl: CommonFields.baseUrl,
47
42
  id: z.number().int().positive().describe(
48
43
  "Numeric ID of the parent cascade list item to fetch child values for. Get this from the 'lookupOptions' returned by 'Fetch Test Run UDF Metadata' for a CASCADINGLIST field — each option has an 'id' field."
49
44
  ),
@@ -53,9 +48,8 @@ const FetchCascadeChildValuesArgsSchema = z.object({
53
48
  });
54
49
  const FetchUdfLayoutArgsSchema = z.object({
55
50
  projectKey: CommonFields.projectKeyOptional,
56
- baseUrl: CommonFields.baseUrl,
57
- entityType: z.enum(["TC", "TS", "IS"]).describe(
58
- "Entity type to fetch UDF field definitions for. 'TC' = Test Case (also returns step UDFs in stepFields), 'TS' = Test Suite, 'IS' = Issue."
51
+ entityType: z.enum(["TC", "TS", "IS", "RQ"]).describe(
52
+ "Entity type to fetch UDF field definitions for. 'TC' = Test Case (also returns step UDFs in stepFields), 'TS' = Test Suite, 'IS' = Issue, 'RQ' = Requirement."
59
53
  ),
60
54
  pageName: z.enum(["ADD", "DETAIL"]).optional().default("ADD").describe(
61
55
  "'ADD' returns fields for create operations (no fieldID needed). 'DETAIL' returns fields for update operations and includes fieldID (projectUserFieldID) required by the UDF update wrapper. Call with 'DETAIL' before updating an entity's UDF values."
@@ -63,7 +57,6 @@ const FetchUdfLayoutArgsSchema = z.object({
63
57
  });
64
58
  const FetchTestRunUdfValuesArgsSchema = z.object({
65
59
  projectKey: CommonFields.projectKeyOptional,
66
- baseUrl: CommonFields.baseUrl,
67
60
  tsrunID: z.coerce.string().optional().describe(
68
61
  "Test Suite Run ID. CRITICAL: the parameter name is 'tsrunID' — do NOT use 'testSuiteRunId', 'tsRunID', or any other variant. Accepts a string or number (e.g. 731600 or '731600' — both are valid). Get this from 'Fetch Executions by Test Suite' → use data[<index>].tsRunID from the response. Required when sourceRows is not provided."
69
62
  ),
@@ -903,7 +903,32 @@ class SwaggerAPI {
903
903
  * @returns Created or updated API metadata with URL. HTTP 201 indicates creation, HTTP 200 indicates update
904
904
  */
905
905
  async createOrUpdateApi(params) {
906
- return this.saveApiDefinition(params, { isPrivate: true });
906
+ const exists = await this.apiExists({
907
+ owner: params.owner,
908
+ apiName: params.apiName
909
+ });
910
+ return this.saveApiDefinition(params, exists ? {} : { isPrivate: true });
911
+ }
912
+ /**
913
+ * Check whether an API (any version) already exists for the given owner/name.
914
+ */
915
+ async apiExists({
916
+ owner,
917
+ apiName
918
+ }) {
919
+ const url = `${this.config.registryBasePath}/apis/${encodeURIComponent(owner)}/${encodeURIComponent(apiName)}`;
920
+ const response = await fetch(url, {
921
+ method: "GET",
922
+ headers: this.headers
923
+ });
924
+ if (response.status === 404) return false;
925
+ if (!response.ok) {
926
+ const errorText = await response.text().catch(() => "");
927
+ throw new ToolError(
928
+ `SwaggerHub Registry API apiExists failed - status: ${response.status} ${response.statusText}${errorText ? ` - ${errorText}` : ""}. owner=${owner}, apiName=${apiName}`
929
+ );
930
+ }
931
+ return true;
907
932
  }
908
933
  /**
909
934
  * Save an API definition to SwaggerHub Registry
@@ -966,12 +991,13 @@ class SwaggerAPI {
966
991
  /**
967
992
  * Create API from Prompt using SmartBear AI
968
993
  * @param params Parameters for creating API from prompt including owner, api name, prompt, and specification type
969
- * @returns Created API metadata with URL. HTTP 201 indicates creation, HTTP 200 for update, HTTP 205 for reload
994
+ * @returns Created API metadata with URL. HTTP 201 indicates creation; HTTP 409 is thrown if the generated version already exists
970
995
  */
971
996
  async createApiFromPrompt(params) {
972
997
  const searchParams = new URLSearchParams();
973
998
  const specType = params.specType ?? "openapi30x";
974
999
  searchParams.append("specType", specType);
1000
+ searchParams.append("createOnly", "true");
975
1001
  const url = `${this.config.registryBasePath}/apis/${encodeURIComponent(
976
1002
  params.owner
977
1003
  )}/${encodeURIComponent(params.apiName)}/.ai?${searchParams.toString()}`;
@@ -989,7 +1015,6 @@ class SwaggerAPI {
989
1015
  `SwaggerHub Registry API createApiFromPrompt failed - status: ${response.status} ${response.statusText}${errorText ? ` - ${errorText}` : ""}. URL: ${url}`
990
1016
  );
991
1017
  }
992
- const operation = response.status === 201 ? "create" : "update";
993
1018
  const version = response.headers.get("X-Version");
994
1019
  return {
995
1020
  owner: params.owner,
@@ -997,7 +1022,7 @@ class SwaggerAPI {
997
1022
  specType,
998
1023
  version: version || void 0,
999
1024
  url: version ? `${this.config.uiBasePath}/apis/${params.owner}/${params.apiName}/${version}` : `${this.config.uiBasePath}/apis/${params.owner}/${params.apiName}`,
1000
- operation
1025
+ operation: "create"
1001
1026
  };
1002
1027
  }
1003
1028
  /**