create_issue
Create a new Jira issue by specifying the project, summary, and description to manage tasks or bugs.
Instructions
Create an issue in Jira
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectKeyOrId | Yes | The key or ID of the project | |
| summary | Yes | The summary of the issue | |
| description | Yes | The description of the issue |
Implementation Reference
- src/tools/create-issue.ts:33-53 (handler)The main handler function that creates a Jira issue via POST to /rest/api/2/issue. Builds a payload with project key, issue type (Task), summary, and description, then calls $jiraJson to make the HTTP request.
export async function createIssue(input: CreateIssueInput) { const url = new URL(`/rest/api/2/issue`, env.JIRA_BASE_URL); const payload = { fields: { project: { key: input.projectKeyOrId }, issuetype: { name: ISSUE_TYPES.TASK }, summary: input.summary, description: input.description, }, }; const json = await $jiraJson(url.toString(), { method: "POST", body: JSON.stringify(payload), }); if (json.isErr()) return err(json.error); return ok(json.value); } - src/tools/create-issue.ts:19-23 (schema)Zod schema defining the input for create_issue: projectKeyOrId (string), summary (string), description (string).
export const createIssueInputSchema = z.object({ projectKeyOrId: z.string().describe("The key or ID of the project"), summary: z.string().describe("The summary of the issue"), description: z.string().describe("The description of the issue"), }); - src/app.ts:28-48 (registration)Imports CREATE_ISSUE_TOOL, createIssue, and createIssueInputSchema from create-issue.ts, and registers the tool in the tools array at line 47.
import { CREATE_ISSUE_TOOL, createIssue, createIssueInputSchema, } from "./tools/create-issue.js"; const server = new Server( { name: "Jira MCP Server", version: VERSION }, { capabilities: { tools: {} } }, ); export const tools = [ // list LIST_PROJECTS_TOOL, LIST_BOARDS_TOOL, LIST_SPRINTS_FROM_BOARD_TOOL, LIST_ISSUES_FROM_SPRINT_TOOL, // create CREATE_ISSUE_TOOL, ] satisfies Tool[]; - src/app.ts:169-194 (registration)The tool call handler in app.ts that routes 'create_issue' to validate input via createIssueInputSchema.safeParse and execute the createIssue function.
if (name === CREATE_ISSUE_TOOL.name) { const input = createIssueInputSchema.safeParse(args); if (!input.success) { return { isError: true, content: [{ type: "text", text: "Invalid input" }], }; } const result = await createIssue(input.data); if (result.isErr()) { console.error(result.error.message); return { isError: true, content: [{ type: "text", text: "An error occurred" }], }; } return { content: [ { type: "text", text: JSON.stringify(result.value, null, 2) }, ], }; } - src/utils/jira-fetch.ts:30-42 (helper)The $jiraJson helper function used by createIssue to make authenticated HTTP requests to the Jira API and parse JSON responses.
export async function $jiraJson(url: string, options?: RequestInit) { try { const response = await $jira(url, options); if (response.isErr()) return err(response.error); const json = await response.value.json(); return ok(json); } catch (error) { return err(new Error(`Failed to fetch ${url}: ${error}`)); } }