Provides tools for interacting with Elasticsearch clusters, enabling users to list indices, perform data searches using the full Query DSL, retrieve field mappings, and monitor cluster shard information.
Provides tools for interacting with Elasticsearch clusters, enabling users to list indices, perform data searches using the full Query DSL, retrieve field mappings, and monitor cluster shard information.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Custom Elasticsearch MCP Serversearch for recent 'critical' errors in the production-logs index"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 supportget_mappings- Get field mappings for any indexget_shards- View cluster shard information
Quick Start
Build from Source
2. Add to Cursor MCP Configuration
Add this to your .cursor/mcp.json file:
Configuration:
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:
For high-traffic environments:
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 | Only needs |
list_indices | Requires | 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:
Testing Concurrent Requests:
Files
simple_elasticsearch_mcp.py- Main MCP serverDockerfile- Container build instructionsrequirements.txt- Python dependencies
Manual Testing
Test the server directly:
Test with JSON-RPC commands:
1. List all tools:
2. List all indices:
3. Search for data:
4. Get index mappings:
5. Check cluster shards:
Set custom Elasticsearch URL:
Troubleshooting
❌ "Connection refused" or "timed out" errors
Root Cause: The most common issue is Docker container networking when Elasticsearch is accessible via SSH tunnel.
Solution: Ensure these requirements are met:
1. SSH Tunnel Must Be Active
If your Elasticsearch is behind SSH tunnel (common for cloud deployments):
2. Correct Docker Configuration
Your mcp.json should use exactly this configuration:
Key Points:
✅ Use
--add-host=host.docker.internal:host-gateway(not IP addresses)✅ Use
ES_URL=http://host.docker.internal:9400(not localhost)✅ SSH tunnel must be running before starting Cursor
3. Test Docker Connectivity
4. Complete MCP Docker Test
Test the full MCP workflow with this comprehensive command:
Expected Output:
Initialization response with server info
List of all Elasticsearch indices in JSON format
No error messages
5. Alternative: Network Host Mode
If host-gateway doesn't work, try network host mode:
❌ "Received request before initialization was complete"
Root Cause: MCP protocol requires proper initialization sequence.
Solution: Always initialize before calling tools:
That's It!
Build → Add to config → Restart Cursor → Done! 🚀