Skip to main content
Glama
kornbed

Jira MCP Server for Cursor

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
NameRequiredDescriptionDefault
ticketYes

Implementation Reference

  • 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}` }],
        };
      }
    }
  • 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}` }],
          };
        }
      }
    );
  • 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
    }
  • 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;
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kornbed/jira-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server