list_indices
Retrieve a list of all indices in your OpenSearch cluster to manage data organization and monitor storage.
Instructions
List all indices in the Opensearch cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The async handler function that implements the logic for the 'list_indices' MCP tool. It queries the OpenSearch cluster for indices and returns them as TextContent.@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 point where IndexTools.register_tools is called to register the list_indices tool (among others) with the MCP server.index_tools.register_tools(self.mcp)