mcp server elasticsearch
Connects Claude and other MCP clients to Elasticsearch data, allowing users to interact with their Elasticsearch indices through natural language conversations.
Connects Claude and other MCP clients to Elasticsearch data, allowing users to interact with their Elasticsearch indices through natural language conversations.
Connect to your Elasticsearch data directly from any MCP Client (like Claude Desktop) using the Model Context Protocol (MCP).
This server connects agents to your Elasticsearch data using the Model Context Protocol. It allows you to interact with your Elasticsearch indices through natural language conversations.
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 indiceshttps://github.com/user-attachments/assets/5dd292e1-a728-4ca7-8f01-1380d1bebe0c
[!TIP] The easiest way to use Elasticsearch MCP Server is through the published npm package.
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"
}
}
}
}
The Elasticsearch MCP Server supports configuration options to connect to your Elasticsearch:
[!NOTE] You must provide either an API key or both username and password for authentication.
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] If you want to modify or extend the MCP Server, follow these local development steps.
Use the correct Node.js version
nvm use
Install Dependencies
npm install
Build the Project
npm run build
Run locally in Claude Desktop App
Edit Config
and add a new MCP Server with the following configuration:{
"mcpServers": {
"elasticsearch-mcp-server-local": {
"command": "node",
"args": [
"/path/to/your/project/dist/index.js"
],
"env": {
"ES_URL": "your-elasticsearch-url",
"ES_API_KEY": "your-api-key"
}
}
}
}
ES_URL=your-elasticsearch-url ES_API_KEY=your-api-key npm run inspector
This will start the MCP Inspector, allowing you to debug and analyze requests. You should see:
Starting MCP inspector...
Proxy server listening on port 3000
? MCP Inspector is up and running at http://localhost:5173 ?
We welcome contributions from the community! For details on how to contribute, please see Contributing Guidelines.
[!TIP] Here are some natural language queries you can try with your MCP Client.
[!WARNING] Avoid using cluster-admin privileges. Create dedicated API keys with limited scope and apply fine-grained access control at the index level to prevent unauthorized data access.
You can 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"
]
}
]
}
}
}
This project is licensed under the Apache License 2.0.
If you encounter issues, feel free to open an issue on the GitHub repository.
[
{
"description": "List all available Elasticsearch indices",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
},
"name": "list_indices"
},
{
"description": "Get field mappings for a specific Elasticsearch index",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"index": {
"description": "Name of the Elasticsearch index to get mappings for",
"minLength": 1,
"type": "string"
}
},
"required": [
"index"
],
"type": "object"
},
"name": "get_mappings"
},
{
"description": "Perform an Elasticsearch search with the provided query DSL. Highlights are always enabled.",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"index": {
"description": "Name of the Elasticsearch index to search",
"minLength": 1,
"type": "string"
},
"queryBody": {
"additionalProperties": {},
"description": "Complete Elasticsearch query DSL object that can include query, size, from, sort, etc.",
"type": "object"
}
},
"required": [
"index",
"queryBody"
],
"type": "object"
},
"name": "search"
}
]