list_macros
Retrieve and manage Zendesk macros programmatically by fetching paginated results, specifying page numbers and the number of macros per page for efficient API integration.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number for pagination | |
| per_page | No | Number of macros per page (max 100) |
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 macros per page (max 100)",
"type": "number"
}
},
"type": "object"
}
Implementation Reference
- src/tools/macros.js:12-27 (handler)The handler function that executes the list_macros tool logic: constructs parameters, calls the Zendesk client's listMacros method, formats the result as JSON text content or handles errors.handler: async ({ page, per_page }) => { try { const params = { page, per_page }; const result = await zendeskClient.listMacros(params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error listing macros: ${error.message}` }], isError: true }; }
- src/tools/macros.js:8-11 (schema)Zod schema defining optional input parameters for pagination: page and per_page.schema: { page: z.number().optional().describe("Page number for pagination"), per_page: z.number().optional().describe("Number of macros per page (max 100)") },
- src/server.js:47-52 (registration)Registration code that iterates over allTools (which includes macrosTools containing list_macros) and calls server.tool for each, providing name, schema, handler, and description.// Register each tool with the server allTools.forEach((tool) => { server.tool(tool.name, tool.schema, tool.handler, { description: tool.description, }); });
- src/server.js:36-36 (registration)The line where macrosTools (containing the list_macros tool) is spread into the allTools array used for registration....macrosTools,
- src/zendesk-client.js:166-168 (helper)Supporting method in ZendeskClient that performs the actual API request to list macros via GET /macros.json.async listMacros(params) { return this.request("GET", "/macros.json", null, params); }