Elasticsearch MCP Server allows you to interact with your Elasticsearch data through natural language conversations using the Model Context Protocol (MCP). This server connects MCP clients like Claude Desktop to your Elasticsearch indices, enabling you to query your data using everyday language.
list_indices
: List all available Elasticsearch indicesget_mappings
: Get field mappings for a specific Elasticsearch indexsearch
: Perform an Elasticsearch search with the provided query DSLget_shards
: Get shard information for all or specific indicesConfigure MCP Client
Edit Config
and add a new MCP Server with the following configuration:{
"mcpServers": {
"elasticsearch-mcp-server": {
"command": "npx",
"args": [
"-y",
"@elastic/mcp-server-elasticsearch"
],
"env": {
"ES_URL": "your-elasticsearch-url",
"ES_API_KEY": "your-api-key"
}
}
}
}
Start a Conversation
The Elasticsearch MCP Server supports the following configuration options:
Environment Variable | Description | Required |
---|---|---|
ES_URL |
Your Elasticsearch instance URL | Yes |
ES_API_KEY |
Elasticsearch API key for authentication | No |
ES_USERNAME |
Elasticsearch username for basic authentication | No |
ES_PASSWORD |
Elasticsearch password for basic authentication | No |
ES_CA_CERT |
Path to custom CA certificate for Elasticsearch SSL/TLS | No |
Note: You must provide either an API key or both username and password for authentication.
Here are some natural language queries you can try with your MCP Client:
It's recommended to create a dedicated Elasticsearch API key with minimal permissions to control access to your data:
POST /_security/api_key
{
"name": "es-mcp-server-access",
"role_descriptors": {
"mcp_server_role": {
"cluster": [
"monitor"
],
"indices": [
{
"names": [
"index-1",
"index-2",
"index-pattern-*"
],
"privileges": [
"read",
"view_index_metadata"
]
}
]
}
}
}
If you encounter issues:
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.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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.
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.