add-issue-comment
Add a comment to an existing GitHub issue by specifying the repository owner, repository name, issue number, and comment content.
Instructions
Add a comment to an existing issue
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | ||
| issue_number | Yes | ||
| owner | Yes | ||
| repo | Yes |
Implementation Reference
- src/tools/issues.ts:230-254 (handler)The core handler function for the 'add-issue-comment' tool. It validates input using AddIssueCommentSchema, uses the GitHub API to create a comment on the specified issue, and returns the created comment details.export async function addIssueComment(args: unknown): Promise<any> { const { owner, repo, issue_number, body } = AddIssueCommentSchema.parse(args); const github = getGitHubApi(); return tryCatchAsync(async () => { const { data } = await github.getOctokit().issues.createComment({ owner, repo, issue_number, body, }); return { id: data.id, user: data.user ? { login: data.user.login, id: data.user.id, } : null, created_at: data.created_at, updated_at: data.updated_at, body: data.body, url: data.html_url, }; }, 'Failed to add issue comment'); }
- src/utils/validation.ts:109-112 (schema)Zod schema used for input validation in the addIssueComment handler. Extends OwnerRepoSchema with issue_number and body requirements.export const AddIssueCommentSchema = OwnerRepoSchema.extend({ issue_number: z.number().int().positive(), body: z.string().min(1, 'Comment body is required'), });
- src/server.ts:1221-1223 (registration)Switch case in the CallToolRequestSchema handler that dispatches to the addIssueComment function.case 'add-issue-comment': result = await addIssueComment(parsedArgs); break;
- src/server.ts:669-691 (registration)Tool registration in the ListToolsRequestSchema response, including name, description, and input schema (mirrors the Zod schema).{ name: 'add-issue-comment', description: 'Add a comment to an existing issue', inputSchema: { type: 'object', properties: { owner: { type: 'string', }, repo: { type: 'string', }, issue_number: { type: 'number', }, body: { type: 'string', }, }, required: ['owner', 'repo', 'issue_number', 'body'], additionalProperties: false, }, },
- src/server.ts:672-691 (schema)JSON Schema definition for the tool input, provided in the tool list response.inputSchema: { type: 'object', properties: { owner: { type: 'string', }, repo: { type: 'string', }, issue_number: { type: 'number', }, body: { type: 'string', }, }, required: ['owner', 'repo', 'issue_number', 'body'], additionalProperties: false, }, },