zephyr-scale-mcp-server 0.4.5 → 0.4.7
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.
- package/build/tool-handlers.js +33 -8
- package/package.json +2 -2
- package/src/tool-handlers.ts +42 -8
package/build/tool-handlers.js
CHANGED
|
@@ -12,8 +12,18 @@ export class ZephyrToolHandlers {
|
|
|
12
12
|
const { test_case_key } = args;
|
|
13
13
|
try {
|
|
14
14
|
const response = await this.axiosInstance.get(`${this.jiraConfig.apiEndpoints.testcase}/${test_case_key}`);
|
|
15
|
+
const testCase = response.data;
|
|
16
|
+
// Fetch the test script content and embed it inline.
|
|
17
|
+
// The base GET /testcases/{key} only returns a link to the script, not the content.
|
|
18
|
+
try {
|
|
19
|
+
const scriptResponse = await this.axiosInstance.get(`${this.jiraConfig.apiEndpoints.testcase}/${test_case_key}/testscript`);
|
|
20
|
+
testCase.testScript = scriptResponse.data;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// Script fetch failed (e.g. no script yet) — leave testScript as the link object
|
|
24
|
+
}
|
|
15
25
|
return {
|
|
16
|
-
content: [{ type: 'text', text: JSON.stringify(
|
|
26
|
+
content: [{ type: 'text', text: JSON.stringify(testCase, null, 2) }],
|
|
17
27
|
};
|
|
18
28
|
}
|
|
19
29
|
catch (error) {
|
|
@@ -240,6 +250,18 @@ export class ZephyrToolHandlers {
|
|
|
240
250
|
if (!tc) {
|
|
241
251
|
throw scriptUpdateError; // no test case data to build PUT payload, surface original error
|
|
242
252
|
}
|
|
253
|
+
// Fetch the existing test script to get its ID — required for the PUT to update in place
|
|
254
|
+
let existingScriptId;
|
|
255
|
+
try {
|
|
256
|
+
const scriptRes = await this.axiosInstance.get(`${this.jiraConfig.apiEndpoints.testcase}/${test_case_key}/testscript`);
|
|
257
|
+
existingScriptId = scriptRes.data?.id;
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
// no existing script — proceed without id
|
|
261
|
+
}
|
|
262
|
+
const testScriptPayload = { type: 'bdd', text: finalText };
|
|
263
|
+
if (existingScriptId)
|
|
264
|
+
testScriptPayload.id = existingScriptId;
|
|
243
265
|
const putPayload = {
|
|
244
266
|
id: tc.id,
|
|
245
267
|
key: test_case_key,
|
|
@@ -247,7 +269,7 @@ export class ZephyrToolHandlers {
|
|
|
247
269
|
status: tc.status,
|
|
248
270
|
priority: tc.priority,
|
|
249
271
|
project: tc.project,
|
|
250
|
-
testScript:
|
|
272
|
+
testScript: testScriptPayload,
|
|
251
273
|
};
|
|
252
274
|
for (const field of ['objective', 'precondition', 'estimatedTime', 'component', 'owner', 'folder']) {
|
|
253
275
|
if (tc[field] !== undefined && tc[field] !== null)
|
|
@@ -258,12 +280,15 @@ export class ZephyrToolHandlers {
|
|
|
258
280
|
if (tc.customFields && Object.keys(tc.customFields).length > 0)
|
|
259
281
|
putPayload.customFields = tc.customFields;
|
|
260
282
|
await this.axiosInstance.put(`${this.jiraConfig.apiEndpoints.testcase}/${test_case_key}`, putPayload);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
283
|
+
// Note: the Zephyr Scale Cloud API's UpdateTestCaseInput does not include a testScript field,
|
|
284
|
+
// so the testScript embedded in the PUT payload is silently ignored.
|
|
285
|
+
// The only endpoint that updates script content (POST /testscript) requires the project to be active.
|
|
286
|
+
// For test cases migrated from Data Center to Cloud, the original project key may be deactivated,
|
|
287
|
+
// blocking script updates at the API level. Contact your Zephyr Scale admin to re-enable the project.
|
|
288
|
+
throw new McpError(ErrorCode.InternalError, `Cannot update test script for ${test_case_key}: the project "${test_case_key.replace(/-T\d+$/, '')}" is deactivated in Zephyr Scale Cloud. ` +
|
|
289
|
+
`This test case was likely migrated from Data Center and retains its original project key prefix. ` +
|
|
290
|
+
`POST /testcases/{key}/testscript requires an active project. ` +
|
|
291
|
+
`Please ask your Zephyr Scale admin to re-enable the project, or recreate this test case under an active Cloud project.`);
|
|
267
292
|
}
|
|
268
293
|
// Primary path succeeded — optionally rename
|
|
269
294
|
if (typeof name === 'string' && name.trim().length > 0) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zephyr-scale-mcp-server",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
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",
|
|
7
7
|
"bin": {
|
|
8
|
-
"zephyr-scale-mcp": "
|
|
8
|
+
"zephyr-scale-mcp": "build/index.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"build/",
|
package/src/tool-handlers.ts
CHANGED
|
@@ -24,8 +24,21 @@ export class ZephyrToolHandlers {
|
|
|
24
24
|
const { test_case_key } = args;
|
|
25
25
|
try {
|
|
26
26
|
const response = await this.axiosInstance.get(`${this.jiraConfig.apiEndpoints.testcase}/${test_case_key}`);
|
|
27
|
+
const testCase = response.data;
|
|
28
|
+
|
|
29
|
+
// Fetch the test script content and embed it inline.
|
|
30
|
+
// The base GET /testcases/{key} only returns a link to the script, not the content.
|
|
31
|
+
try {
|
|
32
|
+
const scriptResponse = await this.axiosInstance.get(
|
|
33
|
+
`${this.jiraConfig.apiEndpoints.testcase}/${test_case_key}/testscript`
|
|
34
|
+
);
|
|
35
|
+
testCase.testScript = scriptResponse.data;
|
|
36
|
+
} catch {
|
|
37
|
+
// Script fetch failed (e.g. no script yet) — leave testScript as the link object
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
return {
|
|
28
|
-
content: [{ type: 'text', text: JSON.stringify(
|
|
41
|
+
content: [{ type: 'text', text: JSON.stringify(testCase, null, 2) }],
|
|
29
42
|
};
|
|
30
43
|
} catch (error) {
|
|
31
44
|
throw new McpError(ErrorCode.InternalError, `Failed to get test case: ${this.formatError(error)}`);
|
|
@@ -260,6 +273,21 @@ export class ZephyrToolHandlers {
|
|
|
260
273
|
if (!tc) {
|
|
261
274
|
throw scriptUpdateError; // no test case data to build PUT payload, surface original error
|
|
262
275
|
}
|
|
276
|
+
|
|
277
|
+
// Fetch the existing test script to get its ID — required for the PUT to update in place
|
|
278
|
+
let existingScriptId: number | undefined;
|
|
279
|
+
try {
|
|
280
|
+
const scriptRes = await this.axiosInstance.get(
|
|
281
|
+
`${this.jiraConfig.apiEndpoints.testcase}/${test_case_key}/testscript`
|
|
282
|
+
);
|
|
283
|
+
existingScriptId = scriptRes.data?.id;
|
|
284
|
+
} catch {
|
|
285
|
+
// no existing script — proceed without id
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const testScriptPayload: any = { type: 'bdd', text: finalText };
|
|
289
|
+
if (existingScriptId) testScriptPayload.id = existingScriptId;
|
|
290
|
+
|
|
263
291
|
const putPayload: any = {
|
|
264
292
|
id: tc.id,
|
|
265
293
|
key: test_case_key,
|
|
@@ -267,7 +295,7 @@ export class ZephyrToolHandlers {
|
|
|
267
295
|
status: tc.status,
|
|
268
296
|
priority: tc.priority,
|
|
269
297
|
project: tc.project,
|
|
270
|
-
testScript:
|
|
298
|
+
testScript: testScriptPayload,
|
|
271
299
|
};
|
|
272
300
|
for (const field of ['objective', 'precondition', 'estimatedTime', 'component', 'owner', 'folder']) {
|
|
273
301
|
if (tc[field] !== undefined && tc[field] !== null) putPayload[field] = tc[field];
|
|
@@ -277,12 +305,18 @@ export class ZephyrToolHandlers {
|
|
|
277
305
|
|
|
278
306
|
await this.axiosInstance.put(`${this.jiraConfig.apiEndpoints.testcase}/${test_case_key}`, putPayload);
|
|
279
307
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
308
|
+
// Note: the Zephyr Scale Cloud API's UpdateTestCaseInput does not include a testScript field,
|
|
309
|
+
// so the testScript embedded in the PUT payload is silently ignored.
|
|
310
|
+
// The only endpoint that updates script content (POST /testscript) requires the project to be active.
|
|
311
|
+
// For test cases migrated from Data Center to Cloud, the original project key may be deactivated,
|
|
312
|
+
// blocking script updates at the API level. Contact your Zephyr Scale admin to re-enable the project.
|
|
313
|
+
throw new McpError(
|
|
314
|
+
ErrorCode.InternalError,
|
|
315
|
+
`Cannot update test script for ${test_case_key}: the project "${test_case_key.replace(/-T\d+$/, '')}" is deactivated in Zephyr Scale Cloud. ` +
|
|
316
|
+
`This test case was likely migrated from Data Center and retains its original project key prefix. ` +
|
|
317
|
+
`POST /testcases/{key}/testscript requires an active project. ` +
|
|
318
|
+
`Please ask your Zephyr Scale admin to re-enable the project, or recreate this test case under an active Cloud project.`
|
|
319
|
+
);
|
|
286
320
|
}
|
|
287
321
|
|
|
288
322
|
// Primary path succeeded — optionally rename
|