elasticsearch-mcp
Supports Elastic Cloud deployments with native cloud ID and API key authentication for connecting to Elasticsearch.
Provides tools for searching, indexing, inserting, updating, deleting documents, and exporting data to CSV from an Elasticsearch cluster.
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., "@elasticsearch-mcplist all indices"
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.
Elasticsearch MCP
Model Context Protocol server for Elasticsearch integration with comprehensive security and performance features
elasticsearch-mcp is a Model Context Protocol (MCP) server that provides standardized, secure tools for interacting with Elasticsearch clusters. Built with TypeScript and optimized for Elastic Cloud environments, it offers comprehensive data management capabilities with enterprise-grade security features.
π Features
π Secure by Design: Input validation, script sanitization, injection prevention
βοΈ Elastic Cloud Ready: Native support for cloud ID and API key authentication
β‘ High Performance: Streaming for large datasets, connection pooling, health monitoring
π οΈ Comprehensive Tools: 7 essential tools covering all major Elasticsearch operations
π Advanced Querying: Full Elasticsearch DSL support with aggregations and highlighting
π Data Export: Stream large datasets to CSV with compression support
π Smart Validation: Zod-based schemas with security-first validation
π Full TypeScript: Complete type safety with strict null checks
Related MCP server: Elasticsearch MCP Server
π¦ Installation
npm install elasticsearch-mcpπββοΈ Quick Start
1. Basic Setup
# Set your Elasticsearch credentials
export ELASTIC_CLOUD_ID="your-cloud-id"
export ELASTIC_API_KEY="your-api-key"
# Start the MCP server
npx elasticsearch-mcp2. Using with Claude Desktop
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"elasticsearch-mcp": {
"command": "npx",
"args": ["elasticsearch-mcp"],
"env": {
"ELASTIC_CLOUD_ID": "your-cloud-id",
"ELASTIC_API_KEY": "your-api-key"
}
}
}
}3. Using with any MCP Client
import { ElasticMCPServer } from 'elasticsearch-mcp';
const server = new ElasticMCPServer();
await server.start();π οΈ Available Tools
Tool | Description | Use Cases |
| List and filter Elasticsearch indices | Index management, monitoring |
| Advanced search with aggregations | Data analysis, querying |
| Create indices with mappings/settings | Schema management |
| Insert documents with validation | Data ingestion |
| Update documents with scripts | Data modification |
| Delete by ID or query | Data cleanup |
| Stream data to CSV files | Reporting, data export |
π Tool Examples
Search with Aggregations
{
"tool": "search_elasticsearch",
"arguments": {
"index": "sales-data",
"query": {
"range": {
"date": {
"gte": "2024-01-01",
"lte": "2024-12-31"
}
}
},
"aggregations": {
"monthly_sales": {
"date_histogram": {
"field": "date",
"calendar_interval": "month"
},
"aggs": {
"total_revenue": {
"sum": { "field": "amount" }
}
}
}
}
}
}Export Large Dataset
{
"tool": "export_to_csv",
"arguments": {
"index": "user-analytics",
"query": {
"bool": {
"filter": [
{ "term": { "status": "active" } },
{ "range": { "last_login": { "gte": "2024-01-01" } } }
]
}
},
"fields": ["user_id", "email", "last_login", "country"],
"filename": "active_users_2024.csv",
"compress": true,
"maxRows": 100000
}
}Create Index with Schema
{
"tool": "create_index",
"arguments": {
"name": "product-catalog",
"mappings": {
"properties": {
"name": { "type": "text", "analyzer": "standard" },
"price": { "type": "float" },
"category": { "type": "keyword" },
"created_at": { "type": "date" },
"tags": { "type": "keyword" },
"description": { "type": "text" }
}
},
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"product_analyzer": {
"type": "standard",
"stopwords": "_english_"
}
}
}
},
"aliases": ["products", "catalog"]
}
}βοΈ Configuration
Environment Variables
Variable | Description | Required | Example |
| Elastic Cloud deployment ID | Yes* |
|
| Elasticsearch API key | Yes* |
|
| Self-hosted Elasticsearch URL | Yes* |
|
| Basic auth username | No |
|
| Basic auth password | No |
|
| Logging level | No |
|
| Log output format | No |
|
| Request concurrency limit | No |
|
*Either ELASTIC_CLOUD_ID or ELASTIC_NODE is required
Configuration File
Create .env file:
# Elastic Cloud (recommended)
ELASTIC_CLOUD_ID=your-deployment-id
ELASTIC_API_KEY=your-api-key
# Logging
LOG_LEVEL=info
LOG_FORMAT=json
# Performance
MAX_CONCURRENT_REQUESTS=10
REQUEST_TIMEOUT_MS=30000π Security Features
Input Validation
Zod Schemas: Strict type validation for all inputs
Field Name Validation: Prevents reserved field usage
Size Limits: Document size, array length, string length limits
Depth Validation: Prevents deeply nested objects/queries
Script Security
Script Sanitization: Blocks dangerous script patterns
Parameter Validation: Validates script parameters
Execution Limits: Prevents resource exhaustion
Query Security
Injection Prevention: Sanitizes and validates all queries
Script Query Blocking: Prevents script-based queries in sensitive operations
Rate Limiting: Protects against abuse
Data Protection
Credential Masking: Never logs sensitive information
Secure Connections: TLS/SSL support
Access Control: Validates permissions before operations
ποΈ Architecture
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β MCP Client βββββΊβElasticsearch MCPβββββΊβ Elasticsearch β
β (Claude, etc.) β β Server β β Cluster β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββ
β Tools β
β β
β β’ fetch β
β β’ search β
β β’ create β
β β’ insert β
β β’ update β
β β’ delete β
β β’ export β
βββββββββββββββπ Performance
Benchmarks
Search: <500ms average response time
Large Exports: 10K+ documents/second with streaming
Memory Usage: <100MB for typical operations
Concurrent Requests: Up to 10 simultaneous operations
Optimization Features
Connection Pooling: Reuses Elasticsearch connections
Streaming: Memory-efficient processing of large datasets
Compression: Reduces export file sizes by 70%+
Health Monitoring: Automatic reconnection on failures
π§ Development
Setup Development Environment
# Clone repository
git clone https://github.com/RajwardhanShinde/elk-mcp.git
cd elk-mcp
# Install dependencies
npm install
# Set up environment
cp .env.example .env
# Edit .env with your Elasticsearch credentials
# Run in development mode
npm run dev
# Run tests
npm test
# Build for production
npm run buildProject Structure
elasticsearch-mcp/
βββ src/
β βββ tools/ # MCP tool implementations
β βββ elasticsearch/ # ES client and connection management
β βββ validation/ # Input validation schemas
β βββ errors/ # Error handling utilities
β βββ config.ts # Configuration management
β βββ logger.ts # Structured logging
β βββ server.ts # Main MCP server
βββ tests/ # Comprehensive test suite
βββ docs/ # Documentation
βββ build/ # Compiled outputπ€ Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Workflow
Fork the repository
Create a feature branch
Make your changes with tests
Ensure all tests pass
Submit a pull request
π Documentation
π Troubleshooting
Common Issues
Connection Failed
# Check credentials
echo $ELASTIC_CLOUD_ID
echo $ELASTIC_API_KEY
# Test connection
curl -H "Authorization: ApiKey $ELASTIC_API_KEY" \\
"$ELASTIC_NODE/_cluster/health"Permission Denied
Ensure API key has required privileges
Check index permissions
Verify cluster access
Tool Validation Errors
Check input parameter types
Validate required fields
Review field name restrictions
See Troubleshooting Guide for more details.
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π·οΈ Version History
v0.1.0 - Initial release with 7 core tools
Full changelog: CHANGELOG.md
π Links
Built with β€οΈ for the Elasticsearch and MCP communities
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/RajwardhanShinde/elasticsearch-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server