The Octodet Elasticsearch MCP Server enables interaction with Elasticsearch clusters through the Model Context Protocol, supporting a wide range of operations:
- Document Management: Add, update, delete documents individually or in bulk, and perform updates/deletions based on queries
- Search & Querying: Execute advanced searches using Elasticsearch DSL with highlighting support
- Index Management: List, create, and delete indices with custom settings and mappings
- Cluster Operations: Monitor cluster health and shard information
- Metadata: Retrieve field mappings, templates, and aliases
- Utility Functions: Count documents with optional query filtering
The server can be configured using environment variables for customized Elasticsearch connections.
Provides comprehensive tools for interacting with Elasticsearch clusters, including full CRUD operations for documents and indices, bulk operations, query-based updates/deletes, cluster health monitoring, and advanced search with DSL queries and highlighting.
Supports ChatGPT via MCP plugins, allowing it to perform Elasticsearch operations through the standardized Model Context Protocol.
Octodet Elasticsearch MCP Server
A Model Context Protocol (MCP) server for Elasticsearch operations, providing a comprehensive set of tools for interacting with Elasticsearch clusters through the standardized Model Context Protocol. This server enables LLM-powered applications to search, update, and manage Elasticsearch data.
Features
- Complete Elasticsearch Operations: Full CRUD operations for documents and indices
- Bulk Operations: Process multiple operations in a single API call
- Query-Based Updates/Deletes: Modify or remove documents based on queries
- Cluster Management: Monitor health, shards, and templates
- Advanced Search: Full support for Elasticsearch DSL queries with highlighting
Installation
As an NPM Package
Install the package globally:
Or use it directly with npx:
From Source
- Clone this repository
- Install dependencies:
- Build the server:
Integration with MCP Clients
VS Code Integration
Add the following configuration to your VS Code settings.json to integrate with the VS Code MCP extension:
Claude Desktop Integration
Configure in your Claude Desktop configuration file:
For Local Development
If you're developing the MCP server locally, you can configure the clients to use your local build:
Configuration
The server uses the following environment variables for configuration:
Variable | Description | Default |
---|---|---|
ES_URL | Elasticsearch server URL | http://localhost:9200 |
ES_API_KEY | API key for authentication | |
ES_USERNAME | Username for authentication | |
ES_PASSWORD | Password for authentication | |
ES_CA_CERT | Path to custom CA certificate | |
ES_VERSION | Elasticsearch version (8 or 9) | 8 |
ES_SSL_SKIP_VERIFY | Skip SSL verification | false |
ES_PATH_PREFIX | Path prefix for Elasticsearch |
Tools
The server provides 16 MCP tools for Elasticsearch operations. Each tool is documented with its required and optional parameters:
1. List Indices
List all available Elasticsearch indices with detailed information.
Parameters:
indexPattern
(optional, string): Pattern to filter indices (e.g., "logs-", "my-index-")
Example:
2. Get Mappings
Get field mappings for a specific Elasticsearch index.
Parameters:
index
(required, string): The name of the index to get mappings for
Example:
3. Search
Perform an Elasticsearch search with the provided query DSL and highlighting.
Parameters:
index
(required, string): The index or indices to search in (supports comma-separated values)queryBody
(required, object): The Elasticsearch query DSL bodyhighlight
(optional, boolean): Enable search result highlighting (default: true)
Example:
4. Get Cluster Health
Get health information about the Elasticsearch cluster.
Parameters:
- None required
Example:
5. Get Shards
Get shard information for all or specific indices.
Parameters:
index
(optional, string): Specific index to get shard information for. If omitted, returns shards for all indices
Example:
6. Add Document
Add a new document to a specific Elasticsearch index.
Parameters:
index
(required, string): The index to add the document todocument
(required, object): The document content to addid
(optional, string): Document ID. If omitted, Elasticsearch will generate one automatically
Example:
7. Update Document
Update an existing document in a specific Elasticsearch index.
Parameters:
index
(required, string): The index containing the documentid
(required, string): The ID of the document to updatedocument
(required, object): The partial document with fields to update
Example:
8. Delete Document
Delete a document from a specific Elasticsearch index.
Parameters:
index
(required, string): The index containing the documentid
(required, string): The ID of the document to delete
Example:
9. Update By Query
Update documents in an Elasticsearch index based on a query.
Parameters:
index
(required, string): The index to update documents inquery
(required, object): Elasticsearch query to match documents for updatescript
(required, object): Script to execute for updating matched documentsconflicts
(optional, string): How to handle version conflicts ("abort" or "proceed", default: "abort")refresh
(optional, boolean): Whether to refresh the index after the operation (default: false)
Example:
10. Delete By Query
Delete documents in an Elasticsearch index based on a query.
Parameters:
index
(required, string): The index to delete documents fromquery
(required, object): Elasticsearch query to match documents for deletionconflicts
(optional, string): How to handle version conflicts ("abort" or "proceed", default: "abort")refresh
(optional, boolean): Whether to refresh the index after the operation (default: false)
Example:
11. Bulk Operations
Perform multiple document operations in a single API call for better performance.
Parameters:
operations
(required, array): Array of operation objects, each containing:action
(required, string): The operation type ("index", "create", "update", or "delete")index
(required, string): The index for this operationid
(optional, string): Document ID (required for update/delete, optional for index/create)document
(conditional, object): Document content (required for index/create/update operations)
Example:
12. Create Index
Create a new Elasticsearch index with optional settings and mappings.
Parameters:
index
(required, string): The name of the index to createsettings
(optional, object): Index settings like number of shards, replicas, etc.mappings
(optional, object): Field mappings defining how documents should be indexed
Example:
13. Delete Index
Delete an Elasticsearch index permanently.
Parameters:
index
(required, string): The name of the index to delete
Example:
14. Count Documents
Count documents in an index, optionally filtered by a query.
Parameters:
index
(required, string): The index to count documents inquery
(optional, object): Elasticsearch query to filter documents for counting
Example:
15. Get Templates
Get index templates from Elasticsearch.
Parameters:
name
(optional, string): Specific template name to retrieve. If omitted, returns all templates
Example:
16. Get Aliases
Get index aliases from Elasticsearch.
Parameters:
name
(optional, string): Specific alias name to retrieve. If omitted, returns all aliases
Example:
Development
Running in Development Mode
Run the server in watch mode during development:
Protocol Implementation
This server implements the Model Context Protocol to enable standardized communication between LLM clients and Elasticsearch. It provides a set of tools that can be invoked by MCP clients to perform various Elasticsearch operations.
Adding New Tools
To add a new tool to the server:
- Define the tool in
src/index.ts
using the MCP server's tool registration format - Implement the necessary functionality in
src/utils/elasticsearchService.ts
- Update this README to document the new tool
Other MCP Clients
This server can be used with any MCP-compatible client, including:
- OpenAI's ChatGPT via MCP plugins
- Anthropic's Claude Desktop
- Claude in VS Code
- Custom applications using the MCP SDK
Programmatic Usage
You can also use the server programmatically in your Node.js applications:
License
This project is licensed under the MIT License - see the LICENSE file for details.
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
Read/write Elasticsearch mcp server with many tools
Related MCP Servers
- AsecurityAlicenseAqualityProvides an MCP protocol interface for interacting with Elasticsearch 7.x databases, supporting comprehensive search functionality including aggregations, highlighting, and sorting.Last updated -31PythonApache 2.0
- AsecurityAlicenseAqualityAn MCP server that provides tools for reading, writing, and editing files on the local filesystem.Last updated -11,387PythonApache 2.0
- -securityAlicense-qualityMCP Server for executing XPath queries on XML contentLast updated -53JavaScriptMIT License
- -securityAlicense-qualityStores metadata for MCP servers and provides smart search capabilities, allowing users to find appropriate MCP servers for their queries and route requests to the most suitable server.Last updated -9PythonMIT License