opensearch-mcp-server 2.0.10__tar.gz → 2.0.12__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.
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/.gitignore +3 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/CONTRIBUTING.md +8 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/PKG-INFO +66 -8
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/README.md +65 -7
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/pyproject.toml +1 -1
- opensearch_mcp_server-2.0.12/server.json +61 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/clients/__init__.py +2 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/clients/base.py +20 -5
- opensearch_mcp_server-2.0.12/src/version.py +1 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/uv.lock +392 -392
- opensearch_mcp_server-2.0.10/Dockerfile +0 -30
- opensearch_mcp_server-2.0.10/src/version.py +0 -1
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/.env.example +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/.github/workflows/pypi-publish.yaml +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/.github/workflows/release.yml +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/.python-version +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/LICENSE +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/Makefile +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/cliff.toml +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/docker-compose-elasticsearch.yml +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/docker-compose-opensearch.yml +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/python-sdk-anthropic/.gitignore +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/python-sdk-anthropic/__init__.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/python-sdk-anthropic/client.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/python-sdk-anthropic/config.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/README.md +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/build.gradle +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/gradle/wrapper/gradle-wrapper.jar +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/gradle/wrapper/gradle-wrapper.properties +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/gradle.properties +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/gradlew +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/gradlew.bat +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/settings.gradle +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/src/main/java/spring/ai/mcp/spring_ai_mcp/Application.java +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/src/main/resources/application.yml +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/src/main/resources/mcp-servers-config.json +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/mcp_client/spring-ai/src/test/java/spring/ai/mcp/spring_ai_mcp/SpringAiMcpApplicationTests.java +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/__init__.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/clients/common/__init__.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/clients/common/alias.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/clients/common/client.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/clients/common/cluster.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/clients/common/document.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/clients/common/general.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/clients/common/index.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/clients/exceptions.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/server.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/tools/__init__.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/tools/alias.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/tools/cluster.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/tools/document.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/tools/general.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/tools/index.py +0 -0
- {opensearch_mcp_server-2.0.10 → opensearch_mcp_server-2.0.12}/src/tools/register.py +0 -0
@@ -73,4 +73,12 @@ If you have already created a branch and want to keep it in sync with the upstre
|
|
73
73
|
git checkout <branch-name>
|
74
74
|
git fetch upstream
|
75
75
|
git rebase upstream/main
|
76
|
+
```
|
77
|
+
|
78
|
+
## Release
|
79
|
+
|
80
|
+
```bash
|
81
|
+
uv sync
|
82
|
+
source .venv/bin/activate
|
83
|
+
make release version=<RELEASE_VERSION>
|
76
84
|
```
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: opensearch-mcp-server
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.12
|
4
4
|
Summary: MCP Server for interacting with Elasticsearch and OpenSearch
|
5
5
|
License: Apache License
|
6
6
|
Version 2.0, January 2004
|
@@ -216,12 +216,14 @@ Requires-Dist: tomli==2.2.1
|
|
216
216
|
Description-Content-Type: text/markdown
|
217
217
|
|
218
218
|
|
219
|
-
|
219
|
+
<!-- mcp-name: io.github.cr7258/elasticsearch-mcp-server -->
|
220
220
|
|
221
|
-
|
221
|
+
# Elasticsearch/OpenSearch MCP Server
|
222
222
|
|
223
223
|
[](https://mseep.ai/app/cr7258-elasticsearch-mcp-server)
|
224
224
|
|
225
|
+
[](https://archestra.ai/mcp-catalog/cr7258__elasticsearch-mcp-server)
|
226
|
+
|
225
227
|
## Overview
|
226
228
|
|
227
229
|
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.
|
@@ -267,7 +269,20 @@ https://github.com/user-attachments/assets/f7409e31-fac4-4321-9c94-b0ff2ea7ff15
|
|
267
269
|
|
268
270
|
## Configure Environment Variables
|
269
271
|
|
270
|
-
|
272
|
+
The MCP server supports the following environment variables for authentication:
|
273
|
+
|
274
|
+
### Basic Authentication (Username/Password)
|
275
|
+
- `ELASTICSEARCH_USERNAME`: Username for basic authentication
|
276
|
+
- `ELASTICSEARCH_PASSWORD`: Password for basic authentication
|
277
|
+
- `OPENSEARCH_USERNAME`: Username for OpenSearch basic authentication
|
278
|
+
- `OPENSEARCH_PASSWORD`: Password for OpenSearch basic authentication
|
279
|
+
|
280
|
+
### API Key Authentication (Elasticsearch only) - Recommended
|
281
|
+
- `ELASTICSEARCH_API_KEY`: API key for [Elasticsearch](https://www.elastic.co/docs/deploy-manage/api-keys/elasticsearch-api-keys) or [Elastic Cloud](https://www.elastic.co/docs/deploy-manage/api-keys/elastic-cloud-api-keys) Authentication.
|
282
|
+
|
283
|
+
### Other Configuration
|
284
|
+
- `ELASTICSEARCH_HOSTS` / `OPENSEARCH_HOSTS`: Comma-separated list of hosts (default: `https://localhost:9200`)
|
285
|
+
- `ELASTICSEARCH_VERIFY_CERTS` / `OPENSEARCH_VERIFY_CERTS`: Whether to verify SSL certificates (default: `false`)
|
271
286
|
|
272
287
|
## Start Elasticsearch/OpenSearch Cluster
|
273
288
|
|
@@ -292,7 +307,7 @@ You can access Kibana/OpenSearch Dashboards from http://localhost:5601.
|
|
292
307
|
Using `uvx` will automatically install the package from PyPI, no need to clone the repository locally. Add the following configuration to 's config file `claude_desktop_config.json`.
|
293
308
|
|
294
309
|
```json
|
295
|
-
// For Elasticsearch
|
310
|
+
// For Elasticsearch with username/password
|
296
311
|
{
|
297
312
|
"mcpServers": {
|
298
313
|
"elasticsearch-mcp-server": {
|
@@ -309,6 +324,22 @@ Using `uvx` will automatically install the package from PyPI, no need to clone t
|
|
309
324
|
}
|
310
325
|
}
|
311
326
|
|
327
|
+
// For Elasticsearch with API key
|
328
|
+
{
|
329
|
+
"mcpServers": {
|
330
|
+
"elasticsearch-mcp-server": {
|
331
|
+
"command": "uvx",
|
332
|
+
"args": [
|
333
|
+
"elasticsearch-mcp-server"
|
334
|
+
],
|
335
|
+
"env": {
|
336
|
+
"ELASTICSEARCH_HOSTS": "https://localhost:9200",
|
337
|
+
"ELASTICSEARCH_API_KEY": "<YOUR_ELASTICSEARCH_API_KEY>"
|
338
|
+
}
|
339
|
+
}
|
340
|
+
}
|
341
|
+
}
|
342
|
+
|
312
343
|
// For OpenSearch
|
313
344
|
{
|
314
345
|
"mcpServers": {
|
@@ -332,7 +363,7 @@ Using `uvx` will automatically install the package from PyPI, no need to clone t
|
|
332
363
|
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`.
|
333
364
|
|
334
365
|
```json
|
335
|
-
// For Elasticsearch
|
366
|
+
// For Elasticsearch with username/password
|
336
367
|
{
|
337
368
|
"mcpServers": {
|
338
369
|
"elasticsearch-mcp-server": {
|
@@ -352,6 +383,25 @@ Using `uv` requires cloning the repository locally and specifying the path to th
|
|
352
383
|
}
|
353
384
|
}
|
354
385
|
|
386
|
+
// For Elasticsearch with API key
|
387
|
+
{
|
388
|
+
"mcpServers": {
|
389
|
+
"elasticsearch-mcp-server": {
|
390
|
+
"command": "uv",
|
391
|
+
"args": [
|
392
|
+
"--directory",
|
393
|
+
"path/to/src/elasticsearch_mcp_server",
|
394
|
+
"run",
|
395
|
+
"elasticsearch-mcp-server"
|
396
|
+
],
|
397
|
+
"env": {
|
398
|
+
"ELASTICSEARCH_HOSTS": "https://localhost:9200",
|
399
|
+
"ELASTICSEARCH_API_KEY": "<YOUR_ELASTICSEARCH_API_KEY>"
|
400
|
+
}
|
401
|
+
}
|
402
|
+
}
|
403
|
+
}
|
404
|
+
|
355
405
|
// For OpenSearch
|
356
406
|
{
|
357
407
|
"mcpServers": {
|
@@ -378,11 +428,15 @@ Using `uv` requires cloning the repository locally and specifying the path to th
|
|
378
428
|
### Option 1: Using uvx
|
379
429
|
|
380
430
|
```bash
|
381
|
-
# export environment variables
|
431
|
+
# export environment variables (with username/password)
|
382
432
|
export ELASTICSEARCH_HOSTS="https://localhost:9200"
|
383
433
|
export ELASTICSEARCH_USERNAME="elastic"
|
384
434
|
export ELASTICSEARCH_PASSWORD="test123"
|
385
435
|
|
436
|
+
# OR export environment variables (with API key)
|
437
|
+
export ELASTICSEARCH_HOSTS="https://localhost:9200"
|
438
|
+
export ELASTICSEARCH_API_KEY="<YOUR_ELASTICSEARCH_API_KEY>"
|
439
|
+
|
386
440
|
# By default, the SSE MCP server will serve on http://127.0.0.1:8000/sse
|
387
441
|
uvx elasticsearch-mcp-server --transport sse
|
388
442
|
|
@@ -405,11 +459,15 @@ uv run src/server.py elasticsearch-mcp-server --transport sse --host 0.0.0.0 --p
|
|
405
459
|
### Option 1: Using uvx
|
406
460
|
|
407
461
|
```bash
|
408
|
-
# export environment variables
|
462
|
+
# export environment variables (with username/password)
|
409
463
|
export ELASTICSEARCH_HOSTS="https://localhost:9200"
|
410
464
|
export ELASTICSEARCH_USERNAME="elastic"
|
411
465
|
export ELASTICSEARCH_PASSWORD="test123"
|
412
466
|
|
467
|
+
# OR export environment variables (with API key)
|
468
|
+
export ELASTICSEARCH_HOSTS="https://localhost:9200"
|
469
|
+
export ELASTICSEARCH_API_KEY="<YOUR_ELASTICSEARCH_API_KEY>"
|
470
|
+
|
413
471
|
# By default, the Streamable HTTP MCP server will serve on http://127.0.0.1:8000/mcp
|
414
472
|
uvx elasticsearch-mcp-server --transport streamable-http
|
415
473
|
|
@@ -1,10 +1,12 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
<!-- mcp-name: io.github.cr7258/elasticsearch-mcp-server -->
|
3
3
|
|
4
|
-
|
4
|
+
# Elasticsearch/OpenSearch MCP Server
|
5
5
|
|
6
6
|
[](https://mseep.ai/app/cr7258-elasticsearch-mcp-server)
|
7
7
|
|
8
|
+
[](https://archestra.ai/mcp-catalog/cr7258__elasticsearch-mcp-server)
|
9
|
+
|
8
10
|
## Overview
|
9
11
|
|
10
12
|
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.
|
@@ -50,7 +52,20 @@ https://github.com/user-attachments/assets/f7409e31-fac4-4321-9c94-b0ff2ea7ff15
|
|
50
52
|
|
51
53
|
## Configure Environment Variables
|
52
54
|
|
53
|
-
|
55
|
+
The MCP server supports the following environment variables for authentication:
|
56
|
+
|
57
|
+
### Basic Authentication (Username/Password)
|
58
|
+
- `ELASTICSEARCH_USERNAME`: Username for basic authentication
|
59
|
+
- `ELASTICSEARCH_PASSWORD`: Password for basic authentication
|
60
|
+
- `OPENSEARCH_USERNAME`: Username for OpenSearch basic authentication
|
61
|
+
- `OPENSEARCH_PASSWORD`: Password for OpenSearch basic authentication
|
62
|
+
|
63
|
+
### API Key Authentication (Elasticsearch only) - Recommended
|
64
|
+
- `ELASTICSEARCH_API_KEY`: API key for [Elasticsearch](https://www.elastic.co/docs/deploy-manage/api-keys/elasticsearch-api-keys) or [Elastic Cloud](https://www.elastic.co/docs/deploy-manage/api-keys/elastic-cloud-api-keys) Authentication.
|
65
|
+
|
66
|
+
### Other Configuration
|
67
|
+
- `ELASTICSEARCH_HOSTS` / `OPENSEARCH_HOSTS`: Comma-separated list of hosts (default: `https://localhost:9200`)
|
68
|
+
- `ELASTICSEARCH_VERIFY_CERTS` / `OPENSEARCH_VERIFY_CERTS`: Whether to verify SSL certificates (default: `false`)
|
54
69
|
|
55
70
|
## Start Elasticsearch/OpenSearch Cluster
|
56
71
|
|
@@ -75,7 +90,7 @@ You can access Kibana/OpenSearch Dashboards from http://localhost:5601.
|
|
75
90
|
Using `uvx` will automatically install the package from PyPI, no need to clone the repository locally. Add the following configuration to 's config file `claude_desktop_config.json`.
|
76
91
|
|
77
92
|
```json
|
78
|
-
// For Elasticsearch
|
93
|
+
// For Elasticsearch with username/password
|
79
94
|
{
|
80
95
|
"mcpServers": {
|
81
96
|
"elasticsearch-mcp-server": {
|
@@ -92,6 +107,22 @@ Using `uvx` will automatically install the package from PyPI, no need to clone t
|
|
92
107
|
}
|
93
108
|
}
|
94
109
|
|
110
|
+
// For Elasticsearch with API key
|
111
|
+
{
|
112
|
+
"mcpServers": {
|
113
|
+
"elasticsearch-mcp-server": {
|
114
|
+
"command": "uvx",
|
115
|
+
"args": [
|
116
|
+
"elasticsearch-mcp-server"
|
117
|
+
],
|
118
|
+
"env": {
|
119
|
+
"ELASTICSEARCH_HOSTS": "https://localhost:9200",
|
120
|
+
"ELASTICSEARCH_API_KEY": "<YOUR_ELASTICSEARCH_API_KEY>"
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
95
126
|
// For OpenSearch
|
96
127
|
{
|
97
128
|
"mcpServers": {
|
@@ -115,7 +146,7 @@ Using `uvx` will automatically install the package from PyPI, no need to clone t
|
|
115
146
|
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`.
|
116
147
|
|
117
148
|
```json
|
118
|
-
// For Elasticsearch
|
149
|
+
// For Elasticsearch with username/password
|
119
150
|
{
|
120
151
|
"mcpServers": {
|
121
152
|
"elasticsearch-mcp-server": {
|
@@ -135,6 +166,25 @@ Using `uv` requires cloning the repository locally and specifying the path to th
|
|
135
166
|
}
|
136
167
|
}
|
137
168
|
|
169
|
+
// For Elasticsearch with API key
|
170
|
+
{
|
171
|
+
"mcpServers": {
|
172
|
+
"elasticsearch-mcp-server": {
|
173
|
+
"command": "uv",
|
174
|
+
"args": [
|
175
|
+
"--directory",
|
176
|
+
"path/to/src/elasticsearch_mcp_server",
|
177
|
+
"run",
|
178
|
+
"elasticsearch-mcp-server"
|
179
|
+
],
|
180
|
+
"env": {
|
181
|
+
"ELASTICSEARCH_HOSTS": "https://localhost:9200",
|
182
|
+
"ELASTICSEARCH_API_KEY": "<YOUR_ELASTICSEARCH_API_KEY>"
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
138
188
|
// For OpenSearch
|
139
189
|
{
|
140
190
|
"mcpServers": {
|
@@ -161,11 +211,15 @@ Using `uv` requires cloning the repository locally and specifying the path to th
|
|
161
211
|
### Option 1: Using uvx
|
162
212
|
|
163
213
|
```bash
|
164
|
-
# export environment variables
|
214
|
+
# export environment variables (with username/password)
|
165
215
|
export ELASTICSEARCH_HOSTS="https://localhost:9200"
|
166
216
|
export ELASTICSEARCH_USERNAME="elastic"
|
167
217
|
export ELASTICSEARCH_PASSWORD="test123"
|
168
218
|
|
219
|
+
# OR export environment variables (with API key)
|
220
|
+
export ELASTICSEARCH_HOSTS="https://localhost:9200"
|
221
|
+
export ELASTICSEARCH_API_KEY="<YOUR_ELASTICSEARCH_API_KEY>"
|
222
|
+
|
169
223
|
# By default, the SSE MCP server will serve on http://127.0.0.1:8000/sse
|
170
224
|
uvx elasticsearch-mcp-server --transport sse
|
171
225
|
|
@@ -188,11 +242,15 @@ uv run src/server.py elasticsearch-mcp-server --transport sse --host 0.0.0.0 --p
|
|
188
242
|
### Option 1: Using uvx
|
189
243
|
|
190
244
|
```bash
|
191
|
-
# export environment variables
|
245
|
+
# export environment variables (with username/password)
|
192
246
|
export ELASTICSEARCH_HOSTS="https://localhost:9200"
|
193
247
|
export ELASTICSEARCH_USERNAME="elastic"
|
194
248
|
export ELASTICSEARCH_PASSWORD="test123"
|
195
249
|
|
250
|
+
# OR export environment variables (with API key)
|
251
|
+
export ELASTICSEARCH_HOSTS="https://localhost:9200"
|
252
|
+
export ELASTICSEARCH_API_KEY="<YOUR_ELASTICSEARCH_API_KEY>"
|
253
|
+
|
196
254
|
# By default, the Streamable HTTP MCP server will serve on http://127.0.0.1:8000/mcp
|
197
255
|
uvx elasticsearch-mcp-server --transport streamable-http
|
198
256
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
|
3
|
+
"name": "io.github.cr7258/elasticsearch-mcp-server",
|
4
|
+
"description": "MCP server for interacting with Elasticsearch",
|
5
|
+
"status": "active",
|
6
|
+
"repository": {
|
7
|
+
"url": "https://github.com/cr7258/elasticsearch-mcp-server",
|
8
|
+
"source": "github"
|
9
|
+
},
|
10
|
+
"version": "2.0.12",
|
11
|
+
"packages": [
|
12
|
+
{
|
13
|
+
"registry_type": "pypi",
|
14
|
+
"registry_base_url": "https://pypi.org",
|
15
|
+
"identifier": "elasticsearch-mcp-server",
|
16
|
+
"version": "2.0.12",
|
17
|
+
"transport": {
|
18
|
+
"type": "stdio"
|
19
|
+
},
|
20
|
+
"environment_variables": [
|
21
|
+
{
|
22
|
+
"name": "ELASTICSEARCH_HOSTS",
|
23
|
+
"description": "Comma-separated list of Elasticsearch hosts (e.g., https://localhost:9200)",
|
24
|
+
"is_required": false,
|
25
|
+
"format": "string",
|
26
|
+
"is_secret": false,
|
27
|
+
"default": "https://localhost:9200"
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "ELASTICSEARCH_API_KEY",
|
31
|
+
"description": "API key for Elasticsearch or Elastic Cloud authentication (recommended)",
|
32
|
+
"is_required": false,
|
33
|
+
"format": "string",
|
34
|
+
"is_secret": true
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"name": "ELASTICSEARCH_USERNAME",
|
38
|
+
"description": "Username for basic authentication (alternative to API key)",
|
39
|
+
"is_required": false,
|
40
|
+
"format": "string",
|
41
|
+
"is_secret": false
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"name": "ELASTICSEARCH_PASSWORD",
|
45
|
+
"description": "Password for basic authentication (used with ELASTICSEARCH_USERNAME)",
|
46
|
+
"is_required": false,
|
47
|
+
"format": "string",
|
48
|
+
"is_secret": true
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"name": "ELASTICSEARCH_VERIFY_CERTS",
|
52
|
+
"description": "Whether to verify SSL certificates (true/false)",
|
53
|
+
"is_required": false,
|
54
|
+
"format": "boolean",
|
55
|
+
"is_secret": false,
|
56
|
+
"default": "false"
|
57
|
+
}
|
58
|
+
]
|
59
|
+
}
|
60
|
+
]
|
61
|
+
}
|
@@ -24,12 +24,14 @@ def create_search_client(engine_type: str) -> SearchClient:
|
|
24
24
|
hosts = [host.strip() for host in hosts_str.split(",")]
|
25
25
|
username = os.environ.get(f"{prefix}_USERNAME")
|
26
26
|
password = os.environ.get(f"{prefix}_PASSWORD")
|
27
|
+
api_key = os.environ.get(f"{prefix}_API_KEY")
|
27
28
|
verify_certs = os.environ.get(f"{prefix}_VERIFY_CERTS", "false").lower() == "true"
|
28
29
|
|
29
30
|
config = {
|
30
31
|
"hosts": hosts,
|
31
32
|
"username": username,
|
32
33
|
"password": password,
|
34
|
+
"api_key": api_key,
|
33
35
|
"verify_certs": verify_certs
|
34
36
|
}
|
35
37
|
|
@@ -24,6 +24,7 @@ class SearchClientBase(ABC):
|
|
24
24
|
hosts = config.get("hosts")
|
25
25
|
username = config.get("username")
|
26
26
|
password = config.get("password")
|
27
|
+
api_key = config.get("api_key")
|
27
28
|
verify_certs = config.get("verify_certs", False)
|
28
29
|
|
29
30
|
# Disable insecure request warnings if verify_certs is False
|
@@ -39,8 +40,8 @@ class SearchClientBase(ABC):
|
|
39
40
|
|
40
41
|
# Initialize client based on engine type
|
41
42
|
if engine_type == "elasticsearch":
|
42
|
-
# Get auth parameters based on elasticsearch package version
|
43
|
-
auth_params = self._get_elasticsearch_auth_params(username, password)
|
43
|
+
# Get auth parameters based on elasticsearch package version and authentication method
|
44
|
+
auth_params = self._get_elasticsearch_auth_params(username, password, api_key)
|
44
45
|
|
45
46
|
self.client = Elasticsearch(
|
46
47
|
hosts=hosts,
|
@@ -64,20 +65,26 @@ class SearchClientBase(ABC):
|
|
64
65
|
base_url=base_url,
|
65
66
|
username=username,
|
66
67
|
password=password,
|
68
|
+
api_key=api_key,
|
67
69
|
verify_certs=verify_certs,
|
68
70
|
)
|
69
71
|
|
70
|
-
def _get_elasticsearch_auth_params(self, username: Optional[str], password: Optional[str]) -> Dict:
|
72
|
+
def _get_elasticsearch_auth_params(self, username: Optional[str], password: Optional[str], api_key: Optional[str]) -> Dict:
|
71
73
|
"""
|
72
74
|
Get authentication parameters for Elasticsearch client based on package version.
|
73
75
|
|
74
76
|
Args:
|
75
77
|
username: Username for authentication
|
76
78
|
password: Password for authentication
|
79
|
+
api_key: API key for authentication
|
77
80
|
|
78
81
|
Returns:
|
79
82
|
Dictionary with appropriate auth parameters for the ES version
|
80
83
|
"""
|
84
|
+
# API key takes precedence over username/password
|
85
|
+
if api_key:
|
86
|
+
return {"api_key": api_key}
|
87
|
+
|
81
88
|
if not username or not password:
|
82
89
|
return {}
|
83
90
|
|
@@ -97,20 +104,28 @@ class SearchClientBase(ABC):
|
|
97
104
|
return {"basic_auth": (username, password)}
|
98
105
|
|
99
106
|
class GeneralRestClient:
|
100
|
-
def __init__(self, base_url: Optional[str], username: Optional[str], password: Optional[str], verify_certs: bool):
|
107
|
+
def __init__(self, base_url: Optional[str], username: Optional[str], password: Optional[str], api_key: Optional[str], verify_certs: bool):
|
101
108
|
self.base_url = base_url.rstrip("/") if base_url else ""
|
102
109
|
self.auth = (username, password) if username and password else None
|
110
|
+
self.api_key = api_key
|
103
111
|
self.verify_certs = verify_certs
|
104
112
|
|
105
113
|
def request(self, method, path, params=None, body=None):
|
106
114
|
url = f"{self.base_url}/{path.lstrip('/')}"
|
115
|
+
headers = {}
|
116
|
+
|
117
|
+
# Add API key to Authorization header if provided
|
118
|
+
if self.api_key:
|
119
|
+
headers["Authorization"] = f"ApiKey {self.api_key}"
|
120
|
+
|
107
121
|
with httpx.Client(verify=self.verify_certs) as client:
|
108
122
|
resp = client.request(
|
109
123
|
method=method.upper(),
|
110
124
|
url=url,
|
111
125
|
params=params,
|
112
126
|
json=body,
|
113
|
-
auth=self.auth
|
127
|
+
auth=self.auth if not self.api_key else None, # Use basic auth only if no API key
|
128
|
+
headers=headers
|
114
129
|
)
|
115
130
|
resp.raise_for_status()
|
116
131
|
ct = resp.headers.get("content-type", "")
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "2.0.12"
|