update_assignees
Assign users to GitHub issues or pull requests by specifying repository details and usernames to manage task ownership.
Instructions
Updates the assignees for a specific issue or pull request in a GitHub repository. Args: repo_owner (str): The owner of the repository. repo_name (str): The name of the repository. issue_number (int): The issue or pull request number to update. assignees (list[str]): A list of usernames to assign to the issue or pull request. Returns: Dict[str, Any]: The updated issue or 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 request fails or an exception is raised.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_owner | Yes | ||
| repo_name | Yes | ||
| issue_number | Yes | ||
| assignees | Yes |
Implementation Reference
- The handler function that executes the update_assignees tool logic. It sends a PATCH request to the GitHub Issues API endpoint to update the assignees list for the specified issue or pull request.def update_assignees(self, repo_owner: str, repo_name: str, issue_number: int, assignees: list[str]) -> Dict[str, Any]: """ Updates the assignees for a specific issue or pull request in a GitHub repository. Args: repo_owner (str): The owner of the repository. repo_name (str): The name of the repository. issue_number (int): The issue or pull request number to update. assignees (list[str]): A list of usernames to assign to the issue or pull request. Returns: Dict[str, Any]: The updated issue or 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 request fails or an exception is raised. """ logging.info(f"Updating assignees for issue/PR {repo_owner}/{repo_name}#{issue_number}") # Construct the issue URL issue_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/issues/{issue_number}" try: # Update the assignees response = requests.patch(issue_url, headers=self._get_headers(), json={ 'assignees': assignees }, timeout=TIMEOUT) response.raise_for_status() issue_data = response.json() logging.info("Assignees updated successfully") return issue_data except Exception as e: logging.error(f"Error updating assignees: {str(e)}") traceback.print_exc() return {"status": "error", "message": str(e)}
- src/mcp_github/issues_pr_analyser.py:105-107 (registration)Registers all public methods from GitHubIntegration instance (self.gi), including update_assignees, as MCP tools via the register_tools method.def _register_tools(self): self.register_tools(self.gi) self.register_tools(self.ip)
- src/mcp_github/issues_pr_analyser.py:109-113 (registration)The method that dynamically registers public methods (non-starting with _) of the GitHubIntegration class as MCP tools by calling self.mcp.add_tool(method). This registers update_assignees among others.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)
- src/mcp_github/issues_pr_analyser.py:27-27 (registration)Import of GitHubIntegration class, whose methods including update_assignees are later registered as tools.from .github_integration import GitHubIntegration as GI