Get Template Version
get_template_versionRetrieve details of a specific template version by providing the template ID and version ID.
Instructions
Retrieve details of a specific template version
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| template_id | Yes | ID of the template | |
| version_id | Yes | ID of the version to retrieve |
Implementation Reference
- src/tools/templates.ts:191-195 (handler)The handler function for get_template_version. It makes a GET request to the SendGrid API endpoint /v3/templates/{template_id}/versions/{version_id} and returns the result.
handler: async ({ template_id, version_id }: { template_id: string; version_id: string }): Promise<ToolResult> => { const result = await makeRequest(`https://api.sendgrid.com/v3/templates/${template_id}/versions/${version_id}`); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }, }, - src/tools/templates.ts:183-190 (schema)The config/schema definition for get_template_version, specifying inputSchema with template_id and version_id as required string parameters.
config: { title: "Get Template Version", description: "Retrieve details of a specific template version", inputSchema: { template_id: z.string().describe("ID of the template"), version_id: z.string().describe("ID of the version to retrieve"), }, }, - src/index.ts:20-23 (registration)Tools are registered with the MCP server using server.registerTool(). The get_template_version tool is included in allTools and gets registered here by its name.
// Register all tools for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); } - src/tools/index.ts:7-17 (registration)The templateTools object (which includes get_template_version) is exported from templates.ts and spread into the combined allTools export.
import { templateTools } from "./templates.js"; export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, }; - src/shared/api.ts:3-18 (helper)The makeRequest helper used by the get_template_version handler to make authenticated HTTP requests to the SendGrid API.
export async function makeRequest(url: string, options: RequestInit = {}): Promise<any> { const response = await fetch(url, { headers: { ...getAuthHeaders(), ...options.headers, }, ...options, }); if (!response.ok) { const errorText = await response.text(); throw new Error(`SendGrid API error (${response.status}): ${errorText}`); } return response.json(); }