create_ticket
Create new Jira tickets directly from Cursor editor by specifying summary, description, project key, and issue type.
Instructions
Create a new Jira ticket
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ticket | Yes |
Implementation Reference
- src/server.ts:277-310 (handler)The handler function for the create_ticket tool. It validates the Jira configuration, constructs the issue fields from the input ticket, optionally adds a parent link, creates the issue using the Jira API, and returns a success message with the new ticket key or an error message.async ({ ticket }: { ticket: JiraTicket }) => { const configError = validateJiraConfig(); if (configError) { return { content: [{ type: "text", text: `Configuration error: ${configError}` }], }; } try { const fields: any = { project: { key: ticket.projectKey }, summary: ticket.summary, description: ticket.description, issuetype: { name: ticket.issueType }, }; // Add parent/epic link if specified if (ticket.parent) { fields.parent = { key: ticket.parent }; } const newTicket = await jira.issues.createIssue({ fields: fields, }); return { content: [{ type: "text", text: `Created ticket: ${newTicket.key}` }], }; } catch (error) { return { content: [{ type: "text", text: `Failed to create ticket: ${(error as Error).message}` }], }; } }
- src/server.ts:49-55 (schema)Zod schema used to validate the input 'ticket' parameter for the create_ticket tool.const TicketSchema = z.object({ summary: z.string().describe("The ticket summary"), description: z.string().describe("The ticket description"), projectKey: z.string().describe("The project key (e.g., PROJECT)"), issueType: z.string().describe("The type of issue (e.g., Task, Bug)"), parent: z.string().optional().describe("The parent/epic key (for next-gen projects)"), });
- src/server.ts:271-311 (registration)The MCP server.tool() call that registers the create_ticket tool, specifying its name, description, input schema, and handler function.server.tool( "create_ticket", "Create a new Jira ticket", { ticket: TicketSchema, }, async ({ ticket }: { ticket: JiraTicket }) => { const configError = validateJiraConfig(); if (configError) { return { content: [{ type: "text", text: `Configuration error: ${configError}` }], }; } try { const fields: any = { project: { key: ticket.projectKey }, summary: ticket.summary, description: ticket.description, issuetype: { name: ticket.issueType }, }; // Add parent/epic link if specified if (ticket.parent) { fields.parent = { key: ticket.parent }; } const newTicket = await jira.issues.createIssue({ fields: fields, }); return { content: [{ type: "text", text: `Created ticket: ${newTicket.key}` }], }; } catch (error) { return { content: [{ type: "text", text: `Failed to create ticket: ${(error as Error).message}` }], }; } } );
- src/server.ts:32-38 (schema)TypeScript interface defining the structure of the JiraTicket type used in the create_ticket handler's type annotation.interface JiraTicket { summary: string; description: string; projectKey: string; issueType: string; parent?: string; // Optional parent/epic key for next-gen projects }
- src/server.ts:90-95 (helper)Helper function called by the handler to validate that required Jira environment variables are set before attempting to create a ticket.function validateJiraConfig(): string | null { if (!process.env.JIRA_HOST) return "JIRA_HOST environment variable is not set"; if (!process.env.JIRA_EMAIL) return "JIRA_EMAIL environment variable is not set"; if (!process.env.JIRA_API_TOKEN) return "JIRA_API_TOKEN environment variable is not set"; return null; }