update_github_pr_description
Modify GitHub pull request titles and descriptions by specifying repository details, PR number, and updated content. Returns success or error messages for each operation.
Instructions
Updates the title and description of a GitHub pull request.
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 update.
new_title (str): The new title for the pull request.
new_description (str): The new description for the pull request.
Returns:
str: A message indicating the result of the update operation. Returns a success message if the update is successful, or an error message if an exception occurs.
Error Handling:
Catches and logs any exceptions that occur during the update process. If an error is encountered, the error message is logged and returned.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| new_description | Yes | ||
| new_title | Yes | ||
| pr_number | Yes | ||
| repo_name | Yes | ||
| repo_owner | Yes |
Implementation Reference
- The core handler function `update_pr_description` that performs the actual API call to update a GitHub PR's title and description. This is the execution logic for the tool.def update_pr_description(self, repo_owner: str, repo_name: str, pr_number: int, new_title: str, new_description: str) -> Dict[str, Any]: """ Updates the title and description (body) of 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 update. new_title (str): The new title for the pull request. new_description (str): The new description (body) for the pull request. Returns: Dict[str, Any]: The updated pull request data as returned by the GitHub API if the update is successful. None: If an error occurs during the update process. Error Handling: Logs an error message and prints the traceback if the update fails due to an exception (e.g., network issues, invalid credentials, or API errors). """ logging.info(f"Updating PR description for {repo_owner}/{repo_name}#{pr_number}") # Construct the PR URL pr_url = self._get_pr_url(repo_owner, repo_name, pr_number) try: # Update the PR description response = requests.patch(pr_url, headers=self._get_headers(), json={ 'title': new_title, 'body': new_description }, timeout=TIMEOUT) response.raise_for_status() pr_data = response.json() logging.info("PR description updated successfully") return pr_data except Exception as e: logging.error(f"Error updating PR description: {str(e)}") traceback.print_exc() return {"status": "error", "message": str(e)}
- src/mcp_github/issues_pr_analyser.py:105-113 (registration)Registers all public methods from the GitHubIntegration class (including `update_pr_description`) as MCP tools by calling `FastMCP.add_tool(method)` in a loop over inspect.getmembers.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)