Skip to main content
Glama
cr7258

Elasticsearch MCP Server

get_index

Retrieve index metadata including mappings, settings, and aliases from Elasticsearch clusters to understand data structure and configuration.

Instructions

        Returns information (mappings, settings, aliases) about one or more indices.
        
        Args:
            index: Name of the index
        

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYes

Implementation Reference

  • MCP tool handler for 'get_index'. Decorated with @mcp.tool(), it takes an index name and delegates to the search_client's get_index method to retrieve index information.
    @mcp.tool()
    def get_index(index: str) -> Dict:
        """
        Returns information (mappings, settings, aliases) about one or more indices.
        
        Args:
            index: Name of the index
        """
        return self.search_client.get_index(index=index)
  • IndexTools.register_tools method registers all index-related MCP tools, including 'get_index', by defining them with @mcp.tool() decorators.
    def register_tools(self, mcp: FastMCP):
        @mcp.tool()
        def list_indices() -> List[Dict]:
            """List all indices."""
            return self.search_client.list_indices()
    
        @mcp.tool()
        def get_index(index: str) -> Dict:
            """
            Returns information (mappings, settings, aliases) about one or more indices.
            
            Args:
                index: Name of the index
            """
            return self.search_client.get_index(index=index)
    
        @mcp.tool()
        def create_index(index: str, body: Optional[Dict] = None) -> Dict:
            """
            Create a new index.
            
            Args:
                index: Name of the index
                body: Optional index configuration including mappings and settings
            """
            return self.search_client.create_index(index=index, body=body)
    
        @mcp.tool()
        def delete_index(index: str) -> Dict:
            """
            Delete an index.
            
            Args:
                index: Name of the index
            """
            return self.search_client.delete_index(index=index)
  • Helper method in IndexClient that implements the core logic for retrieving index information by calling the underlying client's indices.get() method.
    def get_index(self, index: str) -> Dict:
        """Returns information (mappings, settings, aliases) about one or more indices."""
        return self.client.indices.get(index=index)

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