elasticsearch-mcp-server 1.0.0__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of elasticsearch-mcp-server might be problematic. Click here for more details.
- elasticsearch_mcp_server-2.0.0/.env.example +9 -0
- elasticsearch_mcp_server-2.0.0/.github/workflows/pypi-publish.yaml +51 -0
- elasticsearch_mcp_server-2.0.0/.gitignore +12 -0
- elasticsearch_mcp_server-2.0.0/Dockerfile +30 -0
- {elasticsearch_mcp_server-1.0.0 → elasticsearch_mcp_server-2.0.0}/PKG-INFO +105 -29
- elasticsearch_mcp_server-2.0.0/README.md +178 -0
- {elasticsearch_mcp_server-1.0.0 → elasticsearch_mcp_server-2.0.0}/cliff.toml +1 -1
- elasticsearch_mcp_server-1.0.0/docker-compose.yml → elasticsearch_mcp_server-2.0.0/docker-compose-elasticsearch.yml +4 -4
- elasticsearch_mcp_server-2.0.0/docker-compose-opensearch.yml +71 -0
- elasticsearch_mcp_server-2.0.0/mcp_client/.gitignore +1 -0
- elasticsearch_mcp_server-2.0.0/mcp_client/__init__.py +0 -0
- elasticsearch_mcp_server-2.0.0/mcp_client/client.py +158 -0
- elasticsearch_mcp_server-2.0.0/mcp_client/config.py +62 -0
- elasticsearch_mcp_server-2.0.0/pyproject.toml +34 -0
- elasticsearch_mcp_server-2.0.0/smithery.yaml +25 -0
- elasticsearch_mcp_server-2.0.0/src/__init__.py +6 -0
- elasticsearch_mcp_server-2.0.0/src/clients/__init__.py +42 -0
- elasticsearch_mcp_server-2.0.0/src/clients/base.py +54 -0
- elasticsearch_mcp_server-2.0.0/src/clients/common/__init__.py +6 -0
- elasticsearch_mcp_server-2.0.0/src/clients/common/alias.py +20 -0
- elasticsearch_mcp_server-2.0.0/src/clients/common/client.py +25 -0
- elasticsearch_mcp_server-2.0.0/src/clients/common/cluster.py +12 -0
- elasticsearch_mcp_server-2.0.0/src/clients/common/document.py +37 -0
- elasticsearch_mcp_server-2.0.0/src/clients/common/index.py +20 -0
- elasticsearch_mcp_server-2.0.0/src/clients/exceptions.py +69 -0
- elasticsearch_mcp_server-2.0.0/src/server.py +71 -0
- elasticsearch_mcp_server-2.0.0/src/tools/__init__.py +13 -0
- elasticsearch_mcp_server-2.0.0/src/tools/alias.py +46 -0
- elasticsearch_mcp_server-2.0.0/src/tools/cluster.py +17 -0
- elasticsearch_mcp_server-2.0.0/src/tools/document.py +64 -0
- elasticsearch_mcp_server-2.0.0/src/tools/index.py +44 -0
- elasticsearch_mcp_server-2.0.0/src/tools/register.py +41 -0
- elasticsearch_mcp_server-2.0.0/uv.lock +734 -0
- elasticsearch_mcp_server-1.0.0/.env +0 -4
- elasticsearch_mcp_server-1.0.0/.github/workflows/pypi-publish.yaml +0 -41
- elasticsearch_mcp_server-1.0.0/.gitignore +0 -6
- elasticsearch_mcp_server-1.0.0/README.md +0 -106
- elasticsearch_mcp_server-1.0.0/pyproject.toml +0 -24
- elasticsearch_mcp_server-1.0.0/src/elasticsearch_mcp_server/__init__.py +0 -10
- elasticsearch_mcp_server-1.0.0/src/elasticsearch_mcp_server/es_client.py +0 -40
- elasticsearch_mcp_server-1.0.0/src/elasticsearch_mcp_server/server.py +0 -41
- elasticsearch_mcp_server-1.0.0/src/elasticsearch_mcp_server/tools/cluster.py +0 -38
- elasticsearch_mcp_server-1.0.0/src/elasticsearch_mcp_server/tools/document.py +0 -25
- elasticsearch_mcp_server-1.0.0/src/elasticsearch_mcp_server/tools/index.py +0 -51
- elasticsearch_mcp_server-1.0.0/uv.lock +0 -445
- {elasticsearch_mcp_server-1.0.0 → elasticsearch_mcp_server-2.0.0}/.github/workflows/release.yml +0 -0
- {elasticsearch_mcp_server-1.0.0 → elasticsearch_mcp_server-2.0.0}/.python-version +0 -0
- {elasticsearch_mcp_server-1.0.0 → elasticsearch_mcp_server-2.0.0}/LICENSE +0 -0
- {elasticsearch_mcp_server-1.0.0 → elasticsearch_mcp_server-2.0.0}/Makefile +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Elasticsearch connection settings
|
|
2
|
+
ELASTICSEARCH_HOSTS=https://localhost:9200
|
|
3
|
+
ELASTICSEARCH_USERNAME=elastic
|
|
4
|
+
ELASTICSEARCH_PASSWORD=test123
|
|
5
|
+
|
|
6
|
+
# OpenSearch connection settings
|
|
7
|
+
OPENSEARCH_HOSTS=https://localhost:9200
|
|
8
|
+
OPENSEARCH_USERNAME=admin
|
|
9
|
+
OPENSEARCH_PASSWORD=admin
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# This workflow will upload Python Packages using uv when a release is created
|
|
2
|
+
# It builds and publishes two separate packages: elasticsearch-mcp-server and opensearch-mcp-server
|
|
3
|
+
|
|
4
|
+
name: PyPI Publish
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
workflow_run:
|
|
8
|
+
workflows: ["Release"]
|
|
9
|
+
types:
|
|
10
|
+
- completed
|
|
11
|
+
|
|
12
|
+
env:
|
|
13
|
+
UV_PUBLISH_TOKEN: '${{ secrets.PYPI_API_TOKEN }}'
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
deploy:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v2
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v2
|
|
24
|
+
with:
|
|
25
|
+
python-version: '3.10.x'
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: |
|
|
29
|
+
python -m pip install uv
|
|
30
|
+
uv sync
|
|
31
|
+
|
|
32
|
+
# First build and publish elasticsearch-mcp-server
|
|
33
|
+
- name: Build elasticsearch-mcp-server package
|
|
34
|
+
run: uv build
|
|
35
|
+
|
|
36
|
+
- name: Publish elasticsearch-mcp-server package
|
|
37
|
+
run: uv publish
|
|
38
|
+
|
|
39
|
+
# Clean up dist directory
|
|
40
|
+
- name: Clean dist directory
|
|
41
|
+
run: rm -rf dist/*
|
|
42
|
+
|
|
43
|
+
# Then build and publish opensearch-mcp-server
|
|
44
|
+
- name: Build opensearch-mcp-server package
|
|
45
|
+
run: |
|
|
46
|
+
# Change package name to opensearch-mcp-server
|
|
47
|
+
sed -i 's/^name = .*$/name = "opensearch-mcp-server"/' pyproject.toml
|
|
48
|
+
uv build
|
|
49
|
+
|
|
50
|
+
- name: Publish opensearch-mcp-server package
|
|
51
|
+
run: uv publish
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile
|
|
2
|
+
# Start with a Python base image
|
|
3
|
+
FROM python:3.10-slim
|
|
4
|
+
|
|
5
|
+
# Set working directory
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
|
|
8
|
+
# Copy necessary files
|
|
9
|
+
COPY . .
|
|
10
|
+
|
|
11
|
+
# Install hatch to handle the build
|
|
12
|
+
RUN pip install hatch
|
|
13
|
+
|
|
14
|
+
# Clean dist directory before build
|
|
15
|
+
RUN rm -rf dist/*
|
|
16
|
+
|
|
17
|
+
# Use hatch to build the package and install it
|
|
18
|
+
RUN hatch build && pip install dist/*.whl
|
|
19
|
+
|
|
20
|
+
# Set environment variables required for the MCP server
|
|
21
|
+
# These can be overridden at runtime with docker run --env
|
|
22
|
+
ENV ELASTICSEARCH_HOST="https://localhost:9200"
|
|
23
|
+
ENV ELASTICSEARCH_USERNAME="elastic"
|
|
24
|
+
ENV ELASTICSEARCH_PASSWORD="test123"
|
|
25
|
+
|
|
26
|
+
# Expose the port the server is running on (if applicable)
|
|
27
|
+
EXPOSE 8000
|
|
28
|
+
|
|
29
|
+
# Command to run the server
|
|
30
|
+
ENTRYPOINT ["elasticsearch-mcp-server"]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: elasticsearch-mcp-server
|
|
3
|
-
Version:
|
|
4
|
-
Summary: MCP Server for interacting with Elasticsearch
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: MCP Server for interacting with Elasticsearch and OpenSearch
|
|
5
5
|
License: Apache License
|
|
6
6
|
Version 2.0, January 2004
|
|
7
7
|
http://www.apache.org/licenses/
|
|
@@ -205,17 +205,23 @@ License: Apache License
|
|
|
205
205
|
limitations under the License.
|
|
206
206
|
License-File: LICENSE
|
|
207
207
|
Requires-Python: >=3.10
|
|
208
|
+
Requires-Dist: anthropic>=0.49.0
|
|
208
209
|
Requires-Dist: elasticsearch>=8.0.0
|
|
209
210
|
Requires-Dist: fastmcp>=0.4.0
|
|
210
211
|
Requires-Dist: mcp>=1.0.0
|
|
212
|
+
Requires-Dist: opensearch-py>=2.0.0
|
|
211
213
|
Requires-Dist: python-dotenv>=1.0.0
|
|
214
|
+
Requires-Dist: tomli-w>=1.2.0
|
|
215
|
+
Requires-Dist: tomli>=2.2.1
|
|
212
216
|
Description-Content-Type: text/markdown
|
|
213
217
|
|
|
214
|
-
# Elasticsearch MCP Server
|
|
218
|
+
# Elasticsearch/OpenSearch MCP Server
|
|
219
|
+
|
|
220
|
+
[](https://smithery.ai/server/elasticsearch-mcp-server)
|
|
215
221
|
|
|
216
222
|
## Overview
|
|
217
223
|
|
|
218
|
-
A Model Context Protocol (MCP) server implementation that provides Elasticsearch interaction. This server enables searching documents, analyzing indices, and managing cluster through a set of tools.
|
|
224
|
+
A Model Context Protocol (MCP) server implementation that provides Elasticsearch and OpenSearch interaction. This server enables searching documents, analyzing indices, and managing cluster through a set of tools.
|
|
219
225
|
|
|
220
226
|
<a href="https://glama.ai/mcp/servers/b3po3delex"><img width="380" height="200" src="https://glama.ai/mcp/servers/b3po3delex/badge" alt="Elasticsearch MCP Server" /></a>
|
|
221
227
|
|
|
@@ -227,41 +233,67 @@ https://github.com/user-attachments/assets/f7409e31-fac4-4321-9c94-b0ff2ea7ff15
|
|
|
227
233
|
|
|
228
234
|
### Index Operations
|
|
229
235
|
|
|
230
|
-
- `list_indices`: List all indices
|
|
231
|
-
- `
|
|
232
|
-
- `
|
|
236
|
+
- `list_indices`: List all indices.
|
|
237
|
+
- `get_index`: Returns information (mappings, settings, aliases) about one or more indices.
|
|
238
|
+
- `create_index`: Create a new index.
|
|
239
|
+
- `delete_index`: Delete an index.
|
|
233
240
|
|
|
234
241
|
### Document Operations
|
|
235
242
|
|
|
236
|
-
- `search_documents`: Search documents
|
|
243
|
+
- `search_documents`: Search for documents.
|
|
244
|
+
- `index_document`: Creates or updates a document in the index.
|
|
245
|
+
- `get_document`: Get a document by ID.
|
|
246
|
+
- `delete_document`: Delete a document by ID.
|
|
247
|
+
- `delete_by_query`: Deletes documents matching the provided query.
|
|
237
248
|
|
|
238
249
|
### Cluster Operations
|
|
239
250
|
|
|
240
|
-
- `get_cluster_health`:
|
|
241
|
-
- `get_cluster_stats`:
|
|
251
|
+
- `get_cluster_health`: Returns basic information about the health of the cluster.
|
|
252
|
+
- `get_cluster_stats`: Returns high-level overview of cluster statistics.
|
|
253
|
+
|
|
254
|
+
### Alias Operations
|
|
255
|
+
|
|
256
|
+
- `list_aliases`: List all aliases.
|
|
257
|
+
- `get_alias`: Get alias information for a specific index.
|
|
258
|
+
- `put_alias`: Create or update an alias for a specific index.
|
|
259
|
+
- `delete_alias`: Delete an alias for a specific index.
|
|
242
260
|
|
|
261
|
+
## Configure Environment Variables
|
|
243
262
|
|
|
244
|
-
|
|
263
|
+
Copy the `.env.example` file to `.env` and update the values accordingly.
|
|
245
264
|
|
|
246
|
-
Start
|
|
265
|
+
## Start Elasticsearch/OpenSearch Cluster
|
|
266
|
+
|
|
267
|
+
Start the Elasticsearch/OpenSearch cluster using Docker Compose:
|
|
247
268
|
|
|
248
269
|
```bash
|
|
249
|
-
|
|
270
|
+
# For Elasticsearch
|
|
271
|
+
docker-compose -f docker-compose-elasticsearch.yml up -d
|
|
272
|
+
|
|
273
|
+
# For OpenSearch
|
|
274
|
+
docker-compose -f docker-compose-opensearch.yml up -d
|
|
250
275
|
```
|
|
251
276
|
|
|
252
|
-
|
|
277
|
+
The default Elasticsearch username is `elastic` and password is `test123`. The default OpenSearch username is `admin` and password is `admin`.
|
|
253
278
|
|
|
254
|
-
You can access Kibana from http://localhost:5601.
|
|
279
|
+
You can access Kibana/OpenSearch Dashboards from http://localhost:5601.
|
|
255
280
|
|
|
256
281
|
## Usage with Claude Desktop
|
|
257
282
|
|
|
258
|
-
|
|
283
|
+
### Option 1: Installing via Smithery
|
|
259
284
|
|
|
260
|
-
|
|
285
|
+
To install Elasticsearch Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/elasticsearch-mcp-server):
|
|
261
286
|
|
|
262
|
-
|
|
287
|
+
```bash
|
|
288
|
+
npx -y @smithery/cli install elasticsearch-mcp-server --client claude
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Option 2: Using uvx
|
|
292
|
+
|
|
293
|
+
Using `uvx` will automatically install the package from PyPI, no need to clone the repository locally. Add the following configuration to Claude Desktop's config file `claude_desktop_config.json`.
|
|
263
294
|
|
|
264
295
|
```json
|
|
296
|
+
// For Elasticsearch
|
|
265
297
|
{
|
|
266
298
|
"mcpServers": {
|
|
267
299
|
"elasticsearch-mcp-server": {
|
|
@@ -270,23 +302,41 @@ Using `uvx` will automatically install the package from PyPI, no need to clone t
|
|
|
270
302
|
"elasticsearch-mcp-server"
|
|
271
303
|
],
|
|
272
304
|
"env": {
|
|
273
|
-
"
|
|
274
|
-
"
|
|
275
|
-
"
|
|
305
|
+
"ELASTICSEARCH_HOST": "https://localhost:9200",
|
|
306
|
+
"ELASTICSEARCH_USERNAME": "elastic",
|
|
307
|
+
"ELASTICSEARCH_PASSWORD": "test123"
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// For OpenSearch
|
|
314
|
+
{
|
|
315
|
+
"mcpServers": {
|
|
316
|
+
"opensearch-mcp-server": {
|
|
317
|
+
"command": "uvx",
|
|
318
|
+
"args": [
|
|
319
|
+
"opensearch-mcp-server"
|
|
320
|
+
],
|
|
321
|
+
"env": {
|
|
322
|
+
"OPENSEARCH_HOST": "https://localhost:9200",
|
|
323
|
+
"OPENSEARCH_USERNAME": "admin",
|
|
324
|
+
"OPENSEARCH_PASSWORD": "admin"
|
|
276
325
|
}
|
|
277
326
|
}
|
|
278
327
|
}
|
|
279
328
|
}
|
|
280
329
|
```
|
|
281
330
|
|
|
282
|
-
### Option
|
|
331
|
+
### Option 3: Using uv with local development
|
|
283
332
|
|
|
284
|
-
Using `uv` requires cloning the repository locally and specifying the path to the source code.
|
|
333
|
+
Using `uv` requires cloning the repository locally and specifying the path to the source code. Add the following configuration to Claude Desktop's config file `claude_desktop_config.json`.
|
|
285
334
|
|
|
286
335
|
```json
|
|
336
|
+
// For Elasticsearch
|
|
287
337
|
{
|
|
288
338
|
"mcpServers": {
|
|
289
|
-
"elasticsearch": {
|
|
339
|
+
"elasticsearch-mcp-server": {
|
|
290
340
|
"command": "uv",
|
|
291
341
|
"args": [
|
|
292
342
|
"--directory",
|
|
@@ -295,9 +345,29 @@ Using `uv` requires cloning the repository locally and specifying the path to th
|
|
|
295
345
|
"elasticsearch-mcp-server"
|
|
296
346
|
],
|
|
297
347
|
"env": {
|
|
298
|
-
"
|
|
299
|
-
"
|
|
300
|
-
"
|
|
348
|
+
"ELASTICSEARCH_HOST": "https://localhost:9200",
|
|
349
|
+
"ELASTICSEARCH_USERNAME": "elastic",
|
|
350
|
+
"ELASTICSEARCH_PASSWORD": "test123"
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// For OpenSearch
|
|
357
|
+
{
|
|
358
|
+
"mcpServers": {
|
|
359
|
+
"opensearch-mcp-server": {
|
|
360
|
+
"command": "uv",
|
|
361
|
+
"args": [
|
|
362
|
+
"--directory",
|
|
363
|
+
"path/to/src/elasticsearch_mcp_server",
|
|
364
|
+
"run",
|
|
365
|
+
"opensearch-mcp-server"
|
|
366
|
+
],
|
|
367
|
+
"env": {
|
|
368
|
+
"OPENSEARCH_HOST": "https://localhost:9200",
|
|
369
|
+
"OPENSEARCH_USERNAME": "admin",
|
|
370
|
+
"OPENSEARCH_PASSWORD": "admin"
|
|
301
371
|
}
|
|
302
372
|
}
|
|
303
373
|
}
|
|
@@ -309,11 +379,17 @@ Using `uv` requires cloning the repository locally and specifying the path to th
|
|
|
309
379
|
|
|
310
380
|
Restart Claude Desktop to load the new MCP server.
|
|
311
381
|
|
|
312
|
-
Now you can interact with your Elasticsearch cluster through Claude using natural language commands like:
|
|
382
|
+
Now you can interact with your Elasticsearch/OpenSearch cluster through Claude using natural language commands like:
|
|
313
383
|
- "List all indices in the cluster"
|
|
314
384
|
- "How old is the student Bob?"
|
|
315
385
|
- "Show me the cluster health status"
|
|
316
386
|
|
|
387
|
+
## Usage with Anthropic MCP Client
|
|
388
|
+
|
|
389
|
+
```python
|
|
390
|
+
uv run mcp_client/client.py src/server.py
|
|
391
|
+
```
|
|
392
|
+
|
|
317
393
|
## License
|
|
318
394
|
|
|
319
|
-
This project is licensed under the Apache License Version 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
395
|
+
This project is licensed under the Apache License Version 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Elasticsearch/OpenSearch MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://smithery.ai/server/elasticsearch-mcp-server)
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
A Model Context Protocol (MCP) server implementation that provides Elasticsearch and OpenSearch interaction. This server enables searching documents, analyzing indices, and managing cluster through a set of tools.
|
|
8
|
+
|
|
9
|
+
<a href="https://glama.ai/mcp/servers/b3po3delex"><img width="380" height="200" src="https://glama.ai/mcp/servers/b3po3delex/badge" alt="Elasticsearch MCP Server" /></a>
|
|
10
|
+
|
|
11
|
+
## Demo
|
|
12
|
+
|
|
13
|
+
https://github.com/user-attachments/assets/f7409e31-fac4-4321-9c94-b0ff2ea7ff15
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
### Index Operations
|
|
18
|
+
|
|
19
|
+
- `list_indices`: List all indices.
|
|
20
|
+
- `get_index`: Returns information (mappings, settings, aliases) about one or more indices.
|
|
21
|
+
- `create_index`: Create a new index.
|
|
22
|
+
- `delete_index`: Delete an index.
|
|
23
|
+
|
|
24
|
+
### Document Operations
|
|
25
|
+
|
|
26
|
+
- `search_documents`: Search for documents.
|
|
27
|
+
- `index_document`: Creates or updates a document in the index.
|
|
28
|
+
- `get_document`: Get a document by ID.
|
|
29
|
+
- `delete_document`: Delete a document by ID.
|
|
30
|
+
- `delete_by_query`: Deletes documents matching the provided query.
|
|
31
|
+
|
|
32
|
+
### Cluster Operations
|
|
33
|
+
|
|
34
|
+
- `get_cluster_health`: Returns basic information about the health of the cluster.
|
|
35
|
+
- `get_cluster_stats`: Returns high-level overview of cluster statistics.
|
|
36
|
+
|
|
37
|
+
### Alias Operations
|
|
38
|
+
|
|
39
|
+
- `list_aliases`: List all aliases.
|
|
40
|
+
- `get_alias`: Get alias information for a specific index.
|
|
41
|
+
- `put_alias`: Create or update an alias for a specific index.
|
|
42
|
+
- `delete_alias`: Delete an alias for a specific index.
|
|
43
|
+
|
|
44
|
+
## Configure Environment Variables
|
|
45
|
+
|
|
46
|
+
Copy the `.env.example` file to `.env` and update the values accordingly.
|
|
47
|
+
|
|
48
|
+
## Start Elasticsearch/OpenSearch Cluster
|
|
49
|
+
|
|
50
|
+
Start the Elasticsearch/OpenSearch cluster using Docker Compose:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# For Elasticsearch
|
|
54
|
+
docker-compose -f docker-compose-elasticsearch.yml up -d
|
|
55
|
+
|
|
56
|
+
# For OpenSearch
|
|
57
|
+
docker-compose -f docker-compose-opensearch.yml up -d
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The default Elasticsearch username is `elastic` and password is `test123`. The default OpenSearch username is `admin` and password is `admin`.
|
|
61
|
+
|
|
62
|
+
You can access Kibana/OpenSearch Dashboards from http://localhost:5601.
|
|
63
|
+
|
|
64
|
+
## Usage with Claude Desktop
|
|
65
|
+
|
|
66
|
+
### Option 1: Installing via Smithery
|
|
67
|
+
|
|
68
|
+
To install Elasticsearch Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/elasticsearch-mcp-server):
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npx -y @smithery/cli install elasticsearch-mcp-server --client claude
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Option 2: Using uvx
|
|
75
|
+
|
|
76
|
+
Using `uvx` will automatically install the package from PyPI, no need to clone the repository locally. Add the following configuration to Claude Desktop's config file `claude_desktop_config.json`.
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
// For Elasticsearch
|
|
80
|
+
{
|
|
81
|
+
"mcpServers": {
|
|
82
|
+
"elasticsearch-mcp-server": {
|
|
83
|
+
"command": "uvx",
|
|
84
|
+
"args": [
|
|
85
|
+
"elasticsearch-mcp-server"
|
|
86
|
+
],
|
|
87
|
+
"env": {
|
|
88
|
+
"ELASTICSEARCH_HOST": "https://localhost:9200",
|
|
89
|
+
"ELASTICSEARCH_USERNAME": "elastic",
|
|
90
|
+
"ELASTICSEARCH_PASSWORD": "test123"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// For OpenSearch
|
|
97
|
+
{
|
|
98
|
+
"mcpServers": {
|
|
99
|
+
"opensearch-mcp-server": {
|
|
100
|
+
"command": "uvx",
|
|
101
|
+
"args": [
|
|
102
|
+
"opensearch-mcp-server"
|
|
103
|
+
],
|
|
104
|
+
"env": {
|
|
105
|
+
"OPENSEARCH_HOST": "https://localhost:9200",
|
|
106
|
+
"OPENSEARCH_USERNAME": "admin",
|
|
107
|
+
"OPENSEARCH_PASSWORD": "admin"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Option 3: Using uv with local development
|
|
115
|
+
|
|
116
|
+
Using `uv` requires cloning the repository locally and specifying the path to the source code. Add the following configuration to Claude Desktop's config file `claude_desktop_config.json`.
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
// For Elasticsearch
|
|
120
|
+
{
|
|
121
|
+
"mcpServers": {
|
|
122
|
+
"elasticsearch-mcp-server": {
|
|
123
|
+
"command": "uv",
|
|
124
|
+
"args": [
|
|
125
|
+
"--directory",
|
|
126
|
+
"path/to/src/elasticsearch_mcp_server",
|
|
127
|
+
"run",
|
|
128
|
+
"elasticsearch-mcp-server"
|
|
129
|
+
],
|
|
130
|
+
"env": {
|
|
131
|
+
"ELASTICSEARCH_HOST": "https://localhost:9200",
|
|
132
|
+
"ELASTICSEARCH_USERNAME": "elastic",
|
|
133
|
+
"ELASTICSEARCH_PASSWORD": "test123"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// For OpenSearch
|
|
140
|
+
{
|
|
141
|
+
"mcpServers": {
|
|
142
|
+
"opensearch-mcp-server": {
|
|
143
|
+
"command": "uv",
|
|
144
|
+
"args": [
|
|
145
|
+
"--directory",
|
|
146
|
+
"path/to/src/elasticsearch_mcp_server",
|
|
147
|
+
"run",
|
|
148
|
+
"opensearch-mcp-server"
|
|
149
|
+
],
|
|
150
|
+
"env": {
|
|
151
|
+
"OPENSEARCH_HOST": "https://localhost:9200",
|
|
152
|
+
"OPENSEARCH_USERNAME": "admin",
|
|
153
|
+
"OPENSEARCH_PASSWORD": "admin"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
- On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
161
|
+
- On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
162
|
+
|
|
163
|
+
Restart Claude Desktop to load the new MCP server.
|
|
164
|
+
|
|
165
|
+
Now you can interact with your Elasticsearch/OpenSearch cluster through Claude using natural language commands like:
|
|
166
|
+
- "List all indices in the cluster"
|
|
167
|
+
- "How old is the student Bob?"
|
|
168
|
+
- "Show me the cluster health status"
|
|
169
|
+
|
|
170
|
+
## Usage with Anthropic MCP Client
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
uv run mcp_client/client.py src/server.py
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
This project is licensed under the Apache License Version 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
@@ -6,8 +6,8 @@ services:
|
|
|
6
6
|
user: "0"
|
|
7
7
|
command: >
|
|
8
8
|
bash -c '
|
|
9
|
-
if [ x${
|
|
10
|
-
echo "Set the
|
|
9
|
+
if [ x${ELASTICSEARCH_PASSWORD} == x ]; then
|
|
10
|
+
echo "Set the ELASTICSEARCH_PASSWORD environment variable in the .env file";
|
|
11
11
|
exit 1;
|
|
12
12
|
fi;
|
|
13
13
|
if [ ! -f config/certs/ca.zip ]; then
|
|
@@ -48,7 +48,7 @@ services:
|
|
|
48
48
|
echo "Waiting for Elasticsearch availability";
|
|
49
49
|
until curl -s --cacert config/certs/ca/ca.crt https://es01:9200 | grep -q "missing authentication credentials"; do sleep 30; done;
|
|
50
50
|
echo "Setting kibana_system password";
|
|
51
|
-
until curl -s -X POST --cacert config/certs/ca/ca.crt -u "elastic:${
|
|
51
|
+
until curl -s -X POST --cacert config/certs/ca/ca.crt -u "elastic:${ELASTICSEARCH_PASSWORD}" -H "Content-Type: application/json" https://es01:9200/_security/user/kibana_system/_password -d "{\"password\":\"kibana123\"}" | grep -q "^{}"; do sleep 10; done;
|
|
52
52
|
echo "All done!";
|
|
53
53
|
'
|
|
54
54
|
healthcheck:
|
|
@@ -72,7 +72,7 @@ services:
|
|
|
72
72
|
- cluster.name=es-mcp-cluster
|
|
73
73
|
- cluster.initial_master_nodes=es01,es02,es03
|
|
74
74
|
- discovery.seed_hosts=es02,es03
|
|
75
|
-
- ELASTIC_PASSWORD=${
|
|
75
|
+
- ELASTIC_PASSWORD=${ELASTICSEARCH_PASSWORD}
|
|
76
76
|
- bootstrap.memory_lock=true
|
|
77
77
|
- xpack.security.enabled=true
|
|
78
78
|
- xpack.security.http.ssl.enabled=true
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
services:
|
|
2
|
+
opensearch-node1: # This is also the hostname of the container within the Docker network (i.e. https://opensearch-node1/)
|
|
3
|
+
image: opensearchproject/opensearch:2.11.0
|
|
4
|
+
container_name: opensearch-node1
|
|
5
|
+
environment:
|
|
6
|
+
- cluster.name=opensearch-cluster # Name the cluster
|
|
7
|
+
- node.name=opensearch-node1 # Name the node that will run in this container
|
|
8
|
+
- discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
|
|
9
|
+
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligibile to serve as cluster manager
|
|
10
|
+
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
|
|
11
|
+
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
|
|
12
|
+
- cluster.routing.allocation.disk.watermark.low=2gb
|
|
13
|
+
- cluster.routing.allocation.disk.watermark.high=1gb
|
|
14
|
+
- cluster.routing.allocation.disk.watermark.flood_stage=512mb
|
|
15
|
+
ulimits:
|
|
16
|
+
memlock:
|
|
17
|
+
soft: -1 # Set memlock to unlimited (no soft or hard limit)
|
|
18
|
+
hard: -1
|
|
19
|
+
nofile:
|
|
20
|
+
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
|
|
21
|
+
hard: 65536
|
|
22
|
+
volumes:
|
|
23
|
+
- opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
|
|
24
|
+
ports:
|
|
25
|
+
- 9200:9200 # REST API
|
|
26
|
+
- 9600:9600 # Performance Analyzer
|
|
27
|
+
networks:
|
|
28
|
+
- opensearch-net # All of the containers will join the same Docker bridge network
|
|
29
|
+
opensearch-node2:
|
|
30
|
+
image: opensearchproject/opensearch:2.11.0 # This should be the same image used for opensearch-node1 to avoid issues
|
|
31
|
+
container_name: opensearch-node2
|
|
32
|
+
environment:
|
|
33
|
+
- cluster.name=opensearch-cluster
|
|
34
|
+
- node.name=opensearch-node2
|
|
35
|
+
- discovery.seed_hosts=opensearch-node1,opensearch-node2
|
|
36
|
+
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2
|
|
37
|
+
- bootstrap.memory_lock=true
|
|
38
|
+
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
|
|
39
|
+
- cluster.routing.allocation.disk.watermark.low=2gb
|
|
40
|
+
- cluster.routing.allocation.disk.watermark.high=1gb
|
|
41
|
+
- cluster.routing.allocation.disk.watermark.flood_stage=512mb
|
|
42
|
+
ulimits:
|
|
43
|
+
memlock:
|
|
44
|
+
soft: -1
|
|
45
|
+
hard: -1
|
|
46
|
+
nofile:
|
|
47
|
+
soft: 65536
|
|
48
|
+
hard: 65536
|
|
49
|
+
volumes:
|
|
50
|
+
- opensearch-data2:/usr/share/opensearch/data
|
|
51
|
+
networks:
|
|
52
|
+
- opensearch-net
|
|
53
|
+
opensearch-dashboards:
|
|
54
|
+
image: opensearchproject/opensearch-dashboards:2.11.0 # Make sure the version of opensearch-dashboards matches the version of opensearch installed on other nodes
|
|
55
|
+
container_name: opensearch-dashboards
|
|
56
|
+
ports:
|
|
57
|
+
- 5601:5601 # Map host port 5601 to container port 5601
|
|
58
|
+
expose:
|
|
59
|
+
- "5601" # Expose port 5601 for web access to OpenSearch Dashboards
|
|
60
|
+
environment:
|
|
61
|
+
OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' # Define the OpenSearch nodes that OpenSearch Dashboards will query
|
|
62
|
+
networks:
|
|
63
|
+
- opensearch-net
|
|
64
|
+
|
|
65
|
+
volumes:
|
|
66
|
+
opensearch-data1:
|
|
67
|
+
opensearch-data2:
|
|
68
|
+
|
|
69
|
+
networks:
|
|
70
|
+
opensearch-net:
|
|
71
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.env
|
|
File without changes
|