Skip to main content
Glama
saidsef

GitHub PR Issue Analyser

by saidsef

add_inline_pr_comment

Add inline review comments to specific lines in GitHub pull request files for precise code feedback during collaborative development.

Instructions

Adds an inline review comment to a specific line in a file within a pull request on GitHub. Args: repo_owner (str): The owner of the repository. repo_name (str): The name of the repository. pr_number (int): The pull request number. path (str): The relative path to the file (e.g., 'src/main.py'). line (int): The line number in the file to comment on. comment_body (str): The content of the review comment. Returns: Dict[str, Any]: The JSON response from the GitHub API containing the comment data if successful. None: If an error occurs while adding the comment. Error Handling: Logs an error message and prints the traceback if the request fails or an exception is raised.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_ownerYes
repo_nameYes
pr_numberYes
pathYes
lineYes
comment_bodyYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function that implements adding an inline PR comment using GitHub API, including fetching PR head commit and posting the review comment.
    def add_inline_pr_comment(self, repo_owner: str, repo_name: str, pr_number: int, path: str, line: int, comment_body: str) -> Dict[str, Any]:
        """
        Adds an inline review comment to a specific line in a file within a pull request on GitHub.
        Args:
            repo_owner (str): The owner of the repository.
            repo_name (str): The name of the repository.
            pr_number (int): The pull request number.
            path (str): The relative path to the file (e.g., 'src/main.py').
            line (int): The line number in the file to comment on.
            comment_body (str): The content of the review comment.
        Returns:
            Dict[str, Any]: The JSON response from the GitHub API containing the comment data if successful.
            None: If an error occurs while adding the comment.
        Error Handling:
            Logs an error message and prints the traceback if the request fails or an exception is raised.
        """
        logging.info(f"Adding inline review comment to PR {repo_owner}/{repo_name}#{pr_number} on {path}:{line}")
    
        # Construct the review comments URL
        review_comments_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/pulls/{pr_number}/comments"
    
        try:
            pr_url = self._get_pr_url(repo_owner, repo_name, pr_number)
            pr_response = requests.get(pr_url, headers=self._get_headers(), timeout=TIMEOUT)
            pr_response.raise_for_status()
            pr_data = pr_response.json()
            commit_id = pr_data['head']['sha']
    
            payload = {
                "body": comment_body,
                "commit_id": commit_id,
                "path": path,
                "line": line,
                "side": "RIGHT"
            }
    
            response = requests.post(review_comments_url, headers=self._get_headers(), json=payload, timeout=TIMEOUT)
            response.raise_for_status()
            comment_data = response.json()
    
            logging.info("Inline review comment added successfully")
            return comment_data
    
        except Exception as e:
            logging.error(f"Error adding inline review comment: {str(e)}")
            traceback.print_exc()
            return {"status": "error", "message": str(e)}
  • Dynamically registers all public methods of GitHubIntegration (including add_inline_pr_comment) as MCP tools by inspecting and adding them to FastMCP.
    def register_tools(self, methods: Any = None) -> None:
        for name, method in inspect.getmembers(methods):
            if (inspect.isfunction(method) or inspect.ismethod(method)) and not name.startswith("_"):
                self.mcp.add_tool(method)
  • Calls register_tools on the GitHubIntegration instance (self.gi), which triggers the registration of add_inline_pr_comment as an MCP tool.
    def _register_tools(self):
        self.register_tools(self.gi)
        self.register_tools(self.ip)
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the action ('Adds'), success/failure outcomes (returns comment data or None), and error handling (logs error and traceback). However, it lacks details on permissions, rate limits, or side effects like notifications.

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

Conciseness4/5

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

Well-structured with clear sections (Args, Returns, Error Handling) and front-loaded purpose. Slightly verbose in error handling details, but each sentence adds value. Could be more concise by integrating some details.

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

Completeness4/5

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

Given 6 parameters with 0% schema coverage and no annotations, the description does well by documenting all parameters and outcomes. With an output schema, it doesn't need to detail return values. Minor gaps in behavioral context (e.g., auth needs) keep it from a 5.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate. It provides clear semantics for all 6 parameters in the 'Args' section, explaining each parameter's purpose (e.g., 'repo_owner: The owner of the repository') beyond basic schema titles.

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 ('Adds an inline review comment'), target resource ('to a specific line in a file within a pull request on GitHub'), and distinguishes from siblings like 'add_pr_comments' (likely general comments) by specifying 'inline' and 'specific line'.

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

Usage Guidelines2/5

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

No explicit guidance on when to use this tool versus alternatives like 'add_pr_comments' or 'update_reviews'. The description implies usage for inline commenting but doesn't specify prerequisites, exclusions, or compare with sibling tools.

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/saidsef/mcp-github-pr-issue-analyser'

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