create_macro
Streamline Zendesk ticket management by creating macros with specific actions, such as modifying fields or setting values, to automate repetitive tasks and improve efficiency.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| actions | Yes | Actions to perform when macro is applied | |
| description | No | Macro description | |
| title | Yes | Macro title |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"actions": {
"description": "Actions to perform when macro is applied",
"items": {
"additionalProperties": false,
"properties": {
"field": {
"description": "Field to modify",
"type": "string"
},
"value": {
"description": "Value to set"
}
},
"required": [
"field"
],
"type": "object"
},
"type": "array"
},
"description": {
"description": "Macro description",
"type": "string"
},
"title": {
"description": "Macro title",
"type": "string"
}
},
"required": [
"title",
"actions"
],
"type": "object"
}
Implementation Reference
- src/tools/macros.js:64-85 (handler)The asynchronous handler function that processes the create_macro tool invocation. It builds the macro data object from the input parameters (title, description, actions) and calls zendeskClient.createMacro to perform the API request, then formats a success or error response.handler: async ({ title, description, actions }) => { try { const macroData = { title, description, actions }; const result = await zendeskClient.createMacro(macroData); return { content: [{ type: "text", text: `Macro created successfully!\n\n${JSON.stringify(result, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating macro: ${error.message}` }], isError: true }; } }
- src/tools/macros.js:56-63 (schema)Zod schema for validating inputs to the create_macro tool: required 'title' (string), optional 'description' (string), and 'actions' (array of objects each with 'field' (string) and 'value' (any)).schema: { title: z.string().describe("Macro title"), description: z.string().optional().describe("Macro description"), actions: z.array(z.object({ field: z.string().describe("Field to modify"), value: z.any().describe("Value to set") })).describe("Actions to perform when macro is applied") },
- src/server.js:48-52 (registration)Registration loop in the MCP server that dynamically registers all tools, including 'create_macro', by iterating over the combined allTools array (which includes macrosTools containing create_macro) and calling server.tool() for each.allTools.forEach((tool) => { server.tool(tool.name, tool.schema, tool.handler, { description: tool.description, }); });
- src/zendesk-client.js:174-176 (helper)ZendeskClient helper method invoked by the create_macro handler. Performs a POST request to the Zendesk Macros API endpoint (/macros.json) with the macro data wrapped in a 'macro' object.async createMacro(data) { return this.request("POST", "/macros.json", { macro: data }); }