Skip to main content
Glama
awesimon

Elasticsearch MCP Server

get_index_template

Retrieve Elasticsearch index template configurations to manage data structure definitions and ensure consistent indexing patterns across your cluster.

Instructions

Get information about Elasticsearch index templates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoOptional template name filter - if omitted, all templates are returned

Implementation Reference

  • The core handler function that executes the tool logic: calls Elasticsearch's getIndexTemplate API, processes the response by extracting index patterns, version, and priority, formats into text content blocks, handles no-results case, and error handling.
    export async function getIndexTemplate( esClient: Client, name?: string ) { try { const params: Record<string, any> = {}; if (name) { params.name = name; } const response = await esClient.indices.getIndexTemplate(params); const templates = response.index_templates || []; const content = templates.map(template => { const patterns = template.index_template.index_patterns || []; const version = template.index_template.version || "Not specified"; const priority = template.index_template.priority || "Not specified"; let patternsText = ""; if (Array.isArray(patterns)) { patternsText = patterns.join(", "); } else if (typeof patterns === "string") { patternsText = patterns; } return { type: "text" as const, text: `Template: ${template.name}\nIndex patterns: ${patternsText}\nVersion: ${version}\nPriority: ${priority}\n` }; }); if (content.length === 0) { content.push({ type: "text" as const, text: name ? `No template found with name "${name}"` : "No index templates found" }); } return { content }; } catch (error) { console.error(`Get 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:262-274 (registration)
    MCP tool registration using server.tool(), including tool name, description, Zod input schema (optional 'name' parameter), and the async handler wrapper that calls the getIndexTemplate function.
    server.tool( "get_index_template", "Get information about Elasticsearch index templates", { name: z .string() .optional() .describe("Optional template name filter - if omitted, all templates are returned") }, async ({ name }) => { return await getIndexTemplate(esClient, name); } );
  • Zod schema for the tool's input parameter: an optional string 'name' for filtering the template.
    { name: z .string() .optional() .describe("Optional template name filter - if omitted, all templates are returned") },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/awesimon/elasticsearch-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server