zendesk_remove_tag
Remove a specific tag from a Zendesk ticket. Idempotent operation returns the current tag list without modifying the ticket if the tag is absent.
Instructions
Remove a tag from a Zendesk ticket. Idempotent: removing a tag that isn't present returns the current tag list without modifying the ticket. Returns JSON with ticket_id and current tags.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ticket_id | Yes | ||
| tag | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/zendesk_mcp/tools/tags.py:25-42 (handler)The _remove_tag_data function is the core handler for removing a tag from a Zendesk ticket. It fetches the ticket, checks if the tag exists, removes it, updates the ticket via the Zenpy client, and returns JSON with the updated tags.
def _remove_tag_data(ticket_id: int, tag: str) -> str: try: client = get_client() ticket = client.tickets(id=ticket_id) current_tags = list(getattr(ticket, "tags", []) or []) if tag not in current_tags: return json.dumps({"ticket_id": ticket_id, "tags": current_tags}, indent=2) current_tags.remove(tag) ticket.tags = current_tags client.tickets.update(ticket) refreshed = client.tickets(id=ticket_id) return json.dumps({"ticket_id": ticket_id, "tags": list(getattr(refreshed, "tags", []) or [])}, indent=2) except ConfigError as e: return str(e) except Exception as e: if "RecordNotFound" in str(e) or "404" in str(e): return f"Ticket #{ticket_id} not found or not accessible with current credentials." return f"Zendesk API error: {e}" - src/zendesk_mcp/tools/tags.py:51-54 (handler)The zendesk_remove_tag tool function decorated with @mcp.tool(). It is the entry point that delegates to _remove_tag_data().
@mcp.tool() def zendesk_remove_tag(ticket_id: int, tag: str) -> str: """Remove a tag from a Zendesk ticket. Idempotent: removing a tag that isn't present returns the current tag list without modifying the ticket. Returns JSON with ticket_id and current tags.""" return _remove_tag_data(ticket_id, tag) - src/zendesk_mcp/tools/tags.py:52-52 (schema)The tool signature defines the input schema: ticket_id (int) and tag (str). The return type is str (JSON).
def zendesk_remove_tag(ticket_id: int, tag: str) -> str: - src/zendesk_mcp/tools/tags.py:45-55 (registration)The register_tag_tools function registers the tool via the @mcp.tool() decorator.
def register_tag_tools(mcp) -> None: @mcp.tool() def zendesk_add_tag(ticket_id: int, tag: str) -> str: """Add a tag to a Zendesk ticket. Idempotent: adding an existing tag returns the current tag list without modifying the ticket. Returns JSON with ticket_id and current tags.""" return _add_tag_data(ticket_id, tag) @mcp.tool() def zendesk_remove_tag(ticket_id: int, tag: str) -> str: """Remove a tag from a Zendesk ticket. Idempotent: removing a tag that isn't present returns the current tag list without modifying the ticket. Returns JSON with ticket_id and current tags.""" return _remove_tag_data(ticket_id, tag) - src/zendesk_mcp/server.py:44-44 (registration)Tool registration is triggered by calling register_tag_tools(mcp) in the main server setup.
register_tag_tools(mcp)