create_issue
Create a new GitHub issue with title, body, emoji, labels, and assignees to add tasks to a Kanban board for automated task management.
Instructions
新しいissueを作成します
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Gitリポジトリの絶対パス | |
| title | Yes | issueのタイトル | |
| emoji | No | タイトルの先頭に付与するユニークな絵文字 | |
| body | No | issueの本文(## の先頭には絵文字を付与して可読性を上げて) | |
| labels | No | issueのラベル | |
| assignees | No | アサインするユーザー |
Implementation Reference
- src/handlers/issue-handlers.ts:46-98 (handler)The main handler function for 'create_issue'. Uses `gh issue create` CLI command with title, body (written to temp file), labels, assignees, and optional emoji prefix. Also ensures labels exist before creating the issue.
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)Input schema for 'create_issue' defining properties: path (repo absolute path), title (required), emoji, body, labels, and 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:46-50 (registration)Registration of the 'create_issue' tool in the server's ListToolsRequestSchema handler, with its description and inputSchema.
{ name: 'create_issue', description: '新しいissueを作成します', inputSchema: createIssueSchema, }, - src/handlers/tool-handlers.ts:47-59 (registration)Dispatch case in handleToolRequest that validates title presence and calls handleCreateIssue with parsed arguments.
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 `CreateIssueArgs` defining the shape of arguments for the create_issue handler.
export interface CreateIssueArgs { path: string; // Gitリポジトリの絶対パス title: string; emoji?: string; body?: string; labels?: string[]; assignees?: string[]; }