create_github_issue
Create GitHub issues with structured templates, summaries, technical notes, and labels automatically generated from code changes.
Instructions
Cria uma issue no GitHub usando Octokit
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assignees | No | ||
| body | No | ||
| labels | No | ||
| owner | No | ||
| repo | No | ||
| title | Yes |
Implementation Reference
- src/index.ts:119-134 (handler)The asynchronous handler function that creates a GitHub issue using the Octokit client. It takes owner, repo, title, body, labels, and assignees as input, posts to the GitHub API, and returns the issue URL.async ({ owner, repo, title, body, labels, assignees }) => { const octokit = getOctokit() const res = await octokit.request('POST /repos/{owner}/{repo}/issues', { owner, repo, title, body, labels, assignees, }) const url = res.data.html_url return { content: [{ type: 'text', text: `Issue criada: #${url}` }], } }
- src/index.ts:106-117 (schema)Zod input schema for the create_github_issue tool, defining parameters like owner, repo, title, body, labels, and assignees with defaults from environment variables.inputSchema: { owner: z.string().default(process.env.DEFAULT_OWNER || ''), repo: z.string().default(process.env.DEFAULT_REPO || ''), title: z.string(), body: z.string().default(''), labels: z.array(z.string()).default([]), assignees: z .array(z.string()) .default( process.env.DEFAULT_ASSIGNEE ? [process.env.DEFAULT_ASSIGNEE] : [] ), },
- src/index.ts:101-135 (registration)Registration of the 'create_github_issue' tool with the MCP server, including title, description, input schema, and the handler function.server.registerTool( 'create_github_issue', { title: 'Create GitHub Issue', description: 'Cria uma issue no GitHub usando Octokit', inputSchema: { owner: z.string().default(process.env.DEFAULT_OWNER || ''), repo: z.string().default(process.env.DEFAULT_REPO || ''), title: z.string(), body: z.string().default(''), labels: z.array(z.string()).default([]), assignees: z .array(z.string()) .default( process.env.DEFAULT_ASSIGNEE ? [process.env.DEFAULT_ASSIGNEE] : [] ), }, }, async ({ owner, repo, title, body, labels, assignees }) => { const octokit = getOctokit() const res = await octokit.request('POST /repos/{owner}/{repo}/issues', { owner, repo, title, body, labels, assignees, }) const url = res.data.html_url return { content: [{ type: 'text', text: `Issue criada: #${url}` }], } } )
- src/helpers/github.ts:17-25 (helper)Helper function that initializes and returns an authenticated Octokit instance using the GITHUB_TOKEN from environment variables.export function getOctokit() { const token = env('GITHUB_TOKEN') if (!token) { throw new Error('Missing GITHUB_TOKEN env') } return new Octokit({ auth: token }) }