update_assignees
Change the assignees of a GitHub issue or pull request by specifying the repository owner, repository name, issue number, and list of assignee usernames.
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 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main handler function for the 'update_assignees' tool. Makes a PATCH request to the GitHub API to update assignees on an issue/PR, logs missing assignees that couldn't be applied, and returns the updated issue data or an error.
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. """ logger.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 = httpx.patch( issue_url, headers=self._get_headers(), json={"assignees": assignees}, timeout=TIMEOUT, ) self._raise_for_status(response, f"issue/PR #{issue_number} assignees") issue_data = response.json() # GitHub silently drops assignees it cannot apply (non-collaborators, unknown users). # Compare requested vs actually assigned and surface any discrepancy. actual_logins = {u["login"] for u in issue_data.get("assignees", [])} requested = set(assignees) missing = requested - actual_logins if missing: logger.warning(f"Some assignees were not applied: {missing}") return { "status": "partial", "message": f"The following assignees could not be applied (not a collaborator or user does not exist): {sorted(missing)}", "assignees_requested": sorted(requested), "assignees_applied": sorted(actual_logins), "issue": issue_data, } logger.info("Assignees updated successfully") return issue_data except GitHubAuthError: raise except Exception as e: logger.error(f"Error updating assignees: {str(e)}") traceback.print_exc() return {"status": "error", "message": str(e)} - src/mcp_github/issues_pr_analyser.py:137-148 (registration)The registration mechanism: _register_tools() calls register_tools(self.gi), which iterates over all public methods on the GitHubIntegration instance and adds them as MCP tools via self.mcp.add_tool(). This is how update_assignees gets registered.
def _register_tools(self): self.register_tools(self.gi) self.register_tools(self.ip) self.mcp.add_provider(SkillsDirectoryProvider(Path(__file__).parent / "skills")) 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) - src/mcp_github/issues_pr_analyser.py:142-148 (registration)The generic register_tools method that dynamically discovers all public methods on an object and registers them 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)