add_comment
Add comments to Bitbucket pull requests for code review, feedback, questions, or threaded discussions. Supports Markdown formatting for clear communication.
Instructions
Add a comment to a pull request for code review, feedback, questions, or discussion. Use this to provide review feedback, ask questions about specific changes, suggest improvements, or participate in code review discussions. Supports threaded conversations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | No | Bitbucket project key. If omitted, uses BITBUCKET_DEFAULT_PROJECT environment variable. | |
| repository | Yes | Repository slug containing the pull request. | |
| prId | Yes | Pull request ID to comment on. | |
| text | Yes | Comment text content. Supports Markdown formatting for code blocks, links, and emphasis. | |
| parentId | No | ID of parent comment to reply to. Omit for top-level comments. |
Implementation Reference
- src/index.ts:771-794 (handler)The core handler function that executes the 'add_comment' tool logic by making a POST request to the Bitbucket API to add a comment to a pull request.private async addComment(params: PullRequestParams, options: CommentOptions) { const { project, repository, prId } = params; if (!project || !repository || !prId) { throw new McpError( ErrorCode.InvalidParams, 'Project, repository, and prId are required' ); } const { text, parentId } = options; const response = await this.api.post( `/projects/${project}/repos/${repository}/pull-requests/${prId}/comments`, { text, parent: parentId ? { id: parentId } : undefined } ); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }] }; }
- src/index.ts:256-270 (schema)The input schema and metadata definition for the 'add_comment' tool.{ name: 'add_comment', description: 'Add a comment to a pull request for code review, feedback, questions, or discussion. Use this to provide review feedback, ask questions about specific changes, suggest improvements, or participate in code review discussions. Supports threaded conversations.', inputSchema: { type: 'object', properties: { project: { type: 'string', description: 'Bitbucket project key. If omitted, uses BITBUCKET_DEFAULT_PROJECT environment variable.' }, repository: { type: 'string', description: 'Repository slug containing the pull request.' }, prId: { type: 'number', description: 'Pull request ID to comment on.' }, text: { type: 'string', description: 'Comment text content. Supports Markdown formatting for code blocks, links, and emphasis.' }, parentId: { type: 'number', description: 'ID of parent comment to reply to. Omit for top-level comments.' } }, required: ['repository', 'prId', 'text'] } },
- src/index.ts:480-490 (registration)The switch case in the CallToolRequestSchema handler that routes 'add_comment' calls to the addComment method.case 'add_comment': { const commentPrParams: PullRequestParams = { project: getProject(args.project as string), repository: args.repository as string, prId: args.prId as number }; return await this.addComment(commentPrParams, { text: args.text as string, parentId: args.parentId as number }); }