Skip to main content
Glama
AstroMined

PyGithub MCP Server

by AstroMined

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
NameRequiredDescriptionDefault
paramsYes

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")
  • 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)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action ('Delete') which implies a destructive mutation, but doesn't mention critical behaviors: whether deletion is permanent, what permissions are required, if it's reversible, or any rate limits. The return statement adds minimal value ('Empty response on success'), but leaves error conditions and side effects undocumented.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized. It opens with the core purpose, then provides parameter documentation in a clear format, and concludes with return information. Every sentence serves a purpose with minimal waste. The only minor improvement would be front-loading more behavioral context before parameter details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive mutation tool with no annotations and no output schema, the description is incomplete. It documents parameters adequately but fails to address critical context: authentication requirements, permission levels needed, whether deletions are permanent, error conditions, or how this differs from updating comments. The return statement is minimal ('Empty response on success') without explaining what constitutes success or how errors manifest.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It lists all four parameters (owner, repo, issue_number, comment_id) with brief explanations that match the schema's property descriptions. However, it doesn't add meaningful semantics beyond what's already in the schema - no examples, format requirements, or constraints. The parameter documentation is adequate but not insightful.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Delete') and resource ('an issue comment'), making the purpose immediately understandable. It distinguishes this from sibling tools like 'update_issue_comment' or 'list_issue_comments' by specifying deletion rather than modification or retrieval. However, it doesn't explicitly contrast with all siblings, such as 'remove_issue_label' which also performs deletion operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing appropriate permissions), when deletion is appropriate versus updating, or how it differs from related tools like 'update_issue_comment' for modifying comments. The agent must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/AstroMined/pygithub-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server