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)
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully disclose behavioral traits. It only states the action ('Search for documents') without any details on permissions, rate limits, pagination, error handling, or what the search returns (e.g., results format, relevance scoring). This leaves critical behavioral aspects unspecified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief with two sentences, which is appropriately sized. However, it is not front-loaded with key information; the first sentence is vague, and the args section lacks detail. While concise, it under-specifies rather than being efficiently informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (search operation with 2 parameters including a nested object), lack of annotations, and no output schema, the description is severely incomplete. It fails to explain what the tool does beyond the name, how to use parameters effectively, or what to expect in return. This is inadequate for a search tool in a document management system.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It lists 'index' and 'body' as args but provides no semantic meaning beyond their names. For example, it does not explain what an 'index' is in this context, what the 'body' should contain (e.g., query DSL, filters), or examples of valid values. This adds minimal value over the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Search for documents' which is a tautology of the tool name 'search_documents'. It does not specify what type of documents, what search capabilities exist, or how it differs from sibling tools like 'get_document' or 'index_document'. The purpose is stated but lacks specificity and differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this tool versus alternatives. The description does not mention prerequisites (e.g., needing an existing index), exclusions, or comparisons to siblings like 'get_document' (for retrieval by ID) or 'list_indices' (for browsing). Usage context is entirely missing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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