delete_issue_comment
Remove a comment from a GitHub issue by specifying repository details, issue number, and comment ID.
Instructions
Delete an issue comment.
Args:
params: Parameters for deleting a comment including:
- owner: Repository owner (user or organization)
- repo: Repository name
- issue_number: Issue number containing the comment
- comment_id: Comment ID to delete
Returns:
Empty response on success
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- MCP tool handler for 'delete_issue_comment'. It takes parameters, logs the call, delegates to the operations layer, handles GitHub and general errors, and returns a formatted MCP response (success message or error).@tool() def delete_issue_comment(params: DeleteIssueCommentParams) -> dict: """Delete an issue comment. Args: params: Parameters for deleting a comment including: - owner: Repository owner (user or organization) - repo: Repository name - issue_number: Issue number containing the comment - comment_id: Comment ID to delete Returns: Empty response on success """ try: logger.debug(f"delete_issue_comment called with params: {params}") # Pass the Pydantic model directly to the operation issues.delete_issue_comment(params) logger.debug("Comment deleted successfully") return {"content": [{"type": "text", "text": "Comment deleted successfully"}]} except GitHubError as e: logger.error(f"GitHub error: {e}") return { "content": [{"type": "error", "text": format_github_error(e)}], "is_error": True } except Exception as e: logger.error(f"Unexpected error: {e}") logger.error(traceback.format_exc()) error_msg = str(e) if str(e) else "An unexpected error occurred" return { "content": [{"type": "error", "text": f"Internal server error: {error_msg}"}], "is_error": True }
- Pydantic schema class DeleteIssueCommentParams defining input parameters: owner/repo from base RepositoryRef, plus issue_number and comment_id with strict validation.class DeleteIssueCommentParams(RepositoryRef): """Parameters for deleting an issue comment.""" model_config = ConfigDict(strict=True) issue_number: int = Field(..., description="Issue number containing the comment") comment_id: int = Field(..., description="Comment ID to delete")
- src/pygithub_mcp_server/tools/issues/tools.py:439-463 (registration)Registration function that includes 'delete_issue_comment' in the list of issue tools passed to register_tools for MCP server registration.def register(mcp: FastMCP) -> None: """Register all issue tools with the MCP server. Args: mcp: The MCP server instance """ from pygithub_mcp_server.tools import register_tools # List of all issue tools to register issue_tools = [ create_issue, list_issues, get_issue, update_issue, add_issue_comment, list_issue_comments, update_issue_comment, delete_issue_comment, add_issue_labels, remove_issue_label, ] register_tools(mcp, issue_tools) logger.debug(f"Registered {len(issue_tools)} issue tools")
- Core implementation that performs the actual deletion using PyGithub: retrieves repository, issue, comment, and calls delete() on the comment.def delete_issue_comment(params: DeleteIssueCommentParams) -> None: """Delete an issue comment. Args: params: Validated parameters for deleting a comment Raises: GitHubError: If the API request fails """ try: client = GitHubClient.get_instance() repository = client.get_repo(f"{params.owner}/{params.repo}") issue = repository.get_issue(params.issue_number) comment = issue.get_comment(params.comment_id) comment.delete() except GithubException as e: raise GitHubClient.get_instance()._handle_github_exception(e)