create_github_issues
Automate GitHub issue creation from analysis results. Specify repository owner, name, and optional issue numbers. Requires GitHub token.
Instructions
Create GitHub issues from analysis results. Requires GitHub token.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| issueNumbers | No | Issue numbers to create (optional, creates all issues if not specified) | |
| owner | Yes | GitHub repository owner | |
| repo | Yes | GitHub repository name |
Input Schema (JSON Schema)
{
"additionalProperties": false,
"properties": {
"issueNumbers": {
"description": "Issue numbers to create (optional, creates all issues if not specified)",
"items": {
"type": "number"
},
"type": "array"
},
"owner": {
"description": "GitHub repository owner",
"type": "string"
},
"repo": {
"description": "GitHub repository name",
"type": "string"
}
},
"required": [
"owner",
"repo"
],
"type": "object"
}
Implementation Reference
- src/tools/github-issues/handler.ts:26-82 (handler)Core handler function that parses issues from LAST_RESPONSE_OPENAI.json, filters by numbers if specified, and creates GitHub issues using Octokit.export async function handleGitHubIssues(options: GitHubIssuesOptions): Promise<string> { try { if (!options.githubToken) { throw new GitHubError( 'GitHub token is required. Please add your GitHub token to the MCP server configuration.' ); } const octokit = new Octokit({ auth: options.githubToken, }); // Парсим файл с результатами анализа const allIssues = await parseResponseFile( path.join(process.cwd(), 'LAST_RESPONSE_OPENAI.json') ); if (allIssues.length === 0) { return 'No issues found in the conversation file'; } // Фильтруем issues по номерам, если они указаны const issuesToCreate = options.issueNumbers ? allIssues.filter(issue => options.issueNumbers?.includes(issue.number)) : allIssues; if (issuesToCreate.length === 0) { return 'No matching issues found with the specified numbers'; } // Создаем issues const results = await Promise.all( issuesToCreate.map(async issue => { try { await octokit.issues.create({ owner: options.owner, repo: options.repo, title: `[#${issue.number}] ${issue.title}`, body: issue.body, labels: issue.labels, }); return `Created issue #${issue.number}: ${issue.title}`; } catch (error) { return `Failed to create issue #${issue.number}: ${ error instanceof Error ? error.message : String(error) }`; } }) ); return results.join('\n'); } catch (error) { if (error instanceof GitHubError) { throw error; } throw new GitHubError(`Failed to create GitHub issues: ${(error as Error).message}`); } }
- Input schema defining parameters for the tool: owner, repo, and optional issueNumbers.export const githubIssuesSchema = { type: 'object', properties: { owner: { type: 'string', description: 'GitHub repository owner', }, repo: { type: 'string', description: 'GitHub repository name', }, issueNumbers: { type: 'array', items: { type: 'number', }, description: 'Issue numbers to create (optional, creates all issues if not specified)', }, }, required: ['owner', 'repo'], additionalProperties: false, } as const;
- src/tools/github-issues/index.ts:5-52 (registration)Tool object definition with name 'create_github_issues', description, schema reference, and wrapper handler that checks token and delegates to core handler.export const githubIssuesTool: Tool = { name: 'create_github_issues', description: 'Create GitHub issues from analysis results. Requires GitHub token.', inputSchema: githubIssuesSchema, handler: async (args: Record<string, unknown>) => { try { const githubToken = process.env.GITHUB_PERSONAL_ACCESS_TOKEN; if (!githubToken) { return { content: [ { type: 'text', text: 'GitHub token is required. Please add GITHUB_PERSONAL_ACCESS_TOKEN to your MCP server configuration.', }, ], isError: true, }; } const options = { githubToken, owner: String(args.owner), repo: String(args.repo), issueNumbers: args.issueNumbers as number[] | undefined, }; const result = await handleGitHubIssues(options); return { content: [ { type: 'text', text: result, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error creating GitHub issues: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, };
- src/tools/index.ts:6-11 (registration)Main tools array registration including the githubIssuesTool.export const tools = [ codeCollectorTool, installBaseServersTool, codeAnalyzerTool, githubIssuesTool, ];
- Helper function to parse and extract issues from the LAST_RESPONSE_OPENAI.json file.async function parseResponseFile(filePath: string): Promise<ParsedIssue[]> { try { const content = await safeReadFile(filePath); const data = JSON.parse(content); return data.issues; } catch (error) { if (error instanceof GitHubError) { throw error; } throw new GitHubError(`Failed to parse conversation file: ${(error as Error).message}`); } }