add_comment_inline
Add inline comments to specific lines in pull request diffs for code review feedback, questions, or discussions during Bitbucket Server code reviews.
Instructions
Add an inline comment (to specific lines) to the diff of 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. | |
| filePath | Yes | Path to the file in the repository where the comment should be added (e.g., "src/main.py", "README.md"). | |
| line | Yes | Line number in the file to attach the comment to (1-based). | |
| lineType | Yes | Type of change the comment is associated with: ADDED for additions, REMOVED for deletions. |
Implementation Reference
- src/index.ts:796-827 (handler)Core handler function that implements the logic for adding an inline comment to a specific line in a pull request diff. Validates parameters, constructs the API payload with anchor for inline positioning, calls Bitbucket API, logs response, and returns the result.private async addCommentInline(params: PullRequestParams, options: InlineCommentOptions) { const { project, repository, prId } = params; if (!project || !repository || !prId || !options.filePath || !options.line || !options.lineType) { throw new McpError( ErrorCode.InvalidParams, 'Project, repository, prId, filePath, line, and lineType 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, anchor: { path: options.filePath, lineType: options.lineType, line: options.line, diffType: 'EFFECTIVE', fileType: 'TO',} } ); logger.error(response); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }] }; }
- src/index.ts:274-287 (schema)JSON input schema for the add_comment_inline tool, specifying properties, descriptions, types, enums, and required fields for parameter validation.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.' }, filePath: { type: 'string', description: 'Path to the file in the repository where the comment should be added (e.g., "src/main.py", "README.md").' }, line: { type: 'number', description: 'Line number in the file to attach the comment to (1-based).' }, lineType: { type: 'string', enum: ['ADDED', 'REMOVED'], description: 'Type of change the comment is associated with: ADDED for additions, REMOVED for deletions.' } }, required: ['repository', 'prId', 'text', 'filePath', 'line', 'lineType'] }
- src/index.ts:42-60 (schema)TypeScript interfaces defining the parameter structures used by the add_comment_inline handler, including PullRequestParams, CommentOptions, and InlineCommentOptions.interface PullRequestParams extends RepositoryParams { prId?: number; } interface MergeOptions { message?: string; strategy?: 'merge-commit' | 'squash' | 'fast-forward'; } interface CommentOptions { text: string; parentId?: number; } interface InlineCommentOptions extends CommentOptions { filePath: string; line: number; lineType: 'ADDED' | 'REMOVED'; }
- src/index.ts:271-288 (registration)Tool object registration in the ListToolsRequestSchema response array, including name, description, and input schema.{ name: 'add_comment_inline', description: 'Add an inline comment (to specific lines) to the diff of 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.' }, filePath: { type: 'string', description: 'Path to the file in the repository where the comment should be added (e.g., "src/main.py", "README.md").' }, line: { type: 'number', description: 'Line number in the file to attach the comment to (1-based).' }, lineType: { type: 'string', enum: ['ADDED', 'REMOVED'], description: 'Type of change the comment is associated with: ADDED for additions, REMOVED for deletions.' } }, required: ['repository', 'prId', 'text', 'filePath', 'line', 'lineType'] } },
- src/index.ts:492-505 (registration)Switch case registration in the CallToolRequestSchema handler that processes arguments, resolves project, and invokes the addCommentInline handler.case 'add_comment_inline': { const commentPrParams: PullRequestParams = { project: getProject(args.project as string), repository: args.repository as string, prId: args.prId as number }; return await this.addCommentInline(commentPrParams, { text: args.text as string, parentId: args.parentId as number, filePath: args.filePath as string, line: args.line as number, lineType: args.lineType as 'ADDED' | 'REMOVED' }); }