create_issue
Create GitHub issues with titles, emojis, labels, assignees, and formatted bodies to enhance task management and readability on a Kanban board.
Instructions
新しいissueを作成します
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assignees | No | アサインするユーザー | |
| body | No | issueの本文(## の先頭には絵文字を付与して可読性を上げて) | |
| emoji | No | タイトルの先頭に付与するユニークな絵文字 | |
| labels | No | issueのラベル | |
| path | No | Gitリポジトリの絶対パス | |
| title | Yes | issueのタイトル |
Implementation Reference
- src/handlers/issue-handlers.ts:46-98 (handler)Main handler function that executes the create_issue tool logic: validates args, ensures labels exist, creates temp file for body if needed, runs `gh issue create`, fetches issue details, returns response.export async function handleCreateIssue(args: CreateIssueArgs): Promise<ToolResponse> { const { owner, repo } = await getRepoInfo(args); const assigneesFlag = args.assignees?.length ? `--assignee ${args.assignees.join(',')}` : ''; const tempFile = 'issue_body.md'; let bodyFlag = ''; try { // ラベルの存在確認と作成 if (args.labels?.length) { const existingLabels = await getExistingLabels(args.path); for (const label of args.labels) { if (!existingLabels.includes(label)) { await createLabel(args.path, label); } } } const labelsFlag = args.labels?.length ? `--label ${args.labels.join(',')}` : ''; if (args.body) { const fullPath = await writeToTempFile(args.body, tempFile); bodyFlag = `--body-file "${fullPath}"`; } // タイトルに絵文字を付与(指定がある場合) const titleWithEmoji = args.emoji ? `${args.emoji} ${args.title}` : args.title; const { stdout } = await execAsync( `gh issue create --repo ${owner}/${repo} --title "${titleWithEmoji}" ${bodyFlag} ${labelsFlag} ${assigneesFlag}` ); // URLから issue number を抽出 const issueUrl = stdout.trim(); const issueNumber = issueUrl.split('/').pop(); // 作成したissueの詳細情報を取得 const { stdout: issueData } = await execAsync( `gh issue view ${issueNumber} --repo ${owner}/${repo} --json number,title,url` ); return { content: [ { type: 'text', text: issueData, }, ], }; } finally { if (args.body) { await removeTempFile(tempFile); } } }
- src/schemas/issue-schemas.ts:24-59 (schema)JSON schema defining the input parameters for the create_issue tool, including path, title (required), emoji, body, labels, assignees.export const createIssueSchema = { type: 'object', properties: { path: { type: 'string', description: 'Gitリポジトリの絶対パス', }, title: { type: 'string', description: 'issueのタイトル', }, emoji: { type: 'string', description: 'タイトルの先頭に付与するユニークな絵文字', }, body: { type: 'string', description: 'issueの本文(## の先頭には絵文字を付与して可読性を上げて)', }, labels: { type: 'array', items: { type: 'string', }, description: 'issueのラベル', }, assignees: { type: 'array', items: { type: 'string', }, description: 'アサインするユーザー', } }, required: ['title'], };
- src/server.ts:47-50 (registration)Registration of the create_issue tool in the MCP server's listTools response, specifying name, description, and inputSchema.name: 'create_issue', description: '新しいissueを作成します', inputSchema: createIssueSchema, },
- src/handlers/tool-handlers.ts:47-59 (handler)Dispatch handler in the main tool request switch statement that validates title and calls the specific handleCreateIssue function.case 'create_issue': { if (!args?.title) { throw new McpError(ErrorCode.InvalidParams, 'Title is required'); } return await handleCreateIssue({ path: args.path as string, title: args.title as string, emoji: args?.emoji as string | undefined, body: args?.body as string | undefined, labels: args?.labels as string[] | undefined, assignees: args?.assignees as string[] | undefined, }); }
- src/types.ts:7-14 (helper)TypeScript interface defining the arguments for create_issue handler.export interface CreateIssueArgs { path: string; // Gitリポジトリの絶対パス title: string; emoji?: string; body?: string; labels?: string[]; assignees?: string[]; }