search_documents
Find documents in Elasticsearch by specifying an index and search query to retrieve relevant data from your cluster.
Instructions
Search for documents.
Args:
index: Name of the index
body: Search query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes | ||
| body | Yes |
Implementation Reference
- src/tools/document.py:10-20 (handler)The MCP tool handler for 'search_documents', decorated with @mcp.tool(), which defines the tool schema via parameters and docstring, and delegates to the search client for execution.@mcp.tool() def search_documents(index: str, body: Dict) -> Dict: """ Search for documents. Args: index: Name of the index body: Search query """ return self.search_client.search_documents(index=index, body=body)
- src/server.py:44-53 (registration)Registers the DocumentTools class (containing search_documents tool) among other tools via ToolsRegister in the MCP server initialization.tool_classes = [ IndexTools, DocumentTools, ClusterTools, AliasTools, DataStreamTools, GeneralTools, ] # Register all tools register.register_all_tools(tool_classes)
- src/clients/common/document.py:6-8 (helper)Helper method in DocumentClient that implements the core search logic by calling the underlying search engine client.def search_documents(self, index: str, body: Dict) -> Dict: """Search for documents in the index.""" return self.client.search(index=index, body=body)