Skip to main content
Glama
saidsef

GitHub PR Issue Analyser

by saidsef

add_pr_comments

Add comments to GitHub pull requests to provide feedback, suggestions, or analysis during code review processes.

Instructions

Adds a comment to a specific 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 to which the comment will be added. comment (str): The content of the comment to add. 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
commentYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler implementation for the 'add_pr_comments' MCP tool. This method uses the GitHub API to post a general comment to the specified pull request.
    def add_pr_comments(self, repo_owner: str, repo_name: str, pr_number: int, comment: str) -> Dict[str, Any]:
        """
        Adds a comment to a specific 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 to which the comment will be added.
            comment (str): The content of the comment to add.
        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 comment to PR {repo_owner}/{repo_name}#{pr_number}")
    
        # Construct the comments URL
        comments_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/issues/{pr_number}/comments"
    
        try:
            # Add the comment
            response = requests.post(comments_url, headers=self._get_headers(), json={'body': comment}, timeout=TIMEOUT)
            response.raise_for_status()
            comment_data = response.json()
    
            logging.info("Comment added successfully")
            return comment_data
    
        except Exception as e:
            logging.error(f"Error adding comment: {str(e)}")
            traceback.print_exc()
            return {"status": "error", "message": str(e)}
  • The registration logic that dynamically registers all public methods of the GitHubIntegration instance (including 'add_pr_comments') as MCP tools by calling mcp.add_tool on each qualifying method.
    def _register_tools(self):
        self.register_tools(self.gi)
        self.register_tools(self.ip)
    
    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)
  • Instantiation of the GitHubIntegration class instance used for tool registration.
    self.gi = GI()
    self.ip = IP()
    
    # Initialize MCP Server
  • Import of the GitHubIntegration class containing the tool handler.
    from .github_integration import GitHubIntegration as GI
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 correctly describes the core action (adding a comment) and includes error handling information (logs error and prints traceback on failure). However, it lacks important behavioral details like authentication requirements, rate limits, whether the operation is idempotent, or how it handles duplicate comments. The return value documentation is adequate but basic.

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 well-structured and efficiently organized with clear sections (Args, Returns, Error Handling). Every sentence serves a purpose: the opening statement defines the tool, parameter explanations are essential given the schema gap, and error/return documentation provides necessary behavioral context. No wasted words or redundant information.

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 the tool's moderate complexity (4 parameters, mutation operation) and the presence of an output schema (which handles return value documentation), the description provides adequate context. It covers the core functionality, parameters, returns, and error handling. However, for a mutation tool with no annotations, it could benefit from more behavioral context like authentication requirements or side effects.

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

Parameters4/5

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

With 0% schema description coverage, the description must compensate for the lack of parameter documentation in the schema. The 'Args' section clearly explains each parameter's purpose and type, providing essential semantic meaning beyond the bare schema. All 4 parameters are documented with their roles in the GitHub API context, though it could benefit from examples or format requirements.

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 a comment') and target resource ('to a specific pull request on GitHub'), distinguishing it from sibling tools like 'add_inline_pr_comment' (which adds inline comments) and 'create_issue' (which creates issues rather than PR comments). The verb+resource combination is precise and unambiguous.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose 'add_pr_comments' over 'add_inline_pr_comment' (for regular vs. inline comments) or other PR-related tools like 'update_pr_description'. There are no usage prerequisites, exclusions, or contextual recommendations provided.

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