elasticsearch-mcp-server
by: cr7258
A Model Context Protocol (MCP) server implementation that provides Elasticsearch interaction.
📌Overview
Purpose: To provide a Model Context Protocol (MCP) server implementation for effective interaction with Elasticsearch, enhancing document search, index analysis, and cluster management.
Overview: The Elasticsearch MCP Server serves as a bridge for users to interact seamlessly with Elasticsearch, facilitating operations like searching for documents, retrieving index configurations, and monitoring cluster health through a variety of easy-to-use tools.
Key Features:
-
Index Operations: Includes functions like
list_indices
,get_mapping
, andget_settings
that enable users to manage and retrieve information about indices in the Elasticsearch cluster. -
Document Operations: The
search_documents
feature allows users to execute complex searches within an index using Elasticsearch’s Query DSL, streamlining data retrieval tasks. -
Cluster Operations: Functions such as
get_cluster_health
andget_cluster_stats
provide valuable insights into the overall status and statistics of the Elasticsearch cluster, helping maintain optimal performance.
Elasticsearch MCP Server
Overview
Elasticsearch MCP Server is a Model Context Protocol (MCP) server implementation that enables interaction with Elasticsearch. It allows users to search documents, analyze indices, and manage clusters through various tools.
Demo
For a demonstration, visit: Demo Link
Features
Index Operations
- list_indices: List all indices in the Elasticsearch cluster.
- get_mapping: Retrieve the mapping configuration for a specific index.
- get_settings: Get the settings configuration for a specific index.
Document Operations
- search_documents: Search documents in an index using Elasticsearch Query DSL.
Cluster Operations
- get_cluster_health: Get health status of the cluster.
- get_cluster_stats: Get statistical information about the cluster.
Start Elasticsearch Cluster
You can start the Elasticsearch cluster using Docker Compose:
docker-compose up -d
This command will initiate a 3-node Elasticsearch cluster along with Kibana. The default credentials are:
- Username:
elastic
- Password:
test123
You can access Kibana at http://localhost:5601.
Usage with Claude Desktop
Option 1: Installing via Smithery
To automatically install the Elasticsearch Server for Claude Desktop using Smithery, run:
npx -y @smithery/cli install elasticsearch-mcp-server --client claude
Option 2: Using uvx
To install the package using uvx
, add the following configuration to Claude Desktop's config file claude_desktop_config.json
:
{
"mcpServers": {
"elasticsearch-mcp-server": {
"command": "uvx",
"args": [
"elasticsearch-mcp-server"
],
"env": {
"ELASTIC_HOST": "https://localhost:9200",
"ELASTIC_USERNAME": "elastic",
"ELASTIC_PASSWORD": "test123"
}
}
}
}
Option 3: Using uv
for local development
To use uv
, clone the repository and specify the local path in the claude_desktop_config.json
:
{
"mcpServers": {
"elasticsearch": {
"command": "uv",
"args": [
"--directory",
"path/to/src/elasticsearch_mcp_server",
"run",
"elasticsearch-mcp-server"
],
"env": {
"ELASTIC_HOST": "https://localhost:9200",
"ELASTIC_USERNAME": "elastic",
"ELASTIC_PASSWORD": "test123"
}
}
}
}
Configuration file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%/Claude/claude_desktop_config.json
After editing the config, restart Claude Desktop to load the new MCP server. You can then interact with your Elasticsearch cluster using natural language commands, such as:
- "List all indices in the cluster"
- "How old is the student Bob?"
- "Show me the cluster health status"
License
This project is licensed under the Apache License Version 2.0 - see the LICENSE
file for details.