zendesk_get_comments
Retrieve all public replies, internal notes, and attachment metadata for a Zendesk ticket.
Instructions
Get all comments (public replies and internal notes) for a Zendesk ticket. Includes attachment metadata but does not download files.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ticket_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/zendesk_mcp/tools/comments.py:5-45 (handler)The helper function that executes the core logic: fetches comments from Zendesk API, resolves author info, extracts attachments, and returns JSON string.
def _get_comments_data(ticket_id: int) -> str: try: client = get_client() comments = client.tickets.comments(ticket_id) result = [] for comment in comments: try: author = client.users(id=comment.author_id) author_info = { "name": author.name, "email": author.email, "role": author.role, } except Exception: author_info = {"name": "Unknown", "email": "", "role": ""} attachments = [ { "filename": att.file_name, "content_type": att.content_type, "size_bytes": att.size, "content_url": att.content_url, } for att in (comment.attachments or []) ] result.append({ "id": comment.id, "author": author_info, "created_at": str(comment.created_at), "is_public": comment.public, "body": comment.body, "attachments": attachments, }) return json.dumps(result, 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/comments.py:48-52 (handler)The MCP tool handler function 'zendesk_get_comments', decorated with @mcp.tool(), which calls the helper _get_comments_data.
def register_comments_tools(mcp) -> None: @mcp.tool() def zendesk_get_comments(ticket_id: int) -> str: """Get all comments (public replies and internal notes) for a Zendesk ticket. Includes attachment metadata but does not download files.""" return _get_comments_data(ticket_id) - src/zendesk_mcp/server.py:22-23 (registration)Where the tool registration function is called to register all comment tools (including zendesk_get_comments) on the MCP server.
register_ticket_tools(mcp) register_comments_tools(mcp)