add_pr_comment
Add comments to Bitbucket Cloud pull requests, including general feedback or inline comments on specific code lines to facilitate code review discussions.
Instructions
Add a comment to a pull request. Can be a general comment or an inline comment on a specific file/line.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | Yes | The workspace slug | |
| repo_slug | Yes | The repository slug | |
| pr_id | Yes | The pull request ID | |
| content | Yes | Comment content (markdown) | |
| path | No | File path for inline comment | |
| line | No | Line number for inline comment |
Implementation Reference
- src/tools/index.ts:538-554 (registration)Registration of the 'add_pr_comment' tool in the toolDefinitions array, including name, description, and input schema for MCP.{ name: 'add_pr_comment', description: 'Add a comment to a pull request. Can be a general comment or an inline comment on a specific file/line.', inputSchema: { type: 'object' as const, properties: { workspace: { type: 'string', description: 'The workspace slug' }, repo_slug: { type: 'string', description: 'The repository slug' }, pr_id: { type: 'number', description: 'The pull request ID' }, content: { type: 'string', description: 'Comment content (markdown)' }, path: { type: 'string', description: 'File path for inline comment' }, line: { type: 'number', description: 'Line number for inline comment' }, }, required: ['workspace', 'repo_slug', 'pr_id', 'content'], }, },
- src/tools/index.ts:131-138 (schema)Zod schema definition for validating inputs to the add_pr_comment tool.add_pr_comment: z.object({ workspace: z.string().describe('The workspace slug'), repo_slug: z.string().describe('The repository slug'), pr_id: z.number().describe('The pull request ID'), content: z.string().describe('Comment content (markdown)'), path: z.string().optional().describe('File path for inline comment'), line: z.number().optional().describe('Line number for inline comment'), }),
- src/tools/index.ts:968-978 (handler)Tool handler logic in ToolHandler.handleTool that parses arguments using the schema and delegates to PullRequestsAPI.addComment.case 'add_pr_comment': { const params = toolSchemas.add_pr_comment.parse(args); const inline = params.path ? { path: params.path, line: params.line } : undefined; return this.prs.addComment( params.workspace, params.repo_slug, params.pr_id, params.content, inline ); }
- src/api/pullrequests.ts:172-194 (handler)Core implementation of adding a PR comment via Bitbucket API POST request to /pullrequests/{pr_id}/comments endpoint, constructing request body for general or inline comments.async addComment( workspace: string, repo_slug: string, pr_id: number, content: string, inline?: { path: string; line?: number } ): Promise<BitbucketPRComment> { const body: Record<string, unknown> = { content: { raw: content }, }; if (inline) { body.inline = { path: inline.path, to: inline.line, }; } return this.client.post<BitbucketPRComment>( `/repositories/${workspace}/${repo_slug}/pullrequests/${pr_id}/comments`, body ); }