Skip to main content
Glama
Octodet

octodet-elasticsearch-mcp

get_templates

Retrieve index templates from Elasticsearch, optionally filtered by name, to manage and organize data structure configurations efficiently.

Instructions

Get index templates from Elasticsearch

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoOptional template name filter

Implementation Reference

  • The handler function for the 'get_templates' tool. It calls esService.getIndexTemplates(name), formats the templates as JSON text response, and handles errors.
    async ({ name }) => {
      try {
        const templates = await esService.getIndexTemplates(name);
        return {
          content: [
            { type: "text", text: `Index Templates:` },
            { type: "text", text: JSON.stringify(templates, null, 2) },
          ],
        };
      } catch (error) {
        console.error(
          `Failed to get templates: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
        return {
          content: [
            {
              type: "text",
              text: `Error: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    }
  • Input schema for the 'get_templates' tool, defining an optional 'name' string parameter to filter templates.
    {
      name: z.string().optional().describe("Optional template name filter"),
    },
  • src/index.ts:1078-1111 (registration)
    Registration of the 'get_templates' tool using server.tool(), specifying name, description, input schema, and handler.
    server.tool(
      "get_templates",
      "Get index templates from Elasticsearch",
      {
        name: z.string().optional().describe("Optional template name filter"),
      },
      async ({ name }) => {
        try {
          const templates = await esService.getIndexTemplates(name);
          return {
            content: [
              { type: "text", text: `Index Templates:` },
              { type: "text", text: JSON.stringify(templates, null, 2) },
            ],
          };
        } catch (error) {
          console.error(
            `Failed to get templates: ${
              error instanceof Error ? error.message : String(error)
            }`
          );
          return {
            content: [
              {
                type: "text",
                text: `Error: ${
                  error instanceof Error ? error.message : String(error)
                }`,
              },
            ],
          };
        }
      }
    );
  • Helper method in ElasticsearchService that performs the actual Elasticsearch API call to retrieve index templates using client.indices.getIndexTemplate.
    async getIndexTemplates(name?: string): Promise<any> {
      return await this.client.indices.getIndexTemplate({
        name,
      });
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves index templates but doesn't mention any behavioral traits such as whether it requires specific permissions, how it handles errors, if results are paginated, or what the output format looks like. This is a significant gap for a tool with no annotation coverage.

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 with no wasted words. It's front-loaded with the core purpose, making it easy to parse quickly. Every part of the sentence contributes directly to understanding the tool's function.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't address behavioral aspects like permissions or output format, and with sibling tools present, it fails to provide contextual differentiation. For a tool in this environment, more information is needed to guide effective use.

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?

The input schema has 100% description coverage, with the single parameter 'name' documented as an optional template name filter. The description doesn't add any meaning beyond this, such as explaining filter syntax or use cases. Given the high schema coverage, a baseline score of 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Get') and resource ('index templates from Elasticsearch'), making the purpose understandable. However, it doesn't differentiate this tool from sibling tools like 'get_mappings' or 'get_aliases' that also retrieve Elasticsearch metadata, missing an opportunity to clarify its specific scope within the Elasticsearch API.

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?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'list_indices' or 'get_mappings' available, it doesn't specify scenarios where retrieving templates is preferred over other metadata operations, leaving the agent to infer usage context.

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

Related 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/Octodet/elasticsearch-mcp'

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