# Elasticsearch MCP Server
A Model Context Protocol (MCP) server for Elasticsearch, providing core Elasticsearch functionality through MCP tools.
## Features
- **Search Operations**: Perform full-text search, term queries, and complex aggregations
- **Index Management**: Create, delete, and manage Elasticsearch indices
- **Document Operations**: Index, update, delete, and retrieve documents
- **Cluster Information**: Get cluster health, stats, and node information
- **Mapping Management**: Create and manage index mappings
- **Template Management**: Manage index templates and component templates
## Installation
### From PyPI
```bash
pip install mcp-server-elasticsearch
```
### From Source
```bash
git clone https://github.com/your-username/mcp-server-elasticsearch.git
cd mcp-server-elasticsearch
pip install -e .
```
## Configuration
Create a configuration file (e.g., `elastic-mcp.json5`) with your Elasticsearch connection details:
```json5
{
"elasticsearch": {
"hosts": ["http://localhost:9200"],
"username": "your_username", // optional
"password": "your_password", // optional
"api_key": "your_api_key", // optional, alternative to username/password
"verify_certs": true,
"ca_certs": "/path/to/ca.pem", // optional
"timeout": 30
},
"server": {
"host": "localhost",
"port": 8000,
"log_level": "INFO"
}
}
```
## Usage
### As a Standalone Server
```bash
# Using configuration file
elasticsearch-mcp-server --config elastic-mcp.json5
# Using environment variables
export ELASTICSEARCH_HOSTS=http://localhost:9200
export ELASTICSEARCH_USERNAME=your_username
export ELASTICSEARCH_PASSWORD=your_password
elasticsearch-mcp-server
```
### As a Python Module
```python
from elasticsearch_mcp_server import ElasticsearchMCPServer, ElasticsearchConfig
# Load configuration
config = ElasticsearchConfig.from_file("elastic-mcp.json5")
# Create and run server
server = ElasticsearchMCPServer(config)
await server.run_stdio()
```
### Environment Variables
You can configure the server using environment variables:
- `ELASTICSEARCH_HOSTS`: Comma-separated list of Elasticsearch hosts
- `ELASTICSEARCH_USERNAME`: Username for authentication
- `ELASTICSEARCH_PASSWORD`: Password for authentication
- `ELASTICSEARCH_API_KEY`: API key for authentication (alternative to username/password)
- `ELASTICSEARCH_VERIFY_CERTS`: Whether to verify SSL certificates (default: true)
- `ELASTICSEARCH_CA_CERTS`: Path to CA certificate file
- `ELASTICSEARCH_TIMEOUT`: Request timeout in seconds (default: 30)
## Available Tools
The server provides the following MCP tools:
### Search Operations
- `search`: Perform search queries with various parameters
- `msearch`: Execute multiple search requests
- `count`: Count documents matching a query
### Document Operations
- `index_document`: Index a single document
- `get_document`: Retrieve a document by ID
- `update_document`: Update a document
- `delete_document`: Delete a document
- `bulk_operations`: Perform bulk operations
### Index Management
- `create_index`: Create a new index
- `delete_index`: Delete an index
- `get_index_info`: Get index information
- `list_indices`: List all indices
### Mapping Management
- `put_mapping`: Create or update index mapping
- `get_mapping`: Retrieve index mapping
### Cluster Operations
- `cluster_health`: Get cluster health status
- `cluster_stats`: Get cluster statistics
- `node_info`: Get node information
## Requirements
- Python 3.12+
- Elasticsearch 8.0+
## Dependencies
- `elasticsearch>=8.0.0,<9.0.0`
- `mcp>=1.0.0`
- `pydantic>=2.0.0`
- `pydantic-settings>=2.0.0`
- `click>=8.0.0`
- `aiohttp>=3.8.0`
- `python-dotenv>=1.0.0`
- `pyjson5>=1.6.0`
- `structlog>=23.0.0`
- `anyio>=4.0.0`
- `uvicorn>=0.24.0`
- `starlette>=0.27.0`
## License
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## Support
If you encounter any issues or have questions, please file an issue on the GitHub repository.
Raw data
{
"_id": null,
"home_page": null,
"name": "sugon-mcp-server-elasticsearch",
"maintainer": "sugoncloud",
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "elasticsearch, mcp, model-context-protocol, search, server",
"author": "sugoncloud",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/5a/0b/831c6d0b23d851fb78a572cc8e00115b1341987cc86982aff77de28cf96e/sugon_mcp_server_elasticsearch-0.1.1.tar.gz",
"platform": null,
"description": "# Elasticsearch MCP Server\n\nA Model Context Protocol (MCP) server for Elasticsearch, providing core Elasticsearch functionality through MCP tools.\n\n## Features\n\n- **Search Operations**: Perform full-text search, term queries, and complex aggregations\n- **Index Management**: Create, delete, and manage Elasticsearch indices\n- **Document Operations**: Index, update, delete, and retrieve documents\n- **Cluster Information**: Get cluster health, stats, and node information\n- **Mapping Management**: Create and manage index mappings\n- **Template Management**: Manage index templates and component templates\n\n## Installation\n\n### From PyPI\n\n```bash\npip install mcp-server-elasticsearch\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/your-username/mcp-server-elasticsearch.git\ncd mcp-server-elasticsearch\npip install -e .\n```\n\n## Configuration\n\nCreate a configuration file (e.g., `elastic-mcp.json5`) with your Elasticsearch connection details:\n\n```json5\n{\n \"elasticsearch\": {\n \"hosts\": [\"http://localhost:9200\"],\n \"username\": \"your_username\", // optional\n \"password\": \"your_password\", // optional\n \"api_key\": \"your_api_key\", // optional, alternative to username/password\n \"verify_certs\": true,\n \"ca_certs\": \"/path/to/ca.pem\", // optional\n \"timeout\": 30\n },\n \"server\": {\n \"host\": \"localhost\",\n \"port\": 8000,\n \"log_level\": \"INFO\"\n }\n}\n```\n\n## Usage\n\n### As a Standalone Server\n\n```bash\n# Using configuration file\nelasticsearch-mcp-server --config elastic-mcp.json5\n\n# Using environment variables\nexport ELASTICSEARCH_HOSTS=http://localhost:9200\nexport ELASTICSEARCH_USERNAME=your_username\nexport ELASTICSEARCH_PASSWORD=your_password\nelasticsearch-mcp-server\n```\n\n### As a Python Module\n\n```python\nfrom elasticsearch_mcp_server import ElasticsearchMCPServer, ElasticsearchConfig\n\n# Load configuration\nconfig = ElasticsearchConfig.from_file(\"elastic-mcp.json5\")\n\n# Create and run server\nserver = ElasticsearchMCPServer(config)\nawait server.run_stdio()\n```\n\n### Environment Variables\n\nYou can configure the server using environment variables:\n\n- `ELASTICSEARCH_HOSTS`: Comma-separated list of Elasticsearch hosts\n- `ELASTICSEARCH_USERNAME`: Username for authentication\n- `ELASTICSEARCH_PASSWORD`: Password for authentication\n- `ELASTICSEARCH_API_KEY`: API key for authentication (alternative to username/password)\n- `ELASTICSEARCH_VERIFY_CERTS`: Whether to verify SSL certificates (default: true)\n- `ELASTICSEARCH_CA_CERTS`: Path to CA certificate file\n- `ELASTICSEARCH_TIMEOUT`: Request timeout in seconds (default: 30)\n\n## Available Tools\n\nThe server provides the following MCP tools:\n\n### Search Operations\n- `search`: Perform search queries with various parameters\n- `msearch`: Execute multiple search requests\n- `count`: Count documents matching a query\n\n### Document Operations\n- `index_document`: Index a single document\n- `get_document`: Retrieve a document by ID\n- `update_document`: Update a document\n- `delete_document`: Delete a document\n- `bulk_operations`: Perform bulk operations\n\n### Index Management\n- `create_index`: Create a new index\n- `delete_index`: Delete an index\n- `get_index_info`: Get index information\n- `list_indices`: List all indices\n\n### Mapping Management\n- `put_mapping`: Create or update index mapping\n- `get_mapping`: Retrieve index mapping\n\n### Cluster Operations\n- `cluster_health`: Get cluster health status\n- `cluster_stats`: Get cluster statistics\n- `node_info`: Get node information\n\n## Requirements\n\n- Python 3.12+\n- Elasticsearch 8.0+\n\n## Dependencies\n\n- `elasticsearch>=8.0.0,<9.0.0`\n- `mcp>=1.0.0`\n- `pydantic>=2.0.0`\n- `pydantic-settings>=2.0.0`\n- `click>=8.0.0`\n- `aiohttp>=3.8.0`\n- `python-dotenv>=1.0.0`\n- `pyjson5>=1.6.0`\n- `structlog>=23.0.0`\n- `anyio>=4.0.0`\n- `uvicorn>=0.24.0`\n- `starlette>=0.27.0`\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Support\n\nIf you encounter any issues or have questions, please file an issue on the GitHub repository.",
"bugtrack_url": null,
"license": null,
"summary": "MCP server for core Elasticsearch features",
"version": "0.1.1",
"project_urls": null,
"split_keywords": [
"elasticsearch",
" mcp",
" model-context-protocol",
" search",
" server"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0efa93ae0c77f8a8954294f79c7aac6d87d6387d5472d7d7c96cba97d716df7d",
"md5": "6868dc99df60d9dcd42d3b3846494f92",
"sha256": "0513da718739ecaba8c8cb07f9a8231ff891bd723143f2473a7fba690b2f8d9d"
},
"downloads": -1,
"filename": "sugon_mcp_server_elasticsearch-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6868dc99df60d9dcd42d3b3846494f92",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 18604,
"upload_time": "2025-10-30T04:23:55",
"upload_time_iso_8601": "2025-10-30T04:23:55.392212Z",
"url": "https://files.pythonhosted.org/packages/0e/fa/93ae0c77f8a8954294f79c7aac6d87d6387d5472d7d7c96cba97d716df7d/sugon_mcp_server_elasticsearch-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5a0b831c6d0b23d851fb78a572cc8e00115b1341987cc86982aff77de28cf96e",
"md5": "802b536e0c7d241a4a907d7594ed0e62",
"sha256": "2eec579f236b43eb1d5ea7ef52413d9a012656dea8a7d65537f7e2d7d4f22c86"
},
"downloads": -1,
"filename": "sugon_mcp_server_elasticsearch-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "802b536e0c7d241a4a907d7594ed0e62",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 14961,
"upload_time": "2025-10-30T04:23:56",
"upload_time_iso_8601": "2025-10-30T04:23:56.507235Z",
"url": "https://files.pythonhosted.org/packages/5a/0b/831c6d0b23d851fb78a572cc8e00115b1341987cc86982aff77de28cf96e/sugon_mcp_server_elasticsearch-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-30 04:23:56",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "sugon-mcp-server-elasticsearch"
}