search_documents
Query and retrieve documents from Elasticsearch clusters by specifying an index and search query using the MCP server for precise and scalable information retrieval.
Instructions
Search for documents.
Args:
index: Name of the index
body: Search query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | ||
| index | Yes |
Implementation Reference
- src/tools/document.py:10-20 (handler)The FastMCP tool handler for 'search_documents', decorated with @mcp.tool(), including input schema via type hints and docstring, and logic delegating to search_client.@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)Top-level registration where DocumentTools (containing search_documents tool) is included in tool_classes list and registered via ToolsRegister.register_all_tools.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)Underlying helper method in DocumentClient that implements the document search logic by calling self.client.search (the 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)