Skip to main content
Glama
saidsef

GitHub PR Issue Analyser

by saidsef

create_pr

Create a new pull request in a GitHub repository by specifying branches, title, and description to propose code changes for review.

Instructions

Creates a new pull request in the specified GitHub repository. Args: repo_owner (str): The owner of the repository. repo_name (str): The name of the repository. title (str): The title of the pull request. body (str): The body content of the pull request. head (str): The name of the branch where your changes are implemented. base (str): The name of the branch you want the changes pulled into. draft (bool, optional): Whether the pull request is a draft. Defaults to False. Returns: Dict[str, Any]: The JSON response from the GitHub API containing pull request information if successful. Error Handling: Logs errors and prints the traceback if the pull request creation fails, returning None.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_ownerYes
repo_nameYes
titleYes
bodyYes
headYes
baseYes
draftNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the logic for creating a GitHub pull request (PR) using the GitHub REST API. It constructs the API request, sends it with authentication, and returns the PR details or error information.
    def create_pr(self, repo_owner: str, repo_name: str, title: str, body: str, head: str, base: str, draft: bool = False) -> Dict[str, Any]:
        """
        Creates a new pull request in the specified GitHub repository.
        Args:
            repo_owner (str): The owner of the repository.
            repo_name (str): The name of the repository.
            title (str): The title of the pull request.
            body (str): The body content of the pull request.
            head (str): The name of the branch where your changes are implemented.
            base (str): The name of the branch you want the changes pulled into.
            draft (bool, optional): Whether the pull request is a draft. Defaults to False.
        Returns:
            Dict[str, Any]: The JSON response from the GitHub API containing pull request information if successful.
        Error Handling:
            Logs errors and prints the traceback if the pull request creation fails, returning None.
        """
        logging.info(f"Creating PR in {repo_owner}/{repo_name}")
    
        pr_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/pulls"
    
        try:
            response = requests.post(pr_url, headers=self._get_headers(), json={
                'title': title,
                'body': body,
                'head': head,
                'base': base,
                'draft': draft
            }, timeout=TIMEOUT)
            response.raise_for_status()
            pr_data = response.json()
    
            logging.info("PR created successfully")
            return {
                "pr_url": pr_data.get('html_url'),
                "pr_number": pr_data.get('number'),
                "status": pr_data.get('state'),
                "title": pr_data.get('title'),
            }
    
        except Exception as e:
            logging.error(f"Error creating PR: {str(e)}")
            traceback.print_exc()
            return {"status": "error", "message": str(e)}
  • Dynamic registration of all public methods (non-private, i.e., not starting with '_') from the GitHubIntegration instance as MCP tools. This includes the create_pr method, registering it as the 'create_pr' tool.
    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 the register_tools method on the GitHubIntegration instance (self.gi), which triggers the registration of create_pr among other methods as MCP tools.
    def _register_tools(self):
        self.register_tools(self.gi)
        self.register_tools(self.ip)
Behavior2/5

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

With no annotations provided, the description carries full burden but only partially discloses behavior. It mentions error handling (logs errors, returns None) and the return type (JSON response), but lacks critical details like authentication requirements, rate limits, side effects, or whether it's a read-only or destructive operation.

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?

The description is well-structured with clear sections (Args, Returns, Error Handling) and efficiently conveys necessary information. However, some sentences could be more concise (e.g., 'Logs errors and prints the traceback if the pull request creation fails, returning None' could be streamlined).

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 7-parameter mutation tool with no annotations, the description is moderately complete. It covers parameters thoroughly and mentions return values/error handling, but lacks behavioral context (auth, side effects) that would be crucial for safe agent usage. The output schema existence reduces but doesn't eliminate this gap.

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?

With 0% schema description coverage, the description fully compensates by providing detailed parameter documentation. Each parameter is clearly explained with types, purposes, and default values (e.g., 'head: The name of the branch where your changes are implemented'), adding significant value beyond the bare schema.

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 ('Creates a new pull request') and resource ('in the specified GitHub repository'), distinguishing it from sibling tools like create_issue or merge_pr. 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?

No guidance is provided on when to use this tool versus alternatives like create_issue or merge_pr. The description lacks context about prerequisites (e.g., authentication, branch existence) or typical scenarios for creating pull requests versus other operations.

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