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
| Name | Required | Description | Default |
|---|---|---|---|
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)}")]
- src/opensearch_mcp_server/server.py:36-36 (registration)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)
- src/opensearch_mcp_server/server.py:28-28 (registration)Instantiation of the IndexTools class instance that provides the 'list_indices' tool.index_tools = IndexTools(self.logger)
- src/opensearch_mcp_server/server.py:4-4 (registration)Import of the IndexTools class containing the 'list_indices' tool.from .tools.index import IndexTools