Skip to main content
Glama
AstroMined

PyGithub MCP Server

by AstroMined

remove_issue_label

Remove a label from a GitHub issue by specifying repository details, issue number, and label name.

Instructions

Remove a label from an issue.

Args:
    params: Parameters for removing a label including:
        - owner: Repository owner (user or organization)
        - repo: Repository name
        - issue_number: Issue number
        - label: Label to remove

Returns:
    Empty response on success or error if label doesn't exist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • MCP tool handler for remove_issue_label: validates params with RemoveIssueLabelParams, checks if label exists on issue, calls the underlying operation if present, handles errors and returns MCP-formatted response.
    @tool()
    def remove_issue_label(params: RemoveIssueLabelParams) -> dict:
        """Remove a label from an issue.
        
        Args:
            params: Parameters for removing a label including:
                - owner: Repository owner (user or organization)
                - repo: Repository name
                - issue_number: Issue number
                - label: Label to remove
        
        Returns:
            Empty response on success or error if label doesn't exist
        """
        try:
            logger.debug(f"remove_issue_label called with params: {params}")
            
            # First check if the issue exists and has the label
            client = GitHubClient.get_instance()
            repository = client.get_repo(f"{params.owner}/{params.repo}")
            issue = repository.get_issue(params.issue_number)
            
            # Get current labels
            label_names = [label.name for label in issue.labels]
            
            if params.label not in label_names:
                # Label doesn't exist on this issue, return an error
                error_msg = f"Label '{params.label}' does not exist on issue #{params.issue_number}"
                logger.warning(error_msg)
                return {
                    "content": [{"type": "error", "text": error_msg}],
                    "is_error": True
                }
            
            # Now try to remove the label
            issues.remove_issue_label(params)
            logger.debug("Label removed successfully")
            return {"content": [{"type": "text", "text": "Label removed 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 input schema RemoveIssueLabelParams defining parameters: owner/repo (inherited), issue_number (int), label (str non-empty). Used for validation in the tool handler.
    class RemoveIssueLabelParams(RepositoryRef):
        """Parameters for removing a label from an issue."""
    
        model_config = ConfigDict(strict=True)
        
        issue_number: int = Field(..., description="Issue number")
        label: str = Field(..., description="Label to remove")
        
        @field_validator('label')
        @classmethod
        def validate_label(cls, v):
            """Validate that label is not empty."""
            if not v.strip():
                raise ValueError("label cannot be empty")
            return v
  • Registration function that adds remove_issue_label (and other issue tools) to the MCP server using register_tools.
    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 operation function called by the tool handler: uses PyGithub to remove the label from the issue, handles non-existent label gracefully.
    def remove_issue_label(params: RemoveIssueLabelParams) -> None:
        """Remove a label from an issue.
    
        Args:
            params: Validated parameters for removing a label from an issue
    
        Raises:
            GitHubError: If the API request fails or label doesn't exist
        """
        try:
            client = GitHubClient.get_instance()
            repository = client.get_repo(f"{params.owner}/{params.repo}")
            issue = repository.get_issue(params.issue_number)
            try:
                issue.remove_from_labels(params.label)
            except GithubException as label_e:
                # Handle specific case for non-existent labels
                if label_e.status == 404 and "Label does not exist" in str(label_e):
                    logger.warning(f"Label '{params.label}' does not exist on issue #{params.issue_number}")
                    # Not raising an error since removing a non-existent label is not a failure
                    return
                # Re-raise if it's a different error
                raise label_e
        except GithubException as e:
            raise client._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. It states the action is a removal (implying mutation) and mentions error handling for non-existent labels, but lacks critical behavioral details: required permissions (e.g., write access to the repo), whether the operation is reversible, rate limits, or what 'Empty response on success' entails (e.g., HTTP 204). For a mutation tool with zero annotation coverage, this is insufficient.

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 with clear sections (purpose, Args, Returns) and uses bullet points for parameters. It's front-loaded with the core purpose. The Args section could be more concise by integrating parameter details directly, but overall it avoids unnecessary verbosity.

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?

Given the tool's complexity (mutation operation with 4 parameters), lack of annotations, and no output schema, the description is incomplete. It covers the basic action and parameters but misses behavioral context (permissions, reversibility), detailed error cases, and output specifics. For a mutation tool in this context, it should provide more guidance to ensure safe and correct usage.

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, label) with brief explanations in the Args section, adding meaning beyond the bare schema. However, it doesn't provide format details (e.g., owner as username/organization string), constraints, or examples, leaving gaps in parameter understanding.

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

Purpose5/5

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

The description clearly states the specific action ('Remove a label from an issue') with the exact resource ('issue') and distinguishes it from sibling tools like 'add_issue_labels' and 'update_issue'. It uses a precise verb ('Remove') that leaves no ambiguity about the operation.

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., the issue must exist, the label must be present), compare it to sibling tools like 'update_issue' for label management, or specify error conditions beyond a generic mention of 'error if label doesn't exist'.

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