update_pr_description
Update the title and description of a GitHub pull request by specifying the repository, pull request number, new title, and new description.
Instructions
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).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_owner | Yes | ||
| repo_name | Yes | ||
| pr_number | Yes | ||
| new_title | Yes | ||
| new_description | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | ||
| description | Yes | ||
| author | Yes | ||
| created_at | Yes | ||
| updated_at | Yes | ||
| state | Yes |
Implementation Reference
- The actual handler function `update_pr_description` that performs the PR description update via a PATCH request to the GitHub API.
def update_pr_description( self, repo_owner: str, repo_name: str, pr_number: int, new_title: str, new_description: str, ) -> PRContent: """ 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). """ logger.info(f"Updating PR description for {repo_owner}/{repo_name}#{pr_number}") # Construct the PR URL pr_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/pulls/{pr_number}" try: # Update the PR description response = httpx.patch( pr_url, headers=self._get_headers(), json={"title": new_title, "body": new_description}, timeout=TIMEOUT, ) self._raise_for_status(response, f"PR #{pr_number}") pr_data = response.json() logger.info("PR description updated successfully") return pr_data except GitHubAuthError: raise except Exception as e: logger.error(f"Error updating PR description: {str(e)}") traceback.print_exc() return {"status": "error", "message": str(e)} - src/mcp_github/issues_pr_analyser.py:142-148 (registration)The `register_tools` method that dynamically registers all public methods from GitHubIntegration (including `update_pr_description`) as MCP tools.
def register_tools(self, methods: Any = None) -> None: for name in dir(methods): if name.startswith("_"): continue method = getattr(methods, name) if inspect.isroutine(method): self.mcp.add_tool(method) - The PRContent TypedDict used as the return type for `update_pr_description`.
type PRContent = TypedDict( "PRContent", { # pyright: ignore[reportInvalidTypeForm] "title": str, "description": str | None, "author": str, "created_at": str, "updated_at": str, "state": str, }, )