update_issue
Update an existing GitHub issue's title, body, state, labels, assignees, or emoji with new values using the repository path and issue number. Enables modifying issue details for Kanban workflow management.
Instructions
既存のissueを更新します
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Gitリポジトリの絶対パス | |
| issue_number | Yes | issue番号 | |
| title | No | 新しいタイトル | |
| emoji | No | タイトルの先頭に付与する絵文字 | |
| body | No | 新しい本文 | |
| state | No | 新しい状態 | |
| labels | No | 新しいラベル | |
| assignees | No | 新しいアサイン |
Implementation Reference
- src/handlers/issue-handlers.ts:103-151 (handler)The main handler function for update_issue. Uses `gh issue edit` and `gh issue close/reopen` to update an existing GitHub issue. Handles title (with optional emoji), body, labels, assignees, and state changes.
export async function handleUpdateIssue(args: UpdateIssueArgs): Promise<ToolResponse> { const { owner, repo } = await getRepoInfo(args); // タイトルが更新される場合は絵文字を付与(指定がある場合) const titleFlag = args.title ? `--title "${args.emoji ? `${args.emoji} ${args.title}` : args.title}"` : ''; const labelsFlag = args.labels?.length ? `--add-label ${args.labels.join(',')}` : ''; const assigneesFlag = args.assignees?.length ? `--add-assignee ${args.assignees.join(',')}` : ''; const tempFile = 'update_body.md'; let bodyFlag = ''; try { // 状態の更新を処理 if (args.state) { const command = args.state === 'closed' ? 'close' : 'reopen'; await execAsync( `gh issue ${command} ${args.issue_number} --repo ${owner}/${repo}` ); } // その他の更新を処理 if (args.title || args.body || args.labels?.length || args.assignees?.length) { if (args.body) { const fullPath = await writeToTempFile(args.body, tempFile); bodyFlag = `--body-file "${fullPath}"`; } await execAsync( `gh issue edit ${args.issue_number} --repo ${owner}/${repo} ${titleFlag} ${bodyFlag} ${labelsFlag} ${assigneesFlag}` ); } const { stdout: issueData } = await execAsync( `gh issue view ${args.issue_number} --repo ${owner}/${repo} --json number,title,state,url` ); return { content: [ { type: 'text', text: issueData, }, ], }; } finally { if (args.body) { await removeTempFile(tempFile); } } } - src/schemas/issue-schemas.ts:61-105 (schema)JSON Schema definition for update_issue input. Defines fields: path, issue_number (required), title, emoji, body, state (open/closed), labels, assignees.
export const updateIssueSchema = { type: 'object', properties: { path: { type: 'string', description: 'Gitリポジトリの絶対パス', }, issue_number: { type: 'number', description: 'issue番号', }, title: { type: 'string', description: '新しいタイトル', }, emoji: { type: 'string', description: 'タイトルの先頭に付与する絵文字', }, body: { type: 'string', description: '新しい本文', }, state: { type: 'string', enum: ['open', 'closed'], description: '新しい状態', }, labels: { type: 'array', items: { type: 'string', }, description: '新しいラベル', }, assignees: { type: 'array', items: { type: 'string', }, description: '新しいアサイン', }, }, required: ['issue_number'], }; - src/server.ts:51-55 (registration)Registration of the 'update_issue' tool in the ListToolsRequestSchema handler, with its description and inputSchema reference.
{ name: 'update_issue', description: '既存のissueを更新します', inputSchema: updateIssueSchema, }, - src/types.ts:16-25 (helper)TypeScript interface UpdateIssueArgs used as the parameter type for handleUpdateIssue.
export interface UpdateIssueArgs { path: string; // Gitリポジトリの絶対パス issue_number: number; title?: string; emoji?: string; body?: string; state?: 'open' | 'closed'; labels?: string[]; assignees?: string[]; } - src/handlers/tool-handlers.ts:60-74 (handler)Routing logic in handleToolRequest that maps 'update_issue' tool name to handleUpdateIssue, extracting and casting arguments.
case 'update_issue': { if (!args?.issue_number) { throw new McpError(ErrorCode.InvalidParams, 'Issue number is required'); } return await handleUpdateIssue({ path: args.path as string, issue_number: Number(args.issue_number), title: args?.title as string | undefined, emoji: args?.emoji as string | undefined, body: args?.body as string | undefined, state: args?.state as 'open' | 'closed' | undefined, labels: args?.labels as string[] | undefined, assignees: args?.assignees as string[] | undefined, }); }