Skip to main content
Glama

update_issue

Modify GitHub issue details including title, body, labels, and state to reflect current project status and requirements.

Instructions

Updates an existing issue in the specified GitHub repository. Args: repo_owner (str): The owner of the repository. repo_name (str): The name of the repository. issue_number (int): The number of the issue to update. title (str): The new title for the issue. body (str): The new body content for the issue. labels (list[str], optional): A list of labels to assign to the issue. Defaults to an empty list. state (str, optional): The state of the issue ('open' or 'closed'). Defaults to 'open'. Returns: Dict[str, Any]: The updated issue 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

TableJSON Schema
NameRequiredDescriptionDefault
repo_ownerYes
repo_nameYes
issue_numberYes
titleYes
bodyYes
labelsNo
stateNoopen

Implementation Reference

  • The handler function implementing the 'update_issue' tool logic. It constructs the GitHub API URL for the specific issue and sends a PATCH request with the new title, body, labels, and state. Handles errors by logging and returning an error dictionary.
    def update_issue(self, repo_owner: str, repo_name: str, issue_number: int, title: str, body: str, labels: list[str] = [], state: Literal['open', 'closed'] = 'open') -> Dict[str, Any]: """ Updates an existing issue in the specified GitHub repository. Args: repo_owner (str): The owner of the repository. repo_name (str): The name of the repository. issue_number (int): The number of the issue to update. title (str): The new title for the issue. body (str): The new body content for the issue. labels (list[str], optional): A list of labels to assign to the issue. Defaults to an empty list. state (str, optional): The state of the issue ('open' or 'closed'). Defaults to 'open'. Returns: Dict[str, Any]: The updated issue 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 issue {issue_number} in {repo_owner}/{repo_name}") # Construct the issue URL issue_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/issues/{issue_number}" try: # Update the issue response = requests.patch(issue_url, headers=self._get_headers(), json={ 'title': title, 'body': body, 'labels': labels, 'state': state }, timeout=TIMEOUT) response.raise_for_status() issue_data = response.json() logging.info("Issue updated successfully") return issue_data except Exception as e: logging.error(f"Error updating issue: {str(e)}") traceback.print_exc() return {"status": "error", "message": str(e)}
  • The registration mechanism that dynamically registers all public methods of the GitHubIntegration instance (including 'update_issue') as MCP tools by iterating over its members and calling mcp.add_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 'update_issue' as an MCP tool.
    def _register_tools(self): self.register_tools(self.gi) self.register_tools(self.ip)

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