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
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_indices"
}
}Input 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)