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)

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