import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { ZephyrClient } from '../zephyr-client.js';
export function createTestCycleTools(client: ZephyrClient): Tool[] {
return [
{
name: 'zephyr_list_test_cycles',
description: 'List test cycles in a Zephyr project',
inputSchema: {
type: 'object',
properties: {
projectKey: {
type: 'string',
description: 'The project key to list test cycles from'
},
maxResults: {
type: 'number',
description: 'Maximum number of results to return (default: 50)',
default: 50
}
},
required: ['projectKey']
}
},
{
name: 'zephyr_get_test_cycle',
description: 'Get a specific test cycle by its key',
inputSchema: {
type: 'object',
properties: {
testCycleKey: {
type: 'string',
description: 'The key of the test cycle to retrieve'
}
},
required: ['testCycleKey']
}
},
{
name: 'zephyr_create_test_cycle',
description: 'Create a new test cycle in a Zephyr project',
inputSchema: {
type: 'object',
properties: {
projectKey: {
type: 'string',
description: 'The project key to create the test cycle in'
},
name: {
type: 'string',
description: 'The name of the test cycle'
},
description: {
type: 'string',
description: 'The description of the test cycle'
},
status: {
type: 'string',
description: 'The status of the test cycle (e.g., "Active", "Completed", "Planned")',
default: 'Planned'
},
environment: {
type: 'string',
description: 'The test environment (e.g., "QA", "Staging", "Production")'
},
startDate: {
type: 'string',
description: 'Start date in ISO format (YYYY-MM-DD)'
},
endDate: {
type: 'string',
description: 'End date in ISO format (YYYY-MM-DD)'
}
},
required: ['projectKey', 'name']
}
},
{
name: 'zephyr_update_test_cycle',
description: 'Update an existing test cycle',
inputSchema: {
type: 'object',
properties: {
testCycleKey: {
type: 'string',
description: 'The key of the test cycle to update'
},
name: {
type: 'string',
description: 'The updated name of the test cycle'
},
description: {
type: 'string',
description: 'The updated description of the test cycle'
},
status: {
type: 'string',
description: 'The updated status of the test cycle'
},
environment: {
type: 'string',
description: 'The updated test environment'
},
startDate: {
type: 'string',
description: 'Updated start date in ISO format'
},
endDate: {
type: 'string',
description: 'Updated end date in ISO format'
}
},
required: ['testCycleKey']
}
},
{
name: 'zephyr_add_test_cases_to_cycle',
description: 'Add test cases to a test cycle',
inputSchema: {
type: 'object',
properties: {
testCycleKey: {
type: 'string',
description: 'The test cycle key to add test cases to'
},
testCaseKeys: {
type: 'array',
items: { type: 'string' },
description: 'Array of test case keys to add to the cycle',
minItems: 1
}
},
required: ['testCycleKey', 'testCaseKeys']
}
},
{
name: 'zephyr_remove_test_cases_from_cycle',
description: 'Remove test cases from a test cycle',
inputSchema: {
type: 'object',
properties: {
testCycleKey: {
type: 'string',
description: 'The test cycle key to remove test cases from'
},
testCaseKeys: {
type: 'array',
items: { type: 'string' },
description: 'Array of test case keys to remove from the cycle',
minItems: 1
}
},
required: ['testCycleKey', 'testCaseKeys']
}
}
];
}
export async function handleTestCycleToolCall(toolName: string, args: any, client: ZephyrClient): Promise<any> {
switch (toolName) {
case 'zephyr_list_test_cycles':
return await client.getTestCycles(args.projectKey, args.maxResults);
case 'zephyr_get_test_cycle':
return await client.getTestCycle(args.testCycleKey);
case 'zephyr_create_test_cycle':
return await client.createTestCycle(args.projectKey, args);
case 'zephyr_update_test_cycle':
return await client.updateTestCycle(args.testCycleKey, args);
case 'zephyr_add_test_cases_to_cycle':
await client.addTestCaseToCycle(args.testCycleKey, args.testCaseKeys);
return {
success: true,
message: `Added ${args.testCaseKeys.length} test cases to cycle ${args.testCycleKey}`
};
case 'zephyr_remove_test_cases_from_cycle':
await client.removeTestCaseFromCycle(args.testCycleKey, args.testCaseKeys);
return {
success: true,
message: `Removed ${args.testCaseKeys.length} test cases from cycle ${args.testCycleKey}`
};
default:
throw new Error(`Unknown test cycle tool: ${toolName}`);
}
}