get_macro
Retrieve specific Zendesk macros by ID using the Zendesk API MCP Server, enabling efficient management and access to predefined ticket responses and workflows.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Macro ID |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"description": "Macro ID",
"type": "number"
}
},
"required": [
"id"
],
"type": "object"
}
Implementation Reference
- src/tools/macros.js:36-51 (handler)The handler function that executes the 'get_macro' tool logic: fetches the macro via Zendesk client and returns JSON-formatted result or error.handler: async ({ id }) => { try { const result = await zendeskClient.getMacro(id); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error getting macro: ${error.message}` }], isError: true }; } }
- src/tools/macros.js:33-35 (schema)Zod schema defining the input for 'get_macro': requires a numeric 'id' parameter.schema: { id: z.number().describe("Macro ID") },
- src/tools/macros.js:30-52 (registration)Tool definition object for 'get_macro' exported as part of macrosTools array, which is later registered in the MCP server.{ name: "get_macro", description: "Get a specific macro by ID", schema: { id: z.number().describe("Macro ID") }, handler: async ({ id }) => { try { const result = await zendeskClient.getMacro(id); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error getting macro: ${error.message}` }], isError: true }; } } },
- src/zendesk-client.js:170-172 (helper)ZendeskClient helper method that makes the HTTP GET request to the Zendesk API to retrieve a macro by ID.async getMacro(id) { return this.request("GET", `/macros/${id}.json`); }
- src/server.js:48-52 (registration)Generic registration loop in MCP server that registers all tools including 'get_macro' from macrosTools.allTools.forEach((tool) => { server.tool(tool.name, tool.schema, tool.handler, { description: tool.description, }); });