zendesk_list_attachments
Retrieve all attachments from a Zendesk ticket's comments, including filename, content type, size, and download URL, to quickly review files before downloading.
Instructions
List all attachments across all comments for a Zendesk ticket. Returns filename, content type, size, and download URL for each. Use zendesk_download_attachment to fetch file contents.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ticket_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The MCP tool handler for 'zendesk_list_attachments'. Decorated with @mcp.tool(), it takes a ticket_id and delegates to _list_attachments_data().
def zendesk_list_attachments(ticket_id: int) -> str: """List all attachments across all comments for a Zendesk ticket. Returns filename, content type, size, and download URL for each. Use zendesk_download_attachment to fetch file contents.""" return _list_attachments_data(ticket_id) - Helper function _list_attachments_data(ticket_id) that queries Zendesk API via Zenpy client, iterates over each comment's attachments, and returns a JSON array of attachment info (comment_id, filename, content_type, size_bytes, download_url).
def _list_attachments_data(ticket_id: int) -> str: try: client = get_client() comments = client.tickets.comments(ticket_id) result = [] for comment in comments: for att in (comment.attachments or []): result.append({ "comment_id": comment.id, "filename": att.file_name, "content_type": att.content_type, "size_bytes": att.size, "download_url": att.content_url, }) 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/server.py:15-15 (registration)Import of register_attachment_tools from the attachments module.
from zendesk_mcp.tools.attachments import register_attachment_tools - src/zendesk_mcp/server.py:35-35 (registration)Registration call that wires register_attachment_tools (and thus zendesk_list_attachments) into the MCP server.
register_attachment_tools(mcp) - Input schema for zendesk_list_attachments: accepts a single parameter ticket_id of type int.
def zendesk_list_attachments(ticket_id: int) -> str: