Skip to main content
Glama
seohyunjun

OpenSearch MCP Server

by seohyunjun

list_indices

Retrieve a comprehensive list of all indices in an OpenSearch cluster to facilitate index management and analysis.

Instructions

List all indices in the Opensearch cluster

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_indices' tool. It uses the OpenSearch client's cat.indices API to list all indices and returns them as TextContent objects.
    @mcp.tool(description="List all indices in the Opensearch cluster") async def list_indices() -> list[TextContent]: """ List all indices in the Opensearch cluster. It is important to check the indices before searching documents to understand what indices are avilable. """ self.logger.info("Listing indices...") try: indices = self.es_client.cat.indices(format="json") return [TextContent(type="text", text=str(indices))] except Exception as e: self.logger.error(f"Error listing indices: {e}") return [TextContent(type="text", text=f"Error: {str(e)}")]
  • The call to register_tools on the IndexTools instance, which registers the 'list_indices' tool (among others) with the MCP server.
    index_tools.register_tools(self.mcp)
  • Instantiation of the IndexTools class instance that provides the 'list_indices' tool.
    index_tools = IndexTools(self.logger)
  • Import of the IndexTools class containing the 'list_indices' tool.
    from .tools.index import IndexTools

Other Tools

Related 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/seohyunjun/opensearch-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server