Skip to main content
Glama
AstroMined

PyGithub MCP Server

by AstroMined

update_issue_comment

Modify existing comments on GitHub issues by providing new text, repository details, and comment identifiers for accurate updates.

Instructions

Update an issue comment.

Args:
    params: Parameters for updating a comment including:
        - owner: Repository owner (user or organization)
        - repo: Repository name
        - issue_number: Issue number containing the comment
        - comment_id: Comment ID to update
        - body: New comment text

Returns:
    Updated comment details from GitHub API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • MCP tool handler function for 'update_issue_comment'. It takes parameters, delegates to the operations layer, handles errors, and returns an MCP-formatted response.
    @tool()
    def update_issue_comment(params: UpdateIssueCommentParams) -> dict:
        """Update an issue comment.
        
        Args:
            params: Parameters for updating a comment including:
                - owner: Repository owner (user or organization)
                - repo: Repository name
                - issue_number: Issue number containing the comment
                - comment_id: Comment ID to update
                - body: New comment text
        
        Returns:
            Updated comment details from GitHub API
        """
        try:
            logger.debug(f"update_issue_comment called with params: {params}")
            # Pass the Pydantic model directly to the operation
            result = issues.update_issue_comment(params)
            logger.debug(f"Got result: {result}")
            return {"content": [{"type": "text", "text": json.dumps(result, indent=2)}]}
        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 UpdateIssueCommentParams defining input parameters and validation for the update_issue_comment tool.
    class UpdateIssueCommentParams(RepositoryRef):
        """Parameters for updating 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 update")
        body: str = Field(..., description="New comment text")
        
        @field_validator('body')
        @classmethod
        def validate_body(cls, v):
            """Validate that body is not empty."""
            if not v.strip():
                raise ValueError("body cannot be empty")
            return v
  • Registration function that adds the update_issue_comment tool (and other issue tools) to the MCP server instance.
    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 logic using PyGithub to update the issue comment and convert the response.
    def update_issue_comment(params: UpdateIssueCommentParams) -> Dict[str, Any]:
        """Update an issue comment.
    
        Args:
            params: Validated parameters for updating a comment
    
        Returns:
            Updated comment details from GitHub API
    
        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.edit(params.body)
            return convert_issue_comment(comment)
        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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Update' implies a mutation, the description doesn't cover critical traits: whether this requires authentication, if it's idempotent, rate limits, error conditions (e.g., invalid comment_id), or what 'Updated comment details' includes. This is inadequate for a mutation tool with zero annotation coverage.

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

Conciseness5/5

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

The description is well-structured and front-loaded: it starts with the core purpose, then lists parameters clearly in bullet points, and ends with return information. Every sentence earns its place with no wasted words, making it easy to scan and understand quickly.

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

Completeness3/5

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

Given the complexity (a mutation tool with 5 parameters, no annotations, and no output schema), the description is partially complete. It covers the purpose and parameters adequately but lacks behavioral details (e.g., auth, errors) and output specifics. This is the minimum viable for basic use but leaves gaps for robust agent operation.

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

Parameters4/5

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

The schema description coverage is 0%, but the description compensates by listing all parameters (owner, repo, issue_number, comment_id, body) with brief explanations in the 'Args' section. This adds meaningful context beyond the bare schema, though it doesn't detail formats (e.g., string constraints) or provide examples. With 0% coverage, this is strong but not exhaustive.

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 tool's purpose: 'Update an issue comment.' It specifies the verb ('Update') and resource ('issue comment'), making the action unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'add_issue_comment' or 'delete_issue_comment', which would be needed for a score of 5.

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 edit permissions), contrast with 'add_issue_comment' for new comments, or specify scenarios where updating is appropriate versus deleting and recreating. This leaves the agent without usage context.

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