opensearch-mcp-server 2.0.8__py3-none-any.whl → 2.0.10__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opensearch-mcp-server
3
- Version: 2.0.8
3
+ Version: 2.0.10
4
4
  Summary: MCP Server for interacting with Elasticsearch and OpenSearch
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -427,6 +427,21 @@ uv run src/server.py elasticsearch-mcp-server --transport streamable-http
427
427
  uv run src/server.py elasticsearch-mcp-server --transport streamable-http --host 0.0.0.0 --port 8000 --path /mcp
428
428
  ```
429
429
 
430
+ ## Compatibility
431
+
432
+ The MCP server is compatible with Elasticsearch 7.x, 8.x, and 9.x. By default, it uses the Elasticsearch 8.x client (without a suffix). To use the Elasticsearch 7.x client, run the `elasticsearch-mcp-server-es7` variant. For Elasticsearch 9.x, use `elasticsearch-mcp-server-es9`. For example:
433
+
434
+ ```bash
435
+ uvx elasticsearch-mcp-server-es7
436
+ ```
437
+
438
+ | MCP Server | Elasticsearch |
439
+ | --- | --- |
440
+ | elasticsearch-mcp-server-es7 | Elasticsearch 7.x |
441
+ | elasticsearch-mcp-server | Elasticsearch 8.x |
442
+ | elasticsearch-mcp-server-es9 | Elasticsearch 9.x |
443
+ | opensearch-mcp-server | OpenSearch 1.x, 2.x, 3.x |
444
+
430
445
  ## License
431
446
 
432
447
  This project is licensed under the Apache License Version 2.0 - see the [LICENSE](LICENSE) file for details.
@@ -1,8 +1,8 @@
1
1
  src/__init__.py,sha256=aNKcThftSLh9IjOTA-UUpoRzIm4R0WwXKGAzykwecmU,211
2
2
  src/server.py,sha256=BfMAgXTFV9C4waCWRro8Sfl6yXEXr2vJ7YoGY7HhMPY,5072
3
- src/version.py,sha256=oVbl6ILP5dyBZtm2iUzM_QTUhSy3C325aGgDThF7P_4,22
3
+ src/version.py,sha256=QvVarwQu86KS14HXwAYbCqU1tjzA5eNjQxH2V34_iIU,23
4
4
  src/clients/__init__.py,sha256=3UezAt9422S-7BvMiCo2Y9pmATVutorwsIQXP_g_CkA,1221
5
- src/clients/base.py,sha256=MBAGepXyHPtdbtHhxFB8CamZ2ApWCBuOi_6-ey-MqX8,3298
5
+ src/clients/base.py,sha256=r8VmD4FAc-_PgHpNX7Pj2a0Db2NgUtIQvTucsRVSEsA,4700
6
6
  src/clients/exceptions.py,sha256=NYF3KVw-9aAgCViin5OuBI6miMEPS5QsdHx6bcis1wc,2493
7
7
  src/clients/common/__init__.py,sha256=VgvgxFpESn2wAuJmH0XM_Ej2izI7dxK7QJe9wG4fmW0,211
8
8
  src/clients/common/alias.py,sha256=rB53TSld5x2vZyDNAwyEdnh1KWUXMSD7h5fSv_ubR2Q,759
@@ -18,8 +18,8 @@ src/tools/document.py,sha256=XZTVuk4di9VEwWMZN7jyDVnzoOiXkb4FBrXF44sVXTs,2052
18
18
  src/tools/general.py,sha256=whj1spjIb8SS75h843X6c3RTsrZcSm-66KVLlY7OEh0,817
19
19
  src/tools/index.py,sha256=7KNPtElTFelkjRSvdMqPBx9nx_9Uk01OnTMeVo7YeCs,1345
20
20
  src/tools/register.py,sha256=wrG2P6-YPW77bTg1j_ELp8omWRYsJjFeOHUy_unHe6Y,1344
21
- opensearch_mcp_server-2.0.8.dist-info/METADATA,sha256=WqPk4FQoFJhg_BmCH75KaIRTRm23ORWA19_zxMxEsRg,19863
22
- opensearch_mcp_server-2.0.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- opensearch_mcp_server-2.0.8.dist-info/entry_points.txt,sha256=ImfJnUwMpQUBmu-1MeBG_P0dwamfXKQh82mBKW7tWNY,138
24
- opensearch_mcp_server-2.0.8.dist-info/licenses/LICENSE,sha256=DBsjuP5FR51d9kaUdXlVBuBv3cQ_I_adq9gefYQ9FcY,11339
25
- opensearch_mcp_server-2.0.8.dist-info/RECORD,,
21
+ opensearch_mcp_server-2.0.10.dist-info/METADATA,sha256=iS_wfVrNJno7xllqp-pvVjVlV_2nvjq2cJGTJbZIMSE,20476
22
+ opensearch_mcp_server-2.0.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ opensearch_mcp_server-2.0.10.dist-info/entry_points.txt,sha256=ImfJnUwMpQUBmu-1MeBG_P0dwamfXKQh82mBKW7tWNY,138
24
+ opensearch_mcp_server-2.0.10.dist-info/licenses/LICENSE,sha256=DBsjuP5FR51d9kaUdXlVBuBv3cQ_I_adq9gefYQ9FcY,11339
25
+ opensearch_mcp_server-2.0.10.dist-info/RECORD,,
src/clients/base.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from abc import ABC
2
2
  import logging
3
3
  import warnings
4
- from typing import Dict
4
+ from typing import Dict, Optional
5
5
 
6
6
  from elasticsearch import Elasticsearch
7
7
  import httpx
@@ -39,10 +39,13 @@ class SearchClientBase(ABC):
39
39
 
40
40
  # Initialize client based on engine type
41
41
  if engine_type == "elasticsearch":
42
+ # Get auth parameters based on elasticsearch package version
43
+ auth_params = self._get_elasticsearch_auth_params(username, password)
44
+
42
45
  self.client = Elasticsearch(
43
46
  hosts=hosts,
44
- basic_auth=(username, password) if username and password else None,
45
- verify_certs=verify_certs
47
+ verify_certs=verify_certs,
48
+ **auth_params
46
49
  )
47
50
  self.logger.info(f"Elasticsearch client initialized with hosts: {hosts}")
48
51
  elif engine_type == "opensearch":
@@ -64,9 +67,38 @@ class SearchClientBase(ABC):
64
67
  verify_certs=verify_certs,
65
68
  )
66
69
 
70
+ def _get_elasticsearch_auth_params(self, username: Optional[str], password: Optional[str]) -> Dict:
71
+ """
72
+ Get authentication parameters for Elasticsearch client based on package version.
73
+
74
+ Args:
75
+ username: Username for authentication
76
+ password: Password for authentication
77
+
78
+ Returns:
79
+ Dictionary with appropriate auth parameters for the ES version
80
+ """
81
+ if not username or not password:
82
+ return {}
83
+
84
+ # Check Elasticsearch package version to determine auth parameter name
85
+ try:
86
+ from elasticsearch import __version__ as es_version
87
+ major_version = es_version[0]
88
+ if major_version >= 8:
89
+ # ES 8+ uses basic_auth
90
+ return {"basic_auth": (username, password)}
91
+ else:
92
+ # ES 7 and below use http_auth
93
+ return {"http_auth": (username, password)}
94
+ except Exception as e:
95
+ self.logger.error(f"Failed to detect Elasticsearch version: {e}")
96
+ # If we can't detect version, try basic_auth first (ES 8+ default)
97
+ return {"basic_auth": (username, password)}
98
+
67
99
  class GeneralRestClient:
68
- def __init__(self, base_url: str, username: str, password: str, verify_certs: bool):
69
- self.base_url = base_url.rstrip("/")
100
+ def __init__(self, base_url: Optional[str], username: Optional[str], password: Optional[str], verify_certs: bool):
101
+ self.base_url = base_url.rstrip("/") if base_url else ""
70
102
  self.auth = (username, password) if username and password else None
71
103
  self.verify_certs = verify_certs
72
104
 
src/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.0.8"
1
+ __version__ = "2.0.10"