Elasticsearch 7.x MCP server

Integrates with Elasticsearch 7.x, providing efficient data management and search capabilities for projects requiring robust analytics within the ecosystem.
Back to servers
Setup instructions
Provider
Lewis Chung
Release date
Mar 06, 2025
Language
Python
Stats
3 stars

The Elasticsearch 7.x MCP Server provides a Model Context Protocol interface for interacting with Elasticsearch 7.x, allowing you to perform search operations, aggregations, and other Elasticsearch functionality through any MCP client.

Requirements

  • Python 3.10+
  • Elasticsearch 7.x (7.17.x recommended)

Installation Options

Using Smithery

For an automated installation with Claude Desktop:

npx -y @smithery/cli install @imlewc/elasticsearch7-mcp-server --client claude

Manual Installation

Install directly from the source:

pip install -e .

Using Docker Compose

  1. Create a .env file with your Elasticsearch password:
ELASTIC_PASSWORD=your_secure_password
  1. Start all services:
docker-compose up -d

This launches a three-node Elasticsearch 7.17.10 cluster, Kibana, and the MCP server.

Configuration

The server requires the following environment variables:

  • ELASTIC_HOST: Elasticsearch host address (e.g., http://localhost:9200)
  • ELASTIC_USERNAME: Elasticsearch username
  • ELASTIC_PASSWORD: Elasticsearch password
  • MCP_PORT: (Optional) MCP server listening port, default 9999

Using the MCP Server

Connect to the server using any MCP client:

from mcp import MCPClient

client = MCPClient("localhost:9999")
response = client.call("es-ping")
print(response)  # {"success": true}

API Reference

Available Methods

  • es-ping: Check Elasticsearch connection
  • es-info: Get Elasticsearch cluster information
  • es-search: Search documents in Elasticsearch index

Search Examples

Basic Search

search_response = client.call("es-search", {
    "index": "my_index",
    "query": {
        "match": {
            "title": "search keywords"
        }
    },
    "size": 10,
    "from": 0
})

Aggregation Query

agg_response = client.call("es-search", {
    "index": "my_index",
    "size": 0,  # Only need aggregation results, no documents
    "aggs": {
        "categories": {
            "terms": {
                "field": "category.keyword",
                "size": 10
            }
        },
        "avg_price": {
            "avg": {
                "field": "price"
            }
        }
    }
})

Advanced Search with Highlighting and Sorting

advanced_response = client.call("es-search", {
    "index": "my_index",
    "query": {
        "bool": {
            "must": [
                {"match": {"content": "search term"}}
            ],
            "filter": [
                {"range": {"price": {"gte": 100, "lte": 200}}}
            ]
        }
    },
    "sort": [
        {"date": {"order": "desc"}},
        "_score"
    ],
    "highlight": {
        "fields": {
            "content": {}
        }
    },
    "_source": ["title", "date", "price"]
})

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "elasticsearch7-mcp-server" '{"command":"elasticsearch7-mcp-server","args":[]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "elasticsearch7-mcp-server": {
            "command": "elasticsearch7-mcp-server",
            "args": []
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "elasticsearch7-mcp-server": {
            "command": "elasticsearch7-mcp-server",
            "args": []
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later