Custom Elasticsearch MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add custom-elasticsearch -- docker run -i --rm --add-host=host.docker.internal:host-gateway -e ES_URL=http://host.docker.internal:9400 elasticsearch-mcp:latest
README.md

Connects Cursor to Elasticsearch clusters using public-key authorization.

Custom Elasticsearch MCP Server

A simple MCP (Model Context Protocol) server for Elasticsearch designed for cloud environments where your public key is already authorized on the server.

Why This Custom Version?

No API Key Required - Unlike the official Elasticsearch MCP server that requires both ES_URL and ES_API_KEY, this version only needs the URL since your public key is already trusted on the cloud server.

Enhanced Tools - Better usability with optional parameters and improved defaults compared to the official version.

What This Does

This MCP server connects Cursor to your Elasticsearch cluster with 4 powerful tools:

  • list_indices - List all indices (optional pattern filter)
  • search - Full Elasticsearch Query DSL support
  • get_mappings - Get field mappings for any index
  • get_shards - View cluster shard information

Quick Start

Build from Source

git clone https://github.com/M0-AR/Custom-Elasticsearch-MCP-Server.git
cd Custom-Elasticsearch-MCP-Server
docker build -t elasticsearch-mcp:latest .

2. Add to Cursor MCP Configuration

Add this to your .cursor/mcp.json file:

Configuration:

{
    "mcpServers": {
        "elasticsearch-custom": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "--add-host=host.docker.internal:host-gateway",
                "-e",
                "ES_URL=http://host.docker.internal:9400",
                "elasticsearch-mcp:latest"
            ]
        }
    }
}

3. Restart Cursor

Close and reopen Cursor. You should see the elasticsearch-custom server with 4 tools enabled.

Configuration

Environment Variables:

  • ES_URL - Your Elasticsearch URL (default: http://localhost:9400)
  • MAX_CONNECTIONS - Maximum concurrent connections (default: 100)
  • MAX_KEEPALIVE_CONNECTIONS - Maximum keepalive connections (default: 20)
  • CONNECTION_TIMEOUT - Connection timeout in seconds (default: 30)
  • REQUEST_TIMEOUT - Request timeout in seconds (default: 30)

For different Elasticsearch ports:

"ES_URL=http://host.docker.internal:9200"

For high-traffic environments:

"MAX_CONNECTIONS=200",
"MAX_KEEPALIVE_CONNECTIONS=50",
"CONNECTION_TIMEOUT=60",
"REQUEST_TIMEOUT=60"

Example Usage

Once connected in Cursor, you can:

  • List all indices: "Show me all elasticsearch indices"
  • Search data: "Search for sales data in hq.sales index"
  • Get mappings: "What fields are in the hq.menuitems index?"
  • Check cluster: "Show me the elasticsearch cluster status"

Comparison with Official Server

Feature Official Server This Custom Server
Authentication Requires ES_URL + ES_API_KEY Only needs ES_URL (public key authorized)
list_indices Requires indexPattern parameter Optional parameter with "*" default
Tools Available 4 tools (same functions) 4 tools (enhanced usability)
Security API key based Public key authorization
Concurrency Synchronous blocking Async with connection pooling
Performance Single request at a time 100+ concurrent requests

Concurrent Request Handling

This MCP server is designed to handle multiple parallel requests from multiple applications simultaneously using industry best practices:

**Key Features:**

Async/Await Architecture - Non-blocking I/O for parallel request processing ✅ Connection Pooling - Reuses HTTP connections (up to 100 concurrent) ✅ HTTP/2 Support - Multiplexes multiple requests over single connection ✅ Configurable Limits - Adjust connection limits for your workload ✅ Thread-Safe - FastMCP handles concurrent tool execution safely

**Performance Characteristics:**

  • Default: 100 concurrent connections, 20 keepalive connections
  • Scalable: Configure up to 1000+ concurrent connections
  • Efficient: Connection reuse reduces latency by ~50%
  • Reliable: Proper timeout handling prevents connection exhaustion

**Configuration for High Traffic:**

{
    "mcpServers": {
        "elasticsearch-custom": {
            "command": "docker",
            "args": [
                "run", "-i", "--rm",
                "--add-host=host.docker.internal:host-gateway",
                "-e", "ES_URL=http://host.docker.internal:9400",
                "-e", "MAX_CONNECTIONS=200",
                "-e", "MAX_KEEPALIVE_CONNECTIONS=50",
                "-e", "CONNECTION_TIMEOUT=60",
                "-e", "REQUEST_TIMEOUT=60",
                "elasticsearch-mcp:latest"
            ]
        }
    }
}

**Testing Concurrent Requests:**

# Test 10 parallel requests
for i in {1..10}; do

Tools (4)

list_indicesList all indices with an optional pattern filter.
searchPerform a search using full Elasticsearch Query DSL.
get_mappingsRetrieve field mappings for a specific index.
get_shardsView cluster shard information.

Environment Variables

ES_URLYour Elasticsearch URL
MAX_CONNECTIONSMaximum concurrent connections
MAX_KEEPALIVE_CONNECTIONSMaximum keepalive connections
CONNECTION_TIMEOUTConnection timeout in seconds
REQUEST_TIMEOUTRequest timeout in seconds

Configuration

claude_desktop_config.json
{"mcpServers": {"elasticsearch-custom": {"command": "docker", "args": ["run", "-i", "--rm", "--add-host=host.docker.internal:host-gateway", "-e", "ES_URL=http://host.docker.internal:9400", "elasticsearch-mcp:latest"]}}}

Try it

Show me all elasticsearch indices
Search for sales data in hq.sales index
What fields are in the hq.menuitems index?
Show me the elasticsearch cluster status

Frequently Asked Questions

What are the key features of Custom Elasticsearch MCP Server?

Public-key authorization support. Async/Await architecture for non-blocking I/O. Connection pooling for up to 100+ concurrent requests. HTTP/2 support for request multiplexing. Configurable connection and timeout limits.

What can I use Custom Elasticsearch MCP Server for?

Connecting Cursor to secure cloud-hosted Elasticsearch clusters. Performing high-traffic data analysis with concurrent requests. Inspecting cluster health and shard distribution. Querying index mappings to understand data structure for development.

How do I install Custom Elasticsearch MCP Server?

Install Custom Elasticsearch MCP Server by running: git clone https://github.com/M0-AR/Custom-Elasticsearch-MCP-Server.git && cd Custom-Elasticsearch-MCP-Server && docker build -t elasticsearch-mcp:latest .

What MCP clients work with Custom Elasticsearch MCP Server?

Custom Elasticsearch MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Custom Elasticsearch MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare