zephyr-scale-mcp-server 0.3.3 → 0.4.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.
@@ -458,9 +458,16 @@ export class ZephyrToolHandlers {
458
458
  if (response.status !== 201)
459
459
  throw new Error(`Unexpected status code: ${response.status}`);
460
460
  const cycleKey = response.data.key || 'Unknown';
461
- // Step 2: add test cases to the cycle
461
+ // Step 2: add test cases via test executions (Cloud v2 has no /testcycles/{key}/testcases)
462
462
  if (test_case_keys && test_case_keys.length > 0) {
463
- await this.axiosInstance.post(`${this.jiraConfig.apiEndpoints.testrun}/${cycleKey}/testcases`, { items: test_case_keys.map((k) => ({ testCaseKey: k })) });
463
+ for (const testCaseKey of test_case_keys) {
464
+ await this.axiosInstance.post('/testexecutions', {
465
+ projectKey: project_key,
466
+ testCaseKey,
467
+ testCycleKey: cycleKey,
468
+ statusName: 'Not Executed',
469
+ });
470
+ }
464
471
  }
465
472
  return {
466
473
  content: [{
@@ -734,24 +741,24 @@ export class ZephyrToolHandlers {
734
741
  throw new McpError(ErrorCode.InvalidRequest, 'add_test_cases_to_run is only supported on Zephyr Scale Cloud. The Data Center API (v1) does not provide an endpoint to modify test runs after creation.');
735
742
  }
736
743
  const { test_run_key, test_case_keys } = args;
744
+ // Derive project key from the test run key (e.g. PROJ-R123 → PROJ)
745
+ const project_key = test_run_key.split('-')[0];
737
746
  try {
738
- const payload = {
739
- items: test_case_keys.map(key => ({ testCaseKey: key }))
740
- };
741
- const response = await this.axiosInstance.post(`${this.jiraConfig.apiEndpoints.testrun}/${test_run_key}/testcases`, payload);
742
- if (response.status === 200 || response.status === 201 || response.status === 204) {
743
- return {
744
- content: [{ type: 'text', text: `Added ${test_case_keys.length} test case(s) to test run ${test_run_key}.` }],
745
- };
747
+ for (const testCaseKey of test_case_keys) {
748
+ await this.axiosInstance.post('/testexecutions', {
749
+ projectKey: project_key,
750
+ testCaseKey,
751
+ testCycleKey: test_run_key,
752
+ statusName: 'Not Executed',
753
+ });
746
754
  }
755
+ return {
756
+ content: [{ type: 'text', text: `Added ${test_case_keys.length} test case(s) to test run ${test_run_key}.` }],
757
+ };
747
758
  }
748
759
  catch (error) {
749
760
  throw new McpError(ErrorCode.InternalError, `Failed to add test cases: ${this.formatError(error)}`);
750
761
  }
751
- return {
752
- content: [{ type: 'text', text: 'An unexpected error occurred.' }],
753
- isError: true,
754
- };
755
762
  }
756
763
  formatError(error) {
757
764
  if (error instanceof Error && 'response' in error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zephyr-scale-mcp-server",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Model Context Protocol (MCP) server for Zephyr Scale test case management with comprehensive STEP_BY_STEP, PLAIN_TEXT, and BDD support",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",
@@ -513,12 +513,16 @@ export class ZephyrToolHandlers {
513
513
 
514
514
  const cycleKey = response.data.key || 'Unknown';
515
515
 
516
- // Step 2: add test cases to the cycle
516
+ // Step 2: add test cases via test executions (Cloud v2 has no /testcycles/{key}/testcases)
517
517
  if (test_case_keys && test_case_keys.length > 0) {
518
- await this.axiosInstance.post(
519
- `${this.jiraConfig.apiEndpoints.testrun}/${cycleKey}/testcases`,
520
- { items: test_case_keys.map((k: string) => ({ testCaseKey: k })) }
521
- );
518
+ for (const testCaseKey of test_case_keys) {
519
+ await this.axiosInstance.post('/testexecutions', {
520
+ projectKey: project_key,
521
+ testCaseKey,
522
+ testCycleKey: cycleKey,
523
+ statusName: 'Not Executed',
524
+ });
525
+ }
522
526
  }
523
527
 
524
528
  return {
@@ -813,28 +817,24 @@ export class ZephyrToolHandlers {
813
817
 
814
818
  const { test_run_key, test_case_keys } = args;
815
819
 
816
- try {
817
- const payload = {
818
- items: test_case_keys.map(key => ({ testCaseKey: key }))
819
- };
820
- const response = await this.axiosInstance.post(
821
- `${this.jiraConfig.apiEndpoints.testrun}/${test_run_key}/testcases`,
822
- payload
823
- );
820
+ // Derive project key from the test run key (e.g. PROJ-R123 → PROJ)
821
+ const project_key = test_run_key.split('-')[0];
824
822
 
825
- if (response.status === 200 || response.status === 201 || response.status === 204) {
826
- return {
827
- content: [{ type: 'text', text: `Added ${test_case_keys.length} test case(s) to test run ${test_run_key}.` }],
828
- };
823
+ try {
824
+ for (const testCaseKey of test_case_keys) {
825
+ await this.axiosInstance.post('/testexecutions', {
826
+ projectKey: project_key,
827
+ testCaseKey,
828
+ testCycleKey: test_run_key,
829
+ statusName: 'Not Executed',
830
+ });
829
831
  }
832
+ return {
833
+ content: [{ type: 'text', text: `Added ${test_case_keys.length} test case(s) to test run ${test_run_key}.` }],
834
+ };
830
835
  } catch (error) {
831
836
  throw new McpError(ErrorCode.InternalError, `Failed to add test cases: ${this.formatError(error)}`);
832
837
  }
833
-
834
- return {
835
- content: [{ type: 'text', text: 'An unexpected error occurred.' }],
836
- isError: true,
837
- };
838
838
  }
839
839
 
840
840
  private formatError(error: unknown): string {