link_tests_to_issues
Associate test cases with JIRA issues to track testing activities and requirements. Link test case IDs to relevant issue keys for traceability.
Instructions
Associate test cases with JIRA issues
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| testCaseId | Yes | Test case ID | |
| issueKeys | Yes | JIRA issue keys to link |
Implementation Reference
- src/tools/test-execution.ts:94-131 (handler)The main handler function that implements the link_tests_to_issues tool. It validates input, loops through issue keys, links each test case to issues using ZephyrClient, and returns results with success/failure counts.export const linkTestsToIssues = async (input: LinkTestsToIssuesInput) => { const validatedInput = linkTestsToIssuesSchema.parse(input); try { const results = []; for (const issueKey of validatedInput.issueKeys) { try { await getZephyrClient().linkTestCaseToIssue(validatedInput.testCaseId, issueKey); results.push({ issueKey, success: true, }); } catch (error: any) { results.push({ issueKey, success: false, error: error.response?.data?.message || error.message, }); } } return { success: true, data: { testCaseId: validatedInput.testCaseId, linkResults: results, successCount: results.filter(r => r.success).length, failureCount: results.filter(r => !r.success).length, }, }; } catch (error: any) { return { success: false, error: error.response?.data?.message || error.message, }; } };
- src/utils/validation.ts:49-52 (schema)Zod schema defining the input structure for the link_tests_to_issues tool: testCaseId (required string) and issueKeys (array of strings, at least one).export const linkTestsToIssuesSchema = z.object({ testCaseId: z.string().min(1, 'Test case ID is required'), issueKeys: z.array(z.string().min(1)).min(1, 'At least one issue key is required'), });
- src/index.ts:159-170 (registration)Registration of the link_tests_to_issues tool in the MCP server's TOOLS array, including name, description, and input schema for the protocol.{ name: 'link_tests_to_issues', description: 'Associate test cases with JIRA issues', inputSchema: { type: 'object', properties: { testCaseId: { type: 'string', description: 'Test case ID' }, issueKeys: { type: 'array', items: { type: 'string' }, description: 'JIRA issue keys to link' }, }, required: ['testCaseId', 'issueKeys'], }, },
- src/index.ts:413-423 (registration)Dispatcher case in the MCP server's CallToolRequest handler that validates input using the schema and calls the linkTestsToIssues handler function.case 'link_tests_to_issues': { const validatedArgs = validateInput<LinkTestsToIssuesInput>(linkTestsToIssuesSchema, args, 'link_tests_to_issues'); return { content: [ { type: 'text', text: JSON.stringify(await linkTestsToIssues(validatedArgs), null, 2), }, ], }; }