import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { ZephyrClient } from '../zephyr-client.js';
export function createTestPlanTools(client: ZephyrClient): Tool[] {
return [
{
name: 'zephyr_list_test_plans',
description: 'List test plans in a Zephyr project',
inputSchema: {
type: 'object',
properties: {
projectKey: {
type: 'string',
description: 'The project key to list test plans from'
},
maxResults: {
type: 'number',
description: 'Maximum number of results to return (default: 50)',
default: 50
}
},
required: ['projectKey']
}
},
{
name: 'zephyr_get_test_plan',
description: 'Get a specific test plan by its key',
inputSchema: {
type: 'object',
properties: {
testPlanKey: {
type: 'string',
description: 'The key of the test plan to retrieve'
}
},
required: ['testPlanKey']
}
},
{
name: 'zephyr_create_test_plan',
description: 'Create a new test plan in a Zephyr project',
inputSchema: {
type: 'object',
properties: {
projectKey: {
type: 'string',
description: 'The project key to create the test plan in'
},
name: {
type: 'string',
description: 'The name of the test plan'
},
description: {
type: 'string',
description: 'The description of the test plan'
},
status: {
type: 'string',
description: 'The status of the test plan (e.g., "Draft", "Active", "Completed")',
default: 'Draft'
},
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_plan',
description: 'Update an existing test plan',
inputSchema: {
type: 'object',
properties: {
testPlanKey: {
type: 'string',
description: 'The key of the test plan to update'
},
name: {
type: 'string',
description: 'The updated name of the test plan'
},
description: {
type: 'string',
description: 'The updated description of the test plan'
},
status: {
type: 'string',
description: 'The updated status of the test plan'
},
startDate: {
type: 'string',
description: 'Updated start date in ISO format'
},
endDate: {
type: 'string',
description: 'Updated end date in ISO format'
}
},
required: ['testPlanKey']
}
}
];
}
export async function handleTestPlanToolCall(toolName: string, args: any, client: ZephyrClient): Promise<any> {
switch (toolName) {
case 'zephyr_list_test_plans':
return await client.getTestPlans(args.projectKey, args.maxResults);
case 'zephyr_get_test_plan':
return await client.getTestPlan(args.testPlanKey);
case 'zephyr_create_test_plan':
return await client.createTestPlan(args.projectKey, args);
case 'zephyr_update_test_plan':
return await client.updateTestPlan(args.testPlanKey, args);
default:
throw new Error(`Unknown test plan tool: ${toolName}`);
}
}