Skip to main content
Glama

add_pr_comment

Add comments to Bitbucket pull requests, including inline comments on specific code lines, to provide feedback and collaborate on code changes.

Instructions

Add a comment to a pull request.

Can add general comments or inline comments on specific lines.

Args:
    repo_slug: Repository slug
    pr_id: Pull request ID
    content: Comment content (markdown supported)
    file_path: File path for inline comment (optional)
    line: Line number for inline comment (optional, requires file_path)

Returns:
    Created comment info

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_slugYes
pr_idYes
contentYes
file_pathNo
lineNo

Implementation Reference

  • MCP tool handler for 'add_pr_comment'. Calls BitbucketClient to post a comment (general or inline) to a pull request and returns the created comment info.
    @mcp.tool()
    @handle_bitbucket_error
    @formatted
    def add_pr_comment(
        repo_slug: str,
        pr_id: int,
        content: str,
        file_path: Optional[str] = None,
        line: Optional[int] = None,
    ) -> dict:
        """Add a comment to a pull request.
    
        Can add general comments or inline comments on specific lines.
    
        Args:
            repo_slug: Repository slug
            pr_id: Pull request ID
            content: Comment content (markdown supported)
            file_path: File path for inline comment (optional)
            line: Line number for inline comment (optional, requires file_path)
    
        Returns:
            Created comment info
        """
        client = get_client()
        inline = None
        if file_path and line:
            inline = {"path": file_path, "to": line}
    
        result = client.add_pr_comment(
            repo_slug=repo_slug,
            pr_id=pr_id,
            content=content,
            inline=inline,
        )
        return {
            "id": result.get("id"),
            "content": result.get("content", {}).get("raw", ""),
            "inline": inline,
        }
  • BitbucketClient helper method that makes the actual API POST request to add a comment to a PR, constructing the payload and handling response.
    def add_pr_comment(
        self,
        repo_slug: str,
        pr_id: int,
        content: str,
        inline: Optional[dict] = None,
    ) -> dict[str, Any]:
        """Add a comment to a pull request.
    
        Args:
            repo_slug: Repository slug
            pr_id: Pull request ID
            content: Comment content (markdown supported)
            inline: Inline comment location (optional)
                    {"path": "file.py", "to": 10} for line comment
    
        Returns:
            Created comment info
        """
        payload = {
            "content": {"raw": content}
        }
        if inline:
            payload["inline"] = inline
    
        result = self._request(
            "POST",
            self._repo_path(repo_slug, "pullrequests", str(pr_id), "comments"),
            json=payload,
        )
        return self._require_result(result, "add comment to PR", f"#{pr_id}")
  • src/server.py:939-939 (registration)
    The @mcp.tool() decorator registers the add_pr_comment function as an MCP tool.
    @mcp.tool()

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/JaviMaligno/mcp-server-bitbucket'

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