Skip to main content
Glama
cr7258

Elasticsearch MCP Server

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
NameRequiredDescriptionDefault
indexYes
bodyYes

Implementation Reference

  • 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)
  • 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)

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