Skip to main content
Glama
cr7258

Elasticsearch MCP Server

get_document

Retrieve a specific document from an Elasticsearch index using its unique ID to access stored data.

Instructions

        Get a document by ID.
        
        Args:
            index: Name of the index
            id: Document ID
        

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYes
idYes

Implementation Reference

  • The MCP tool handler for 'get_document'. It retrieves a document from the specified index by ID using the search client.
    @mcp.tool()
    def get_document(index: str, id: str) -> Dict:
        """
        Get a document by ID.
        
        Args:
            index: Name of the index
            id: Document ID
        """
        return self.search_client.get_document(index=index, id=id)
  • The underlying helper method in DocumentClient that performs the actual document retrieval using the base client.
    def get_document(self, index: str, id: str) -> Dict:
        """Get a document by ID."""
        return self.client.get(index=index, id=id)
  • src/server.py:38-53 (registration)
    Top-level registration point where DocumentTools is included in the list of tool classes passed to ToolsRegister.register_all_tools.
    def _register_tools(self):
        """Register all MCP tools."""
        # Create a tools register
        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)
  • Logic in ToolsRegister.register_all_tools that instantiates each tool class (including DocumentTools) and registers their tools via with_exception_handling, which calls register_tools.
    for tool_class in tool_classes:
        self.logger.info(f"Registering tools from {tool_class.__name__}")
        tool_instance = tool_class(self.search_client)
        
        # Set logger and client attributes
        tool_instance.logger = self.logger
        tool_instance.search_client = self.search_client
        
        # Check if risk management is enabled (high-risk operations are disabled)
        if risk_manager.high_risk_ops_disabled:
            # Add risk manager attributes for filtering
            tool_instance.risk_manager = risk_manager
            tool_instance.tool_class_name = tool_class.__name__
            # Register tools with risk filtering
            self._register_with_risk_filter(tool_instance)
        else:
            # Register tools with just exception handling (original way)
            with_exception_handling(tool_instance, self.mcp)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves a document but doesn't cover critical aspects like whether it's a read-only operation, error handling for missing documents, authentication needs, or rate limits. This is a significant gap for a tool with zero annotation coverage.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, with the core purpose stated first followed by parameter details. The two-sentence structure is efficient, though the 'Args:' section could be integrated more smoothly into the flow.

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

Completeness2/5

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

Given the tool's complexity (2 required parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns, error conditions, or behavioral traits, making it inadequate for safe and effective use by an agent.

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

Parameters3/5

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

The description lists both parameters ('index' and 'id') with brief explanations, adding meaning beyond the schema which has 0% description coverage. However, it doesn't provide details like format examples, constraints, or how they interact, leaving the agent with only basic semantic context.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('document by ID'), making it immediately understandable. However, it doesn't differentiate from sibling tools like 'get_index' or 'get_data_stream', which also retrieve resources by ID, so it lacks sibling distinction.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose 'get_document' over 'search_documents' or 'get_index', nor does it specify prerequisites like needing an existing document ID. This leaves the agent without contextual usage cues.

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