zephyr-scale-mcp-server 0.2.5 → 0.2.6

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.
@@ -196,32 +196,63 @@ export class ZephyrToolHandlers {
196
196
  }
197
197
  async createFolder(args) {
198
198
  const { project_key, name, parent_folder_path, folder_type = 'TEST_CASE' } = args;
199
+ // Build payload based on Jira type
199
200
  const payload = {
200
201
  projectKey: project_key,
201
202
  name: name,
202
- folderType: folder_type,
203
203
  };
204
+ // For Data Center/Server API, use 'type' field
205
+ // For Cloud API, use 'folderType' field
206
+ if (this.jiraConfig.type === 'datacenter') {
207
+ payload.type = folder_type;
208
+ }
209
+ else {
210
+ payload.folderType = folder_type;
211
+ }
212
+ // Handle parent folder
204
213
  if (parent_folder_path) {
205
- payload.parentFolderPath = parent_folder_path;
214
+ // For Data Center/Server, the API expects parentId (numeric)
215
+ // For Cloud, it may accept parentFolderPath
216
+ // We'll try to use the path first, but provide better error messaging
217
+ if (this.jiraConfig.type === 'datacenter') {
218
+ // Data Center API typically expects parentId as a number
219
+ // If parent_folder_path is provided as a string path, we need to resolve it to an ID
220
+ // For now, we'll accept it and let the API respond with an error if needed
221
+ payload.parentId = parent_folder_path;
222
+ }
223
+ else {
224
+ payload.parentFolderPath = parent_folder_path;
225
+ }
206
226
  }
207
227
  try {
208
228
  const response = await this.axiosInstance.post(this.jiraConfig.apiEndpoints.folder, payload);
209
- if (response.status === 201) {
229
+ if (response.status === 201 || response.status === 200) {
210
230
  return {
211
231
  content: [
212
232
  {
213
233
  type: 'text',
214
- text: `✅ Folder created successfully: ${response.data.name} (ID: ${response.data.id})\n${JSON.stringify(response.data, null, 2)}`,
234
+ text: `✅ Folder created successfully: ${response.data.name || name} (ID: ${response.data.id || 'N/A'})\n${JSON.stringify(response.data, null, 2)}`,
215
235
  },
216
236
  ],
217
237
  };
218
238
  }
219
239
  else {
220
- throw new Error(`Failed to create folder: ${response.status}`);
240
+ throw new Error(`Unexpected status code: ${response.status}`);
221
241
  }
222
242
  }
223
243
  catch (error) {
224
- throw new McpError(ErrorCode.InternalError, `Failed to create folder: ${error instanceof Error ? error.message : String(error)}`);
244
+ let errorMessage = 'Unknown error';
245
+ if (error instanceof Error && 'response' in error) {
246
+ const axiosError = error;
247
+ errorMessage = `Status: ${axiosError.response?.status}, Data: ${JSON.stringify(axiosError.response?.data)}, Payload sent: ${JSON.stringify(payload)}`;
248
+ }
249
+ else if (error instanceof Error) {
250
+ errorMessage = error.message;
251
+ }
252
+ else {
253
+ errorMessage = String(error);
254
+ }
255
+ throw new McpError(ErrorCode.InternalError, `Failed to create folder: ${errorMessage}`);
225
256
  }
226
257
  }
227
258
  async getTestRunCases(args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zephyr-scale-mcp-server",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
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",
@@ -220,35 +220,63 @@ export class ZephyrToolHandlers {
220
220
  async createFolder(args: FolderArgs) {
221
221
  const { project_key, name, parent_folder_path, folder_type = 'TEST_CASE' } = args;
222
222
 
223
+ // Build payload based on Jira type
223
224
  const payload: any = {
224
225
  projectKey: project_key,
225
226
  name: name,
226
- folderType: folder_type,
227
227
  };
228
228
 
229
+ // For Data Center/Server API, use 'type' field
230
+ // For Cloud API, use 'folderType' field
231
+ if (this.jiraConfig.type === 'datacenter') {
232
+ payload.type = folder_type;
233
+ } else {
234
+ payload.folderType = folder_type;
235
+ }
236
+
237
+ // Handle parent folder
229
238
  if (parent_folder_path) {
230
- payload.parentFolderPath = parent_folder_path;
239
+ // For Data Center/Server, the API expects parentId (numeric)
240
+ // For Cloud, it may accept parentFolderPath
241
+ // We'll try to use the path first, but provide better error messaging
242
+ if (this.jiraConfig.type === 'datacenter') {
243
+ // Data Center API typically expects parentId as a number
244
+ // If parent_folder_path is provided as a string path, we need to resolve it to an ID
245
+ // For now, we'll accept it and let the API respond with an error if needed
246
+ payload.parentId = parent_folder_path;
247
+ } else {
248
+ payload.parentFolderPath = parent_folder_path;
249
+ }
231
250
  }
232
251
 
233
252
  try {
234
253
  const response = await this.axiosInstance.post(this.jiraConfig.apiEndpoints.folder, payload);
235
254
 
236
- if (response.status === 201) {
255
+ if (response.status === 201 || response.status === 200) {
237
256
  return {
238
257
  content: [
239
258
  {
240
259
  type: 'text',
241
- text: `✅ Folder created successfully: ${response.data.name} (ID: ${response.data.id})\n${JSON.stringify(response.data, null, 2)}`,
260
+ text: `✅ Folder created successfully: ${response.data.name || name} (ID: ${response.data.id || 'N/A'})\n${JSON.stringify(response.data, null, 2)}`,
242
261
  },
243
262
  ],
244
263
  };
245
264
  } else {
246
- throw new Error(`Failed to create folder: ${response.status}`);
265
+ throw new Error(`Unexpected status code: ${response.status}`);
247
266
  }
248
267
  } catch (error) {
268
+ let errorMessage = 'Unknown error';
269
+ if (error instanceof Error && 'response' in error) {
270
+ const axiosError = error as any;
271
+ errorMessage = `Status: ${axiosError.response?.status}, Data: ${JSON.stringify(axiosError.response?.data)}, Payload sent: ${JSON.stringify(payload)}`;
272
+ } else if (error instanceof Error) {
273
+ errorMessage = error.message;
274
+ } else {
275
+ errorMessage = String(error);
276
+ }
249
277
  throw new McpError(
250
278
  ErrorCode.InternalError,
251
- `Failed to create folder: ${error instanceof Error ? error.message : String(error)}`
279
+ `Failed to create folder: ${errorMessage}`
252
280
  );
253
281
  }
254
282
  }
@@ -579,4 +607,4 @@ export class ZephyrToolHandlers {
579
607
  isError: true,
580
608
  };
581
609
  }
582
- }
610
+ }
@@ -357,4 +357,4 @@ export const toolSchemas = [
357
357
  required: ['test_run_key', 'test_case_keys'],
358
358
  },
359
359
  },
360
- ];
360
+ ];
package/src/types.ts CHANGED
@@ -49,7 +49,7 @@ export interface UpdateBddArgs {
49
49
  export interface FolderArgs {
50
50
  project_key: string;
51
51
  name: string;
52
- parent_folder_path?: string;
52
+ parent_folder_path?: string; // For Cloud: folder path string; For Data Center: numeric folder ID
53
53
  folder_type?: 'TEST_CASE' | 'TEST_PLAN' | 'TEST_RUN';
54
54
  }
55
55
 
@@ -92,4 +92,4 @@ export interface JiraConfig {
92
92
  baseUrl: string;
93
93
  authHeaders: Record<string, string>;
94
94
  apiEndpoints: ApiEndpoints;
95
- }
95
+ }