sansong089/elasticsearch-mcp-server
If you are the rightful owner of elasticsearch-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Elasticsearch MCP Server is a comprehensive tool for managing and maintaining Elasticsearch clusters, providing a unified interface for various operations.
Elasticsearch MCP Server
A Model Context Protocol (MCP) server that provides comprehensive Elasticsearch maintenance and management capabilities. Supports cluster monitoring, index management, snapshot operations, alias management, and document operations through a unified interface.
|
Features
🔍 Cluster Management
- Health Check: Monitor cluster health status
- Statistics: Get comprehensive cluster statistics
💾 Snapshot Management
- Create Snapshots: Backup indices to snapshot repositories
- Restore Snapshots: Restore indices from backups
- Repository Management: Create and manage snapshot repositories
📊 Index Operations
- Index Listing: List all indices with filtering
- Index Cleanup: Remove old indices based on patterns and age
- Index Optimization: Force merge segments for better performance
- Reindexing: Migrate data between indices with optional filtering
🏷️ Template Management
- Create Templates: Define index templates for new indices
- Template Operations: View, update, and delete templates
🔗 Alias Management
- Alias Operations: Create, view, delete, and switch aliases
- Alias-Based Operations: Perform document operations using aliases
📝 Document Operations
- Query Documents: Search and retrieve documents with flexible queries
- Update Documents: Modify documents using update scripts
- Delete Documents: Remove documents based on queries or IDs
- Alias-Based Document Ops: All document operations support aliases
🚀 Installation & Configuration
📋 System Requirements
- Node.js: 16.0 or higher
- Elasticsearch: 7.x or 8.x
📦 Installation Steps
# Clone the repository
git clone https://github.com/sansong089/elasticsearch-mcp-server.git
cd elasticsearch-mcp-server
# Install dependencies
npm install
# Build the project
npm run build
⚙️ Configuration
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"elasticsearch": {
"command": "node",
"args": ["C:\\path\\to\\your\\elasticsearch-mcp-server\\build\\server\\index.js"],
"env": {
"ES_HOST": "localhost",
"ES_PORT": "9200",
"ES_SCHEME": "http",
"ES_USERNAME": "your_username",
"ES_PASSWORD": "your_password"
}
}
}
}
Cline
Add to your Cline MCP settings:
{
"mcpServers": {
"elasticsearch": {
"command": "node",
"args": ["/path/to/your/elasticsearch-mcp-server/build/server/index.js"],
"env": {
"ES_HOST": "localhost",
"ES_PORT": "9200",
"ES_SCHEME": "http",
"ES_USERNAME": "your_username",
"ES_PASSWORD": "your_password"
}
}
}
}
Note: Replace the path with the actual path to your build/server/index.js file after building the project.
🔧 Available Tools
This project primarily supports Elasticsearch maintenance and management. The server provides the following MCP tools:
Cluster Management
check_cluster_health- Check cluster health statusget_cluster_stats- Get cluster statistics
Snapshot Operations
create_snapshot- Create index snapshotsrestore_snapshot- Restore from snapshotscreate_snapshot_repository- Create snapshot repositories
Index Maintenance
list_indices- List indicescleanup_old_indices- Clean up old indicesoptimize_indices- Optimize indicesreindex_data- Reindex data
Template Management
create_index_template- Create index templatesget_index_template- View templatesdelete_index_template- Delete templateslist_index_templates- List all templates
Alias Management
create_index_alias- Create aliasesget_index_alias- View aliasesdelete_index_alias- Delete aliaseslist_aliases- List all aliasesswitch_index_alias- Switch aliases between indices
Document Operations (Index-based)
query_index_docs- Query documents in indicesupdate_documents- Update documents by querydelete_documents- Delete documents by queryupdate_document_by_id- Update single documentdelete_document_by_id- Delete single document
Document Operations (Alias-based)
query_alias_docs- Query documents via aliasesupdate_alias_docs- Update documents via aliasesdelete_alias_docs- Delete documents via aliasesupdate_alias_doc_by_id- Update document via aliasdelete_alias_doc_by_id- Delete document via alias
Index Information
get_index_mapping- Get index mappingsget_index_stats- Get index statistics
Example Usage
Creating a Snapshot
{
"repository": "my_backup_repo",
"snapshot": "daily_backup_2024",
"indices": "logstash-*"
}
Querying Documents
{
"index": "my_index",
"query": "{\"match\": {\"status\": \"active\"}}",
"size": 50
}
Creating an Alias
{
"alias": "current_data",
"indices": "data-2024-09-*",
"filter": "{\"range\": {\"timestamp\": {\"gte\": \"now-30d\"}}}"
}
⚠️ Important Disclaimer
Critical Warning: Modification and deletion operations must NEVER be authorized for automatic execution by AI assistants
Please read the following terms carefully:
-
Usage Restrictions
- This software is for learning, development, and testing purposes only
- Do not use in unauthorized production environments
-
Risk Warnings
- Users must bear all consequences of operations themselves
- Including but not limited to data loss, service interruption, etc.
-
Security Warnings
- Modification and deletion operations must NEVER be authorized for automatic execution by AI assistants
- All destructive operations must go through manual confirmation and review
- Operations with Confluence administrative privileges may cause serious security risks
- Please run in secure and controllable environments
-
Disclaimer
- This project is provided "as is" without any express or implied warranties
- The author is not responsible for any damages caused by using this software
Please ensure you understand and accept the above terms before use.