Skip to main content
Glama
cr7258

Elasticsearch MCP Server

delete_by_query

Delete Elasticsearch documents matching a specific query to remove targeted data from an index.

Instructions

        Deletes documents matching the provided query.
        
        Args:
            index: Name of the index
            body: Query to match documents for deletion
        

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYes
bodyYes

Implementation Reference

  • The main MCP tool handler for delete_by_query. Decorated with @mcp.tool() for registration and execution. Delegates to the search_client's delete_by_query method.
    @mcp.tool()
    def delete_by_query(index: str, body: Dict) -> Dict:
        """
        Deletes documents matching the provided query.
        
        Args:
            index: Name of the index
            body: Query to match documents for deletion
        """
        return self.search_client.delete_by_query(index=index, body=body)
  • Supporting method in DocumentClient class that proxies the delete_by_query call to the underlying Elasticsearch/OpenSearch client.
    def delete_by_query(self, index: str, body: Dict) -> Dict:
        """Deletes documents matching the provided query."""
        return self.client.delete_by_query(index=index, body=body)
  • src/server.py:40-53 (registration)
    Central registration point where DocumentTools (containing delete_by_query) is included in the list of tool classes to register with the MCP server.
    # Create a tools register
    register = ToolsRegister(self.logger, self.search_client, self.mcp)
    
    # Define all tool classes to register
    tool_classes = [
        IndexTools,
        DocumentTools,
        ClusterTools,
        AliasTools,
        DataStreamTools,
        GeneralTools,
    ]        
    # Register all tools
    register.register_all_tools(tool_classes)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool deletes documents, implying a destructive mutation, but fails to add context on permissions, rate limits, reversibility, or what happens to matched documents. For a deletion tool, this is a significant gap in safety and operational details.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose in the first sentence. The 'Args' section is structured but could be more integrated. There's no wasted text, though it could be slightly more concise by merging the purpose and parameter explanations.

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 tool's complexity (destructive deletion with query matching), lack of annotations, no output schema, and low schema description coverage, the description is incomplete. It doesn't address critical aspects like return values, error handling, or the scope of deletion (e.g., partial vs. complete matches), leaving significant gaps for agent understanding.

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 description includes an 'Args' section that lists parameters ('index' and 'body') with brief explanations, adding meaning beyond the input schema, which has 0% description coverage. However, the explanations are minimal ('Name of the index', 'Query to match documents for deletion') and don't fully compensate for the schema's lack of details, such as query format or index constraints.

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 tool's purpose: 'Deletes documents matching the provided query.' It specifies the verb ('deletes') and resource ('documents'), making the action explicit. However, it doesn't distinguish this from sibling tools like 'delete_document' or 'delete_index,' which limits differentiation.

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. It lacks context such as prerequisites, when-not-to-use scenarios, or comparisons to siblings like 'delete_document' (which might delete by ID) or 'delete_index' (which deletes entire indices). This omission leaves the agent without usage direction.

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/cr7258/elasticsearch-mcp-server'

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