Skip to main content
Glama
Octodet

octodet-elasticsearch-mcp

create_index

Define and configure Elasticsearch index with custom settings and field mappings for efficient data organization and retrieval.

Instructions

Create a new Elasticsearch index with optional settings and mappings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYesName of the new Elasticsearch index to create
mappingsNoOptional index mappings defining field types and properties
settingsNoOptional index settings like number of shards, replicas, etc.

Implementation Reference

  • The handler function for the 'create_index' tool. It calls esService.createIndex with the provided index name, settings, and mappings, then returns a success message or error.
    async ({ index, settings, mappings }) => {
      try {
        const response = await esService.createIndex(index, settings, mappings);
        return {
          content: [
            {
              type: "text",
              text: `Index '${index}' created successfully.`,
            },
          ],
        };
      } catch (error) {
        console.error(
          `Failed to create index: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
        return {
          content: [
            {
              type: "text",
              text: `Error: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    }
  • Input schema for the 'create_index' tool using Zod, defining parameters: index (required string), settings (optional record), mappings (optional record).
    {
      index: z
        .string()
        .trim()
        .min(1, "Index name is required")
        .describe("Name of the new Elasticsearch index to create"),
      settings: z
        .record(z.any())
        .optional()
        .describe(
          "Optional index settings like number of shards, replicas, etc."
        ),
      mappings: z
        .record(z.any())
        .optional()
        .describe(
          "Optional index mappings defining field types and properties"
        ),
    },
  • src/index.ts:938-988 (registration)
    Registration of the 'create_index' tool using server.tool(), including name, description, input schema, and handler function.
      "create_index",
      "Create a new Elasticsearch index with optional settings and mappings",
      {
        index: z
          .string()
          .trim()
          .min(1, "Index name is required")
          .describe("Name of the new Elasticsearch index to create"),
        settings: z
          .record(z.any())
          .optional()
          .describe(
            "Optional index settings like number of shards, replicas, etc."
          ),
        mappings: z
          .record(z.any())
          .optional()
          .describe(
            "Optional index mappings defining field types and properties"
          ),
      },
      async ({ index, settings, mappings }) => {
        try {
          const response = await esService.createIndex(index, settings, mappings);
          return {
            content: [
              {
                type: "text",
                text: `Index '${index}' created successfully.`,
              },
            ],
          };
        } catch (error) {
          console.error(
            `Failed to create index: ${
              error instanceof Error ? error.message : String(error)
            }`
          );
          return {
            content: [
              {
                type: "text",
                text: `Error: ${
                  error instanceof Error ? error.message : String(error)
                }`,
              },
            ],
          };
        }
      }
    );
  • The ElasticsearchService.createIndex method, which performs the actual index creation using the Elasticsearch client, incorporating optional settings and mappings.
    async createIndex(
      index: string,
      settings?: any,
      mappings?: any
    ): Promise<any> {
      const body: any = {};
    
      if (settings) {
        body.settings = settings;
      }
    
      if (mappings) {
        body.mappings = mappings;
      }
    
      return await this.client.indices.create({
        index,
        ...(Object.keys(body).length > 0 ? { body } : {}),
      });
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states 'Create' implying a write/mutation operation but fails to disclose critical behavioral traits: whether this requires admin permissions, if it overwrites existing indices, what happens on failure, or any rate limits. This is inadequate for a mutation tool with zero 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 zero waste. It is front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place without redundancy.

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 complexity (mutation tool with nested objects) and lack of annotations/output schema, the description is incomplete. It omits behavioral details (e.g., permissions, idempotency), error handling, and return values, leaving significant gaps for an AI agent to invoke it correctly.

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%, so the schema fully documents all three parameters. The description adds minimal value by mentioning 'optional settings and mappings' but does not elaborate beyond what the schema provides (e.g., no examples or constraints). Baseline 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.

Purpose5/5

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

The description clearly states the specific action ('Create a new Elasticsearch index') and resource ('index'), distinguishing it from sibling tools like 'list_indices' (read) and 'delete_index' (destructive). It also mentions optional components ('with optional settings and mappings'), providing precise scope.

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 like 'list_indices' for checking existing indices or 'delete_index' for removal. It lacks context about prerequisites (e.g., index naming conventions) or exclusions, leaving usage decisions ambiguous.

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