get_cluster_stats
Retrieve comprehensive cluster statistics from OpenSearch to monitor health, performance metrics, and resource utilization for effective cluster management.
Instructions
Get cluster statistics
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The async handler function that implements the get_cluster_stats tool. It calls self.es_client.cluster.stats() to retrieve cluster statistics and returns the response as a list of TextContent.@mcp.tool(description="Get cluster statistics") async def get_cluster_stats() -> list[TextContent]: """ Get statistics from a cluster wide perspective. The API returns basic index metrics (shard numbers, store size, memory usage) and information about the current nodes that form the cluster (number, roles, os, jvm versions, memory usage, cpu and installed plugins). https://opensearch.org/docs/latest/tuning-your-cluster/ """ self.logger.info("Getting cluster stats") try: response = self.es_client.cluster.stats() return [TextContent(type="text", text=str(response))] except Exception as e: self.logger.error(f"Error getting cluster stats: {e}") return [TextContent(type="text", text=f"Error: {str(e)}")]
- src/opensearch_mcp_server/server.py:38-38 (registration)Invocation of register_tools on the ClusterTools instance, which registers the get_cluster_stats tool (among others) with the MCP server instance.cluster_tools.register_tools(self.mcp)