get_ticket_comments
Retrieve all comments for a Zendesk ticket by its ID to view discussion history and support interactions.
Instructions
Retrieve all comments for a Zendesk ticket by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ticket_id | Yes | The ID of the ticket to get comments for |
Implementation Reference
- The actual implementation of fetching ticket comments using the Zenpy client.
def get_ticket_comments(self, ticket_id: int) -> List[Dict[str, Any]]: """ Get all comments for a specific ticket. """ try: comments = self.client.tickets.comments(ticket=ticket_id) return [{ 'id': comment.id, 'author_id': comment.author_id, 'body': comment.body, 'html_body': comment.html_body, 'public': comment.public, 'created_at': str(comment.created_at) } for comment in comments] except Exception as e: raise Exception(f"Failed to get comments for ticket {ticket_id}: {str(e)}") - src/zendesk_mcp_server/server.py:368-376 (handler)Tool handler in server.py that routes the "get_ticket_comments" request to the ZendeskClient.
elif name == "get_ticket_comments": if not arguments: raise ValueError("Missing arguments") comments = zendesk_client.get_ticket_comments( arguments["ticket_id"]) return [types.TextContent( type="text", text=json.dumps(comments) )] - src/zendesk_mcp_server/server.py:192-204 (registration)Registration of the "get_ticket_comments" tool, defining its schema and description.
name="get_ticket_comments", description="Retrieve all comments for a Zendesk ticket by its ID", inputSchema={ "type": "object", "properties": { "ticket_id": { "type": "integer", "description": "The ID of the ticket to get comments for" } }, "required": ["ticket_id"] } ),