Skip to main content
Glama
Octodet

octodet-elasticsearch-mcp

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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, }; }
  • 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; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Octodet/elasticsearch-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server