Skip to main content
Glama

zendesk_get_tickets

Retrieve a paginated list of Zendesk tickets. Supports sorting by date, priority, or status with customizable order.

Instructions

List Zendesk tickets with pagination. page: 1-based page number. per_page: max 100. sort_by: created_at, updated_at, priority, or status. sort_order: asc or desc. Returns tickets plus pagination metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo
per_pageNo
sort_byNocreated_at
sort_orderNodesc

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `zendesk_get_tickets` tool handler function, registered as an MCP tool via the `@mcp.tool()` decorator and exposed by `register_list_tickets_tools()`. It accepts optional pagination/sorting parameters and delegates to `_get_tickets_data()`.
    def register_list_tickets_tools(mcp) -> None:
        @mcp.tool()
        def zendesk_get_tickets(
            page: int = 1,
            per_page: int = 25,
            sort_by: str = "created_at",
            sort_order: str = "desc",
        ) -> str:
            """List Zendesk tickets with pagination. page: 1-based page number. per_page: max 100. sort_by: created_at, updated_at, priority, or status. sort_order: asc or desc. Returns tickets plus pagination metadata."""
            return _get_tickets_data(page=page, per_page=per_page, sort_by=sort_by, sort_order=sort_order)
  • The `_get_tickets_data()` helper that performs the actual Zendesk API call via httpx, validates parameters, constructs the API URL, parses the response, and returns a JSON string with ticket data and pagination metadata.
    def _get_tickets_data(
        page: int = 1,
        per_page: int = 25,
        sort_by: str = "created_at",
        sort_order: str = "desc",
    ) -> str:
        if sort_by not in _VALID_SORT_BY:
            return f"Invalid sort_by '{sort_by}'. Valid values: {', '.join(sorted(_VALID_SORT_BY))}"
        if sort_order not in _VALID_SORT_ORDER:
            return f"Invalid sort_order '{sort_order}'. Valid values: {', '.join(sorted(_VALID_SORT_ORDER))}"
        per_page = max(1, min(per_page, _MAX_PER_PAGE))
        page = max(1, int(page))
    
        try:
            subdomain, token = get_oauth_session()
        except ConfigError as e:
            return str(e)
    
        url = f"https://{subdomain}.zendesk.com/api/v2/tickets.json"
        try:
            response = httpx.get(
                url,
                params={"page": page, "per_page": per_page, "sort_by": sort_by, "sort_order": sort_order},
                headers={"Authorization": f"Bearer {token}"},
                timeout=30,
            )
            response.raise_for_status()
            data = response.json()
        except Exception as e:
            return f"Zendesk API error: {e}"
    
        raw_tickets = data.get("tickets", [])
        tickets = [{
            "id": t.get("id"),
            "subject": t.get("subject"),
            "status": t.get("status"),
            "priority": t.get("priority"),
            "description": t.get("description"),
            "created_at": t.get("created_at"),
            "updated_at": t.get("updated_at"),
            "requester_id": t.get("requester_id"),
            "assignee_id": t.get("assignee_id"),
        } for t in raw_tickets]
    
        has_more = data.get("next_page") is not None
        return json.dumps({
            "tickets": tickets,
            "page": page,
            "per_page": per_page,
            "count": len(tickets),
            "sort_by": sort_by,
            "sort_order": sort_order,
            "has_more": has_more,
            "next_page": page + 1 if has_more else None,
            "previous_page": page - 1 if page > 1 else None,
        }, indent=2)
  • Imports and constants: httpx for API calls, `get_oauth_session`/`ConfigError` from client module, and validation constants for sort_by/sort_order/per_page.
    import json
    import httpx
    from zendesk_mcp.client import get_oauth_session, ConfigError
    
    _VALID_SORT_BY = {"created_at", "updated_at", "priority", "status"}
    _VALID_SORT_ORDER = {"asc", "desc"}
    _MAX_PER_PAGE = 100
  • Import of `register_list_tickets_tools` from the list_tickets module.
    from zendesk_mcp.tools.list_tickets import register_list_tickets_tools
  • Registration call: `register_list_tickets_tools(mcp)` which triggers the decorator that registers `zendesk_get_tickets` as an MCP tool.
    register_list_tickets_tools(mcp)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses pagination behavior (page basis, per_page max, sort options) and that the response includes pagination metadata. No annotations present, so description carries full burden; it sufficiently covers functional behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no redundancy. Purpose and parameter details are front-loaded. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no required params, no enums) and the presence of an output schema (not shown), the description adequately covers usage and return format. For a list tool, this is complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema coverage, the description fully explains all 4 parameters: page (1-based), per_page (max 100), sort_by (four valid values), sort_order (asc/desc). This adds essential meaning beyond the schema.

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?

Clearly states 'List Zendesk tickets with pagination' – a specific verb and resource. Distinguishes from siblings like zendesk_get_ticket (single ticket) and zendesk_search_tickets (search-based).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Describes pagination and parameters, implying usage for listing all tickets with sorting and filtering. However, lacks explicit guidance on when to use this vs alternatives like search_tickets or get_ticket.

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/michaelrice/zendesk-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server