delete_document
Remove a specific document from an Elasticsearch index by providing the index name and document ID. This tool simplifies document deletion in Elasticsearch clusters.
Instructions
Delete a document by ID.
Args:
index: Name of the index
id: Document ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| index | Yes |
Implementation Reference
- src/tools/document.py:44-54 (handler)The primary MCP tool handler for 'delete_document'. This function is defined and registered using @mcp.tool() within DocumentTools.register_tools. It delegates the deletion to the search client's delete_document method.@mcp.tool() def delete_document(index: str, id: str) -> Dict: """ Delete a document by ID. Args: index: Name of the index id: Document ID """ return self.search_client.delete_document(index=index, id=id)
- src/clients/common/document.py:30-32 (helper)Supporting helper method in DocumentClient (search_client) that performs the actual document deletion by calling the underlying client.delete() method.def delete_document(self, index: str, id: str) -> Dict: """Removes a document from the index.""" return self.client.delete(index=index, id=id)
- src/server.py:41-53 (registration)The DocumentTools class (containing delete_document) is registered via inclusion in tool_classes list passed to ToolsRegister.register_all_tools, which instantiates it and calls its register_tools method.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)
- src/risk_config.py:15-19 (helper)delete_document is flagged as a high-risk operation for DocumentTools, subject to runtime filtering via RiskManager."DocumentTools": { "index_document", "delete_document", "delete_by_query", },