create-issue
Create new issues in GitHub repositories to report bugs, request features, or track tasks directly through the GitHub MCP Server.
Instructions
Create a new issue in a GitHub repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner (username or organization) | |
| repo | Yes | Repository name | |
| title | Yes | Issue title | |
| body | Yes | Issue body | |
| labels | No | Labels to apply to the issue |
Implementation Reference
- src/tools.ts:278-319 (handler)The handler function that implements the 'create-issue' tool logic. It uses the Octokit client to create a new issue in a GitHub repository and returns the issue details or an error message.const createIssue = async (args: CreateIssueArgs) => { const { owner, repo, title, body, labels = [] } = args; try { const response = await octokit.rest.issues.create({ owner, repo, title, body, labels, }); return { content: [ { type: "text", text: JSON.stringify( { number: response.data.number, title: response.data.title, url: response.data.html_url, created_at: response.data.created_at, message: "Issue created successfully", }, null, 2 ), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred'; return { content: [ { type: "text", text: `Error creating issue: ${errorMessage}`, }, ], }; } };
- src/tools.ts:78-110 (schema)The schema definition for the 'create-issue' tool, including inputSchema with properties for owner, repo, title, body, and optional labels."create-issue": { name: "create-issue", description: "Create a new issue in a GitHub repository", inputSchema: { type: "object", properties: { owner: { type: "string", description: "Repository owner (username or organization)", }, repo: { type: "string", description: "Repository name", }, title: { type: "string", description: "Issue title", }, body: { type: "string", description: "Issue body", }, labels: { type: "array", items: { type: "string" }, description: "Labels to apply to the issue", } }, required: ["owner", "repo", "title", "body"], }, },
- src/tools.ts:322-327 (registration)Export of toolHandlers object that maps tool names to their handler functions, including 'create-issue' to createIssue.export const toolHandlers = { "search-repos": searchRepos, "get-repo-info": getRepoInfo, "list-issues": listIssues, "create-issue": createIssue, };
- src/handlers.ts:19-21 (registration)Registration of ListToolsRequestSchema handler, which exposes all tool schemas (including create-issue) via Object.values(tools).server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.values(tools) }));
- src/handlers.ts:22-32 (registration)Registration of CallToolRequestSchema handler, which dispatches to the appropriate tool handler (including createIssue for 'create-issue') based on name.server.setRequestHandler(CallToolRequestSchema, async (request) => { type ToolHandlerKey = keyof typeof toolHandlers; const { name, arguments: params } = request.params ?? {}; const handler = toolHandlers[name as ToolHandlerKey]; if (!handler) throw new Error("tool not found"); type HandlerParams = Parameters<typeof handler>; return handler(params as any); }) }