Skip to main content
Glama
Octodet

octodet-elasticsearch-mcp

delete_document

Remove a specific document from an Elasticsearch index by providing the index name and document ID for precise data management.

Instructions

Delete a document from a specific Elasticsearch index

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesDocument ID to delete
indexYesName of the Elasticsearch index

Implementation Reference

  • The main handler function for the "delete_document" MCP tool. It receives index and id parameters, calls the esService.deleteDocument helper, and returns a structured response with success or error message in MCP format.
    async ({ index, id }) => {
      try {
        await esService.deleteDocument(index, id);
        return {
          content: [
            {
              type: "text",
              text: `Document with ID '${id}' deleted from index '${index}'.`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error deleting document: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    }
  • Zod-based input schema defining the required 'index' and 'id' string parameters with validation and descriptions for the delete_document tool.
    {
      index: z
        .string()
        .trim()
        .min(1, "Index name is required")
        .describe("Name of the Elasticsearch index"),
      id: z
        .string()
        .min(1, "Document ID is required")
        .describe("Document ID to delete"),
    },
  • src/index.ts:504-542 (registration)
    The server.tool registration call for the "delete_document" tool, specifying name, description, input schema, and handler function.
    server.tool(
      "delete_document",
      "Delete a document from a specific Elasticsearch index",
      {
        index: z
          .string()
          .trim()
          .min(1, "Index name is required")
          .describe("Name of the Elasticsearch index"),
        id: z
          .string()
          .min(1, "Document ID is required")
          .describe("Document ID to delete"),
      },
      async ({ index, id }) => {
        try {
          await esService.deleteDocument(index, id);
          return {
            content: [
              {
                type: "text",
                text: `Document with ID '${id}' deleted from index '${index}'.`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error deleting document: ${
                  error instanceof Error ? error.message : String(error)
                }`,
              },
            ],
          };
        }
      }
    );
  • Supporting helper method in ElasticsearchService class that performs the actual document deletion using the Elasticsearch client.
    async deleteDocument(index: string, id: string): Promise<any> {
      return await this.client.delete({ index, id });
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the action without disclosing critical behavioral traits. It doesn't mention that this is a destructive operation, whether it requires specific permissions, what happens on success/failure, or any rate limits. For a deletion tool with zero annotation coverage, this is a significant gap.

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's appropriately sized and front-loaded with the core action, making it easy to parse quickly.

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?

For a destructive tool with no annotations and no output schema, the description is incomplete. It doesn't explain what gets deleted, the implications of deletion, error conditions, or return values. Given the complexity and lack of structured data, more context is needed for safe and 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?

Schema description coverage is 100%, so the schema already documents both parameters (id and index) with their descriptions. The description adds no additional parameter semantics beyond what the schema provides, maintaining the baseline score when 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 ('Delete') and target resource ('a document from a specific Elasticsearch index'), distinguishing it from siblings like delete_index or delete_by_query. It precisely communicates the tool's function without ambiguity.

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

Usage Guidelines3/5

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

The description implies usage for deleting individual documents by ID, but doesn't explicitly state when to use this versus alternatives like delete_by_query (for bulk deletion) or delete_index (for entire indices). It provides basic context but lacks explicit guidance on exclusions or prerequisites.

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