read_jira_issue
Retrieve JIRA issue details and metadata using an issue key to access specific information for test management and tracking.
Instructions
Read JIRA issue details and metadata
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| issueKey | Yes | JIRA issue key (e.g., ABC-123) | |
| fields | No | Specific fields to retrieve (optional) |
Implementation Reference
- src/tools/jira-issues.ts:13-62 (handler)Main handler function that validates input, retrieves the Jira issue using JiraClient, extracts and formats relevant fields into a structured response, handles errors.
export const readJiraIssue = async (input: ReadJiraIssueInput) => { const validatedInput = readJiraIssueSchema.parse(input); try { const issue = await getJiraClient().getIssue(validatedInput.issueKey, validatedInput.fields); return { success: true, data: { key: issue.key, summary: issue.fields?.summary || null, description: issue.fields?.description || null, status: issue.fields?.status ? { name: issue.fields.status.name, category: issue.fields.status.statusCategory?.name || 'Unknown', } : null, priority: issue.fields?.priority?.name || null, assignee: issue.fields?.assignee ? { name: issue.fields.assignee.displayName, email: issue.fields.assignee.emailAddress, } : null, reporter: issue.fields?.reporter ? { name: issue.fields.reporter.displayName, email: issue.fields.reporter.emailAddress, } : null, created: issue.fields?.created || null, updated: issue.fields?.updated || null, issueType: issue.fields?.issuetype?.name || null, project: issue.fields?.project ? { key: issue.fields.project.key, name: issue.fields.project.name, } : null, labels: issue.fields?.labels || [], components: issue.fields?.components?.map(c => c.name) || [], fixVersions: issue.fields?.fixVersions?.map(v => v.name) || [], customFields: issue.fields ? Object.entries(issue.fields) .filter(([key]) => key.startsWith('customfield_')) .reduce((acc, [key, value]) => ({ ...acc, [key]: value, }), {}) : {}, }, }; } catch (error: any) { return { success: false, error: error.response?.data?.errorMessages?.[0] || error.message, }; } }; - src/utils/validation.ts:21-24 (schema)Zod schema defining the input structure for the read_jira_issue tool: issueKey (required string), fields (optional array of strings).
export const readJiraIssueSchema = z.object({ issueKey: z.string().min(1, 'Issue key is required'), fields: z.array(z.string()).optional(), }); - src/index.ts:64-75 (registration)Tool specification object registered in the TOOLS array used by listTools MCP handler, defining name, description, and input schema.
{ name: 'read_jira_issue', description: 'Read JIRA issue details and metadata', inputSchema: { type: 'object', properties: { issueKey: { type: 'string', description: 'JIRA issue key (e.g., ABC-123)' }, fields: { type: 'array', items: { type: 'string' }, description: 'Specific fields to retrieve (optional)' }, }, required: ['issueKey'], }, }, - src/index.ts:329-339 (registration)Dispatch handler in the callTool MCP request handler that validates arguments using the schema and invokes the readJiraIssue function.
case 'read_jira_issue': { const validatedArgs = validateInput<ReadJiraIssueInput>(readJiraIssueSchema, args, 'read_jira_issue'); return { content: [ { type: 'text', text: JSON.stringify(await readJiraIssue(validatedArgs), null, 2), }, ], }; } - src/tools/jira-issues.ts:6-11 (helper)Singleton helper function to lazily initialize and return the JiraClient instance.
const getJiraClient = (): JiraClient => { if (!jiraClient) { jiraClient = new JiraClient(); } return jiraClient; };