zendesk_get_ticket
Retrieve a specific Zendesk ticket by its ID using the Zendesk MCP Server, enabling efficient access to ticket details for streamlined support management.
Instructions
Get a Zendesk ticket by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ticket_id | Yes | The ID of the ticket to retrieve |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"ticket_id": {
"description": "The ID of the ticket to retrieve",
"type": "string"
}
},
"required": [
"ticket_id"
],
"type": "object"
}
Implementation Reference
- src/tools/index.ts:97-116 (handler)The handler function for the zendesk_get_ticket tool. It parses the ticket_id, fetches the ticket using the getTicket helper with the global Zendesk client, and returns the result as JSON text or an error message.async ({ ticket_id }) => { try { const result = await getTicket(client, parseInt(ticket_id, 10)); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message || 'Unknown error occurred'}` }], isError: true }; } }
- src/tools/index.ts:94-96 (schema)Input schema using Zod for the zendesk_get_ticket tool, defining ticket_id as a string.{ ticket_id: z.string().describe("The ID of the ticket to retrieve"), },
- src/tools/index.ts:91-117 (registration)Registration of the zendesk_get_ticket tool using server.tool, including name, description, input schema, and handler function.server.tool( "zendesk_get_ticket", "Get a Zendesk ticket by ID", { ticket_id: z.string().describe("The ID of the ticket to retrieve"), }, async ({ ticket_id }) => { try { const result = await getTicket(client, parseInt(ticket_id, 10)); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message || 'Unknown error occurred'}` }], isError: true }; } } );
- src/tools/index.ts:23-33 (helper)Helper function getTicket that wraps the Zendesk client's tickets.show callback API into a Promise to fetch a ticket by ID.export async function getTicket(client: any, ticketId: number): Promise<any> { return new Promise((resolve, reject) => { client.tickets.show(ticketId, (error: Error | undefined, req: any, result: any) => { if (error) { reject(error); } else { resolve(result); } }); }); }