search
Search and organize Zendesk Support data by query, sort criteria, and pagination settings to efficiently retrieve and manage tickets, users, organizations, and more.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number for pagination | |
| per_page | No | Number of results per page (max 100) | |
| query | Yes | Search query string | |
| sort_by | No | Field to sort by | |
| sort_order | No | Sort order (asc or desc) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"page": {
"description": "Page number for pagination",
"type": "number"
},
"per_page": {
"description": "Number of results per page (max 100)",
"type": "number"
},
"query": {
"description": "Search query string",
"type": "string"
},
"sort_by": {
"description": "Field to sort by",
"type": "string"
},
"sort_order": {
"description": "Sort order (asc or desc)",
"enum": [
"asc",
"desc"
],
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- src/tools/search.js:15-31 (handler)The async handler function that implements the core logic of the 'search' tool. It constructs parameters, calls zendeskClient.search(), formats the result as JSON text content, or returns an error message.handler: async ({ query, sort_by, sort_order, page, per_page }) => { try { const params = { sort_by, sort_order, page, per_page }; const result = await zendeskClient.search(query, params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error searching: ${error.message}` }], isError: true }; } }
- src/tools/search.js:8-14 (schema)Zod schema defining the input parameters for the 'search' tool, including query (required) and optional sorting/pagination params.schema: { query: z.string().describe("Search query string"), sort_by: z.string().optional().describe("Field to sort by"), sort_order: z.enum(["asc", "desc"]).optional().describe("Sort order (asc or desc)"), page: z.number().optional().describe("Page number for pagination"), per_page: z.number().optional().describe("Number of results per page (max 100)") },
- src/server.js:48-52 (registration)Registers all tools including 'search' (from searchTools spread into allTools) with the MCP server by calling server.tool() for each tool's name, schema, handler, and description.allTools.forEach((tool) => { server.tool(tool.name, tool.schema, tool.handler, { description: tool.description, }); });
- src/zendesk-client.js:249-252 (helper)Supporting method in ZendeskClient that performs the actual API search request to /search.json, used by the tool handler.// Search async search(query, params = {}) { return this.request("GET", "/search.json", null, { query, ...params }); }
- src/server.js:40-40 (registration)Includes the searchTools array (containing the 'search' tool definition) into the allTools array for subsequent registration....searchTools,