Skip to main content
Glama
garc33

Bitbucket Server MCP

by garc33

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
NameRequiredDescriptionDefault
projectNoBitbucket project key. If omitted, uses BITBUCKET_DEFAULT_PROJECT environment variable.
repositoryYesRepository slug containing the pull request.
prIdYesPull request ID to comment on.
textYesComment text content. Supports Markdown formatting for code blocks, links, and emphasis.
parentIdNoID of parent comment to reply to. Omit for top-level comments.
filePathYesPath to the file in the repository where the comment should be added (e.g., "src/main.py", "README.md").
lineYesLine number in the file to attach the comment to (1-based).
lineTypeYesType of change the comment is associated with: ADDED for additions, REMOVED for deletions.

Implementation Reference

  • 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) }]
      };
    }
  • 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']
    }
  • 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'
      });
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'supports threaded conversations' and implies mutation ('Add'), but does not disclose other behavioral traits such as required permissions, rate limits, or what happens on success/failure. This leaves gaps for a mutation tool, though the purpose is clear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with the first sentence covering the core purpose and the second adding usage context. Every sentence adds value without redundancy, making it efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a mutation tool with 8 parameters and no annotations or output schema, the description is somewhat complete but lacks details on behavioral aspects like error handling or response format. It covers purpose and usage well but misses deeper contextual information needed for full agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema fully documents all 8 parameters. The description does not add any parameter-specific details beyond what the schema provides, such as examples or edge cases. This meets the baseline of 3, as the schema handles the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Add an inline comment'), target resource ('to the diff of a pull request'), and purpose ('for code review, feedback, questions, or discussion'). It distinguishes from the sibling 'add_comment' by specifying 'inline comment (to specific lines)' and mentions threaded conversations, providing clear differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool ('to provide review feedback, ask questions about specific changes, suggest improvements, or participate in code review discussions'), which gives clear context. However, it does not mention when not to use it or explicitly name alternatives like 'add_comment' for non-inline comments, which prevents a perfect score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/garc33/bitbucket-server-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server