Skip to main content
Glama
awesimon

Elasticsearch MCP Server

get_index_template

Retrieve details about Elasticsearch index templates, with an optional filter by template name to narrow results.

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 main handler function 'getIndexTemplate' that executes the tool logic. It accepts an optional 'name' parameter, calls esClient.indices.getIndexTemplate(), formats the response with template name, index patterns, version, and priority, and returns content. Includes 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:261-274 (registration)
    Registration of the 'get_index_template' tool via server.tool(). Defines the schema (optional 'name' string) and calls the getIndexTemplate handler function.
    // Get index templates
    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);
      }
    );
  • Input schema for the 'get_index_template' tool: an optional 'name' string parameter to filter by template name.
    {
      name: z
        .string()
        .optional()
        .describe("Optional template name filter - if omitted, all templates are returned")
    },
  • Import of getIndexTemplate from the tools file into server.ts.
    import { createIndexTemplate, getIndexTemplate, deleteIndexTemplate } from "./tools/createIndexTemplate.js";
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full responsibility for behavioral disclosure. It merely states 'Get information' without describing what information is returned, whether the operation is read-only, or any potential side effects. The agent lacks essential behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the verb and resource. Every word earns its place; there is no redundancy or unnecessary detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool (one optional parameter, no output schema), the description covers basic purpose but fails to specify the return format or structure. It is minimally complete but could benefit from additional context about the expected output.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the schema already explains the 'name' parameter well. The tool description adds no extra semantic meaning beyond what the schema provides, so a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get information about Elasticsearch index templates' uses a clear verb ('Get') and specific resource ('information about Elasticsearch index templates'). It unambiguously states the tool's function and distinguishes it from sibling tools like create_index_template or delete_index_template.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like get_mappings or list_indices. The optional 'name' parameter is mentioned in the schema but not in the description, and there is no indication of typical use cases or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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