Elasticsearch MCP Server

by sajitsasi

3 stars
143 downloads
Not rated
GitHub

About

Elasticsearch MCP Server is an MCP (Model Context Protocol) server that provides tools and resources to interact with Elasticsearch clusters. It is designed for developers and AI agents using MCP-compatible clients like Claude.

Details

Author
sajitsasi
GitHub stars
3
Downloads
143
Categories
Database

- List all indices in the cluster
- Get mappings for a specific index
- Perform Elasticsearch searches with query DSL
- Search with a simple query string
- Access cluster and index statistics

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Elasticsearch MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install dependencies, set environment variables ES_CLOUD_ID and ES_API_KEY, then run python es_mcp_server.py. Optionally use configure_mcp_server.py to add the server to Claude's MCP settings.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "elasticsearch mcp server": {
            "es_mcp_server": {
                "command": "python",
                "args": [
                    "configure_mcp_server.py",
                    "your_cloud_id",
                    "your_api_key"
                ]
            }
        }
    }
}

McpServers

{
    "es_mcp_server": {
        "command": "python",
        "args": [
            "configure_mcp_server.py",
            "your_cloud_id",
            "your_api_key"
        ]
    }
}

Elasticsearch MCP Server

This project implements an MCP (Model Context Protocol) server for Elasticsearch, providing tools and resources to interact with Elasticsearch clusters.

License: MIT

Features

Tools

- list_indices: Lists all indices in the Elasticsearch cluster - get_mappings: Gets the mappings for a specific index - search: Performs an Elasticsearch search with a provided query DSL - search_with_query_string: Performs a search with a simple query string - get_index_stats: Gets statistics for a specific index

Resources

- elasticsearch://indices: Lists all Elasticsearch indices - elasticsearch://index/{index_name}: Gets detailed information about a specific index - elasticsearch://mapping/{index_name}: Gets mapping information for a specific index

Prerequisites

- Python 3.7+
- Elasticsearch Python client
- MCP SDK
- Elasticsearch cluster credentials (Cloud ID and API Key)

Setup

1. Clone the repository:

   git clone https://github.com/yourusername/elasticsearch-mcp-server.git
cd elasticsearch-mcp-server

2. Install the required dependencies:

   pip install -r requirements.txt

3. Set up environment variables:
- Copy the example environment file: cp .env.example .env
- Edit the .env file and add your Elasticsearch credentials

Or set them directly in your shell:

   export ES_CLOUD_ID=your_elasticsearch_cloud_id
export ES_API_KEY=your_elasticsearch_api_key

Configuring the MCP Server for Claude

The configure_mcp_server.py script helps you set up the Elasticsearch MCP server in Claude's MCP settings file. This allows Claude to connect to your Elasticsearch cluster through the MCP server.

python configure_mcp_server.py your_cloud_id your_api_key

This script:
1. Takes your Elasticsearch Cloud ID and API Key as command-line arguments
2. Locates or creates the Claude MCP settings file
3. Adds or updates the Elasticsearch MCP server configuration
4. Sets the environment variables needed for the server to connect to your Elasticsearch cluster

After running this script, restart VS Code to apply the changes. Claude will then be able to use the Elasticsearch MCP server to interact with your Elasticsearch cluster.

Testing the MCP Resources

Option 1: Using the Test Script

We've provided a test script that starts the MCP server and provides instructions for testing:

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.