delete_index_template
Delete an existing Elasticsearch index template by specifying its name. This tool helps manage index templates, removing those that are no longer needed.
Instructions
Delete an Elasticsearch index template
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the template to delete |
Implementation Reference
- src/tools/createIndexTemplate.ts:122-150 (handler)The actual handler function that executes the delete_index_template tool logic. It calls esClient.indices.deleteIndexTemplate with the provided name and returns a success/error message.
export async function deleteIndexTemplate( esClient: Client, name: string ) { try { const response = await esClient.indices.deleteIndexTemplate({ name }); return { content: [ { type: "text" as const, text: response.acknowledged ? `Index template "${name}" deleted successfully.` : `Index template delete request sent, but not acknowledged. Check cluster status.` } ] }; } catch (error) { console.error(`Delete index template failed: ${error instanceof Error ? error.message : String(error)}`); return { content: [ { type: "text" as const, text: `Error: ${error instanceof Error ? error.message : String(error)}` } ] }; - src/server.ts:276-290 (registration)Registers the 'delete_index_template' tool with the MCP server, defining the schema (name: zod string) and wiring it to the deleteIndexTemplate handler.
// Delete an index template server.tool( "delete_index_template", "Delete an Elasticsearch index template", { name: z .string() .trim() .min(1, "Template name is required") .describe("Name of the template to delete") }, async ({ name }) => { return await deleteIndexTemplate(esClient, name); } ); - src/server.ts:13-27 (helper)Import of the deleteIndexTemplate function from the tools module to be used in server registration.
import { createIndexTemplate, getIndexTemplate, deleteIndexTemplate } from "./tools/createIndexTemplate.js"; export { listIndices, getMappings, search, getClusterHealth, createIndex, createMapping, bulk, reindex, createIndexTemplate, getIndexTemplate, deleteIndexTemplate }; - src/server.ts:24-27 (helper)Re-export of deleteIndexTemplate alongside other tool functions for external use.
createIndexTemplate, getIndexTemplate, deleteIndexTemplate };