create_issue
Create a new GitHub issue with a title, description, assignees, labels, and milestone to track tasks or report problems.
Instructions
Create a new issue in a GitHub repository.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner | |
| repo | Yes | Repository name | |
| title | Yes | Issue title | |
| body | No | Issue body content | |
| assignees | No | Usernames to assign to this issue | |
| labels | No | Labels to apply to this issue | |
| milestone | No | Milestone number |
Implementation Reference
- src/tools/issues.ts:189-214 (handler)The async handler function that executes the 'create_issue' tool logic. It calls octokit.rest.issues.create() with the provided parameters (owner, repo, title, body, assignees, labels, milestone) and returns a formatted text response with the created issue details.
async ({ owner, repo, title, body, assignees, labels, milestone }) => { try { const response = await octokit.rest.issues.create({ owner, repo, title, body, assignees, labels, milestone, }) const i = response.data let text = `Issue created: **#${i.number}: ${i.title}**\n` text += `URL: ${i.html_url}\n` text += `State: ${i.state}\n` if (i.labels && i.labels.length > 0) text += `Labels: ${i.labels.map(l => typeof l === "string" ? l : l.name).join(", ")}\n` if (i.assignees && i.assignees.length > 0) text += `Assignees: ${i.assignees.map(a => a.login).join(", ")}\n` return { content: [{ type: "text", text }], } } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.message}` }], } } }, - src/tools/issues.ts:174-188 (schema)Zod schema definitions for the 'create_issue' tool inputs: owner (string), repo (string), title (string), body (optional string), assignees (optional array of strings), labels (optional array of strings), milestone (optional number).
{ owner: z.string().describe("Repository owner"), repo: z.string().describe("Repository name"), title: z.string().describe("Issue title"), body: z.string().optional().describe("Issue body content"), assignees: z .array(z.string()) .optional() .describe("Usernames to assign to this issue"), labels: z .array(z.string()) .optional() .describe("Labels to apply to this issue"), milestone: z.number().optional().describe("Milestone number"), }, - src/tools/issues.ts:170-215 (registration)The registration of the 'create_issue' tool via server.tool(), including the name 'create_issue', description 'Create a new issue in a GitHub repository.', the Zod schema, and the handler function.
// Tool: Create Issue server.tool( "create_issue", "Create a new issue in a GitHub repository.", { owner: z.string().describe("Repository owner"), repo: z.string().describe("Repository name"), title: z.string().describe("Issue title"), body: z.string().optional().describe("Issue body content"), assignees: z .array(z.string()) .optional() .describe("Usernames to assign to this issue"), labels: z .array(z.string()) .optional() .describe("Labels to apply to this issue"), milestone: z.number().optional().describe("Milestone number"), }, async ({ owner, repo, title, body, assignees, labels, milestone }) => { try { const response = await octokit.rest.issues.create({ owner, repo, title, body, assignees, labels, milestone, }) const i = response.data let text = `Issue created: **#${i.number}: ${i.title}**\n` text += `URL: ${i.html_url}\n` text += `State: ${i.state}\n` if (i.labels && i.labels.length > 0) text += `Labels: ${i.labels.map(l => typeof l === "string" ? l : l.name).join(", ")}\n` if (i.assignees && i.assignees.length > 0) text += `Assignees: ${i.assignees.map(a => a.login).join(", ")}\n` return { content: [{ type: "text", text }], } } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.message}` }], } } }, ) - src/index.ts:4-4 (registration)Import of the registerIssueTools function from the tools/issues module.
import { registerIssueTools } from "./tools/issues.js" - src/index.ts:16-16 (registration)Call to registerIssueTools(server, octokit) which registers all issue tools including create_issue on the MCP server.
registerIssueTools(server, octokit)