add_pull_request_comment
Adds a comment to a pull request in Backlog, specifying project, repository, pull request number, and content. Notifies specified users to streamline collaboration and feedback.
Instructions
Adds a comment to a pull request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Comment content | |
| notifiedUserId | No | User IDs to notify | |
| number | Yes | Pull request number | |
| projectIdOrKey | Yes | Project ID or project key | |
| repoIdOrName | Yes | Repository ID or name |
Implementation Reference
- src/tools/addPullRequestComment.ts:64-95 (handler)Handler function that destructures input parameters, resolves project ID or key and repository ID or name using utility functions, and calls the Backlog API's postPullRequestComments method to add the comment.importantFields: ['id', 'content', 'createdUser'], handler: async ({ projectId, projectKey, repoId, repoName, number, ...params }) => { const result = resolveIdOrKey( 'project', { id: projectId, key: projectKey }, t ); if (!result.ok) { throw result.error; } const repoRes = resolveIdOrName( 'repository', { id: repoId, name: repoName }, t ); if (!repoRes.ok) { throw repoRes.error; } return backlog.postPullRequestComments( result.value, String(repoRes.value), number, params ); },
- Zod schema defining the input parameters for the tool, including optional project ID/key, repo ID/name, required PR number and content, and optional notified user IDs.const addPullRequestCommentSchema = buildToolSchema((t) => ({ projectId: z .number() .optional() .describe( t( 'TOOL_ADD_PULL_REQUEST_COMMENT_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)' ) ), projectKey: z .string() .optional() .describe( t( 'TOOL_ADD_PULL_REQUEST_COMMENT_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')" ) ), repoId: z .number() .optional() .describe(t('TOOL_ADD_PULL_REQUEST_REPO_ID', 'Repository ID')), repoName: z .string() .optional() .describe(t('TOOL_ADD_PULL_REQUEST_REPO_NAME', 'Repository name')), number: z .number() .describe(t('TOOL_ADD_PULL_REQUEST_COMMENT_NUMBER', 'Pull request number')), content: z .string() .describe(t('TOOL_ADD_PULL_REQUEST_COMMENT_CONTENT', 'Comment content')), notifiedUserId: z .array(z.number()) .optional() .describe( t('TOOL_ADD_PULL_REQUEST_COMMENT_NOTIFIED_USER_ID', 'User IDs to notify') ), }));
- src/tools/tools.ts:120-136 (registration)The addPullRequestCommentTool is instantiated with backlog and translation helper, and registered within the 'git' toolset group in the allTools export.{ name: 'git', description: 'Tools for managing Git repositories and pull requests.', enabled: false, tools: [ getGitRepositoriesTool(backlog, helper), getGitRepositoryTool(backlog, helper), getPullRequestsTool(backlog, helper), getPullRequestsCountTool(backlog, helper), getPullRequestTool(backlog, helper), addPullRequestTool(backlog, helper), updatePullRequestTool(backlog, helper), getPullRequestCommentsTool(backlog, helper), addPullRequestCommentTool(backlog, helper), updatePullRequestCommentTool(backlog, helper), ], },