get_cluster_health
Retrieve detailed health status of the Elasticsearch cluster to monitor performance, identify issues, and ensure optimal functionality.
Instructions
Get health information about the Elasticsearch cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:327-365 (handler)MCP tool registration and handler implementation for get_cluster_health. It invokes the Elasticsearch service to fetch cluster health and returns formatted text response with JSON data.server.tool( "get_cluster_health", "Get health information about the Elasticsearch cluster", {}, async () => { try { const health = await esService.getClusterHealth(); return { content: [ { type: "text", text: `Elasticsearch Cluster Health:`, }, { type: "text", text: JSON.stringify(health, null, 2), }, ], }; } catch (error) { console.error( `Failed to get cluster health: ${ error instanceof Error ? error.message : String(error) }` ); return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
- Helper method in ElasticsearchService that performs the actual client.cluster.health() API call and maps the response to ClusterHealth interface.async getClusterHealth(): Promise<ClusterHealth> { const response = await this.client.cluster.health(); return { status: response.status, nodeCount: response.number_of_nodes, datanodeCount: response.number_of_data_nodes, activePrimaryShards: response.active_primary_shards, activeShards: response.active_shards, relocatingShards: response.relocating_shards, initializingShards: response.initializing_shards, unassignedShards: response.unassigned_shards, pendingTasks: response.number_of_pending_tasks, }; }
- src/utils/models.ts:37-47 (schema)TypeScript interface defining the structure of the cluster health response data.export interface ClusterHealth { status: string; nodeCount: number; datanodeCount: number; activePrimaryShards: number; activeShards: number; relocatingShards: number; initializingShards: number; unassignedShards: number; pendingTasks: number; }