mcp-hydrolix 0.1.3__tar.gz → 0.1.4__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.
@@ -1,3 +1,3 @@
1
1
  [*]
2
2
  trim_trailing_whitespace = true
3
- end_of_line = lf
3
+ end_of_line = lf
@@ -168,7 +168,7 @@ cython_debug/
168
168
  # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
169
169
  # and can be added to the global gitignore or merged into this file. For a more nuclear
170
170
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
171
- #.idea/
171
+ .idea/
172
172
 
173
173
  # PyPI configuration file
174
174
  .pypirc
@@ -0,0 +1,20 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v6.0.0
4
+ hooks:
5
+ - id: end-of-file-fixer
6
+ - id: trailing-whitespace
7
+ args: [--markdown-linebreak-ext=md]
8
+ - id: check-yaml
9
+ - id: check-json
10
+ - id: check-toml
11
+ - id: no-commit-to-branch
12
+
13
+ - repo: https://github.com/astral-sh/ruff-pre-commit
14
+ rev: v0.12.9
15
+ hooks:
16
+ - id: ruff
17
+ name: ruff lint
18
+ args: [--fix]
19
+ - id: ruff-format
20
+ name: ruff format
@@ -198,4 +198,4 @@
198
198
  distributed under the License is distributed on an "AS IS" BASIS,
199
199
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
200
  See the License for the specific language governing permissions and
201
- limitations under the License.
201
+ limitations under the License.
@@ -1,22 +1,24 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-hydrolix
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: An MCP server for Hydrolix.
5
5
  Project-URL: Home, https://github.com/hydrolix/mcp-hydrolix
6
6
  License-Expression: Apache-2.0
7
7
  License-File: LICENSE
8
8
  Requires-Python: >=3.13
9
9
  Requires-Dist: clickhouse-connect>=0.8.16
10
- Requires-Dist: mcp[cli]>=1.3.0
10
+ Requires-Dist: fastmcp>=2.0.0
11
11
  Requires-Dist: pip-system-certs>=4.0
12
12
  Requires-Dist: python-dotenv>=1.0.1
13
- Requires-Dist: uvicorn>=0.34.0
14
13
  Provides-Extra: dev
14
+ Requires-Dist: pre-commit; extra == 'dev'
15
15
  Requires-Dist: pytest; extra == 'dev'
16
+ Requires-Dist: pytest-asyncio; extra == 'dev'
16
17
  Requires-Dist: ruff; extra == 'dev'
17
18
  Description-Content-Type: text/markdown
18
19
 
19
20
  # Hydrolix MCP Server
21
+
20
22
  [![PyPI - Version](https://img.shields.io/pypi/v/mcp-hydrolix)](https://pypi.org/project/mcp-hydrolix)
21
23
 
22
24
  An MCP server for Hydrolix.
@@ -24,16 +26,16 @@ An MCP server for Hydrolix.
24
26
  ## Tools
25
27
 
26
28
  * `run_select_query`
27
- - Execute SQL queries on your Hydrolix cluster.
28
- - Input: `sql` (string): The SQL query to execute.
29
- - All Hydrolix queries are run with `readonly = 1` to ensure they are safe.
29
+ * Execute SQL queries on your Hydrolix cluster.
30
+ * Input: `sql` (string): The SQL query to execute.
31
+ * All Hydrolix queries are run with `readonly = 1` to ensure they are safe.
30
32
 
31
33
  * `list_databases`
32
- - List all databases on your Hydrolix cluster.
34
+ * List all databases on your Hydrolix cluster.
33
35
 
34
36
  * `list_tables`
35
- - List all tables in a database.
36
- - Input: `database` (string): The name of the database.
37
+ * List all tables in a database.
38
+ * Input: `database` (string): The name of the database.
37
39
 
38
40
  ## Effective Usage
39
41
 
@@ -44,13 +46,25 @@ Due to the wide variety in LLM architectures, not all models will proactively us
44
46
  * Include time ranges in your prompts (e.g., "Between December 5 2023 and January 18 2024, ...") and specifically request that the output be ordered by timestamp.
45
47
  - This prompts the model to write more efficient queries that take advantage of [primary key optimizations](https://hydrolix.io/blog/optimizing-latest-n-row-queries/)
46
48
 
49
+ ### Health Check Endpoint
50
+
51
+ When running with HTTP or SSE transport, a health check endpoint is available at `/health`. This endpoint:
52
+ - Returns `200 OK` with the Hydrolix query-head's Clickhouse version if the server is healthy and can connect to Hydrolix
53
+ - Returns `503 Service Unavailable` if the server cannot connect to the Hydrolix query-head
54
+
55
+ Example:
56
+ ```bash
57
+ curl http://localhost:8000/health
58
+ # Response: OK - Connected to Hydrolix compatible with ClickHouse 24.3.1
59
+ ```
60
+
47
61
  ## Configuration
48
62
 
49
63
  The Hydrolix MCP server is configured using a standard MCP server entry. Consult your client's documentation for specific instructions on where to find or declare MCP servers. An example setup using Claude Desktop is documented below.
50
64
 
51
65
  The recommended way to launch the Hydrolix MCP server is via the [`uv` project manager](https://github.com/astral-sh/uv), which will manage installing all other dependencies in an isolated environment.
52
66
 
53
- MCP Server definition (JSON):
67
+ MCP Server definition using username and password (JSON):
54
68
 
55
69
  ```json
56
70
  {
@@ -71,7 +85,27 @@ MCP Server definition (JSON):
71
85
  }
72
86
  ```
73
87
 
74
- MCP Server definition (YAML):
88
+ MCP Server definition using service account token (JSON):
89
+
90
+ ```json
91
+ {
92
+ "command": "uv",
93
+ "args": [
94
+ "run",
95
+ "--with",
96
+ "mcp-hydrolix",
97
+ "--python",
98
+ "3.13",
99
+ "mcp-hydrolix"
100
+ ],
101
+ "env": {
102
+ "HYDROLIX_HOST": "<hydrolix-host>",
103
+ "HYDROLIX_TOKEN": "<hydrolix-service-account-token>"
104
+ }
105
+ }
106
+ ```
107
+
108
+ MCP Server definition using username and password (YAML):
75
109
 
76
110
  ```yaml
77
111
  command: uv
@@ -88,13 +122,29 @@ env:
88
122
  HYDROLIX_PASSWORD: <hydrolix-password>
89
123
  ```
90
124
 
125
+ MCP Server definition using service account token (YAML):
126
+
127
+ ```yaml
128
+ command: uv
129
+ args:
130
+ - run
131
+ - --with
132
+ - mcp-hydrolix
133
+ - --python
134
+ - "3.13"
135
+ - mcp-hydrolix
136
+ env:
137
+ HYDROLIX_HOST: <hydrolix-host>
138
+ HYDROLIX_TOKEN: <hydrolix-service-account-token>
139
+ ```
140
+
91
141
  ### Configuration Example (Claude Desktop)
92
142
 
93
143
  1. Open the Claude Desktop configuration file located at:
94
144
  - On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
95
145
  - On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
96
146
 
97
- 2. Add a `mcp-hydrolix` server entry to the `mcpServers` config block:
147
+ 2. Add a `mcp-hydrolix` server entry to the `mcpServers` config block to use username and password:
98
148
 
99
149
  ```json
100
150
  {
@@ -119,6 +169,30 @@ env:
119
169
  }
120
170
  ```
121
171
 
172
+ To leverage service account use the following config block:
173
+
174
+ ```json
175
+ {
176
+ "mcpServers": {
177
+ "mcp-hydrolix": {
178
+ "command": "uv",
179
+ "args": [
180
+ "run",
181
+ "--with",
182
+ "mcp-hydrolix",
183
+ "--python",
184
+ "3.13",
185
+ "mcp-hydrolix"
186
+ ],
187
+ "env": {
188
+ "HYDROLIX_HOST": "<hydrolix-host>",
189
+ "HYDROLIX_TOKEN": "<hydrolix-service-account-token>"
190
+ }
191
+ }
192
+ }
193
+ }
194
+ ```
195
+
122
196
  3. Update the environment variable definitions to point to your Hydrolix cluster.
123
197
 
124
198
  4. (Recommended) Locate the command entry for `uv` and replace it with the absolute path to the `uv` executable. This ensures that the correct version of `uv` is used when starting the server. You can find this path using `which uv` or `where.exe uv`.
@@ -131,16 +205,47 @@ The following variables are used to configure the Hydrolix connection. These var
131
205
 
132
206
  #### Required Variables
133
207
  * `HYDROLIX_HOST`: The hostname of your Hydrolix server
134
- * `HYDROLIX_USER`: The username for authentication
135
- * `HYDROLIX_PASSWORD`: The password for authentication
208
+ * `HYDROLIX_TOKEN`: The Hydrolix service account token (omit if using username/password)
209
+ * `HYDROLIX_USER`: The username for authentication (omit if using service account)
210
+ * `HYDROLIX_PASSWORD`: The password for authentication (omit if using service account)
211
+
212
+ **Authentication precedence:** If both `HYDROLIX_TOKEN` and `HYDROLIX_USER`/`HYDROLIX_PASSWORD` are provided, the service account token takes precedence and username/password authentication will be ignored.
136
213
 
137
214
  #### Optional Variables
138
215
  * `HYDROLIX_PORT`: The port number of your Hydrolix server
139
- - Default: `8088`
140
- - Usually doesn't need to be set unless using a non-standard port
216
+ * Default: `8088`
217
+ * Usually doesn't need to be set unless using a non-standard port
141
218
  * `HYDROLIX_VERIFY`: Enable/disable SSL certificate verification
142
- - Default: `"true"`
143
- - Set to `"false"` to disable certificate verification (not recommended for production)
219
+ * Default: `"true"`
220
+ * Set to `"false"` to disable certificate verification (not recommended for production)
144
221
  * `HYDROLIX_DATABASE`: Default database to use
145
- - Default: None (uses server default)
146
- - Set this to automatically connect to a specific database
222
+ *Default: None (uses server default)
223
+ * Set this to automatically connect to a specific database
224
+ * `HYDROLIX_MCP_SERVER_TRANSPORT`: Sets the transport method for the MCP server.
225
+ * Default: `"stdio"`
226
+ * Valid options: `"stdio"`, `"http"`, `"sse"`. This is useful for local development with tools like MCP Inspector.
227
+ * `HYDROLIX_MCP_BIND_HOST`: Host to bind the MCP server to when using HTTP or SSE transport
228
+ * Default: `"127.0.0.1"`
229
+ * Set to `"0.0.0.0"` to bind to all network interfaces (useful for Docker or remote access)
230
+ * Only used when transport is `"http"` or `"sse"`
231
+ * `HYDROLIX_MCP_BIND_PORT`: Port to bind the MCP server to when using HTTP or SSE transport
232
+ * Default: `"8000"`
233
+ * Only used when transport is `"http"` or `"sse"`
234
+
235
+
236
+ For MCP Inspector or remote access with HTTP transport:
237
+
238
+ ```env
239
+ HYDROLIX_HOST=localhost
240
+ HYDROLIX_USER=default
241
+ HYDROLIX_PASSWORD=myPassword
242
+ HYDROLIX_MCP_SERVER_TRANSPORT=http
243
+ HYDROLIX_MCP_BIND_HOST=0.0.0.0 # Bind to all interfaces
244
+ HYDROLIX_MCP_BIND_PORT=4200 # Custom port (default: 8000)
245
+ ```
246
+
247
+ When using HTTP transport, the server will run on the configured port (default 8000). For example, with the above configuration:
248
+ - MCP endpoint: `http://localhost:4200/mcp`
249
+ - Health check: `http://localhost:4200/health`
250
+
251
+ Note: The bind host and port settings are only used when transport is set to "http" or "sse".
@@ -0,0 +1,232 @@
1
+ # Hydrolix MCP Server
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/mcp-hydrolix)](https://pypi.org/project/mcp-hydrolix)
4
+
5
+ An MCP server for Hydrolix.
6
+
7
+ ## Tools
8
+
9
+ * `run_select_query`
10
+ * Execute SQL queries on your Hydrolix cluster.
11
+ * Input: `sql` (string): The SQL query to execute.
12
+ * All Hydrolix queries are run with `readonly = 1` to ensure they are safe.
13
+
14
+ * `list_databases`
15
+ * List all databases on your Hydrolix cluster.
16
+
17
+ * `list_tables`
18
+ * List all tables in a database.
19
+ * Input: `database` (string): The name of the database.
20
+
21
+ ## Effective Usage
22
+
23
+ Due to the wide variety in LLM architectures, not all models will proactively use the tools above, and few will use them effectively without guidance, even with the carefully-constructed tool descriptions provided to the model. To get the best results out of your model while using the Hydrolix MCP server, we recommend the following:
24
+
25
+ * Refer to your Hydrolix database by name and request tool usage in your prompts (e.g., "Using MCP tools to access my Hydrolix database, please ...")
26
+ - This encourages the model to use the MCP tools available and minimizes hallucinations.
27
+ * Include time ranges in your prompts (e.g., "Between December 5 2023 and January 18 2024, ...") and specifically request that the output be ordered by timestamp.
28
+ - This prompts the model to write more efficient queries that take advantage of [primary key optimizations](https://hydrolix.io/blog/optimizing-latest-n-row-queries/)
29
+
30
+ ### Health Check Endpoint
31
+
32
+ When running with HTTP or SSE transport, a health check endpoint is available at `/health`. This endpoint:
33
+ - Returns `200 OK` with the Hydrolix query-head's Clickhouse version if the server is healthy and can connect to Hydrolix
34
+ - Returns `503 Service Unavailable` if the server cannot connect to the Hydrolix query-head
35
+
36
+ Example:
37
+ ```bash
38
+ curl http://localhost:8000/health
39
+ # Response: OK - Connected to Hydrolix compatible with ClickHouse 24.3.1
40
+ ```
41
+
42
+ ## Configuration
43
+
44
+ The Hydrolix MCP server is configured using a standard MCP server entry. Consult your client's documentation for specific instructions on where to find or declare MCP servers. An example setup using Claude Desktop is documented below.
45
+
46
+ The recommended way to launch the Hydrolix MCP server is via the [`uv` project manager](https://github.com/astral-sh/uv), which will manage installing all other dependencies in an isolated environment.
47
+
48
+ MCP Server definition using username and password (JSON):
49
+
50
+ ```json
51
+ {
52
+ "command": "uv",
53
+ "args": [
54
+ "run",
55
+ "--with",
56
+ "mcp-hydrolix",
57
+ "--python",
58
+ "3.13",
59
+ "mcp-hydrolix"
60
+ ],
61
+ "env": {
62
+ "HYDROLIX_HOST": "<hydrolix-host>",
63
+ "HYDROLIX_USER": "<hydrolix-user>",
64
+ "HYDROLIX_PASSWORD": "<hydrolix-password>"
65
+ }
66
+ }
67
+ ```
68
+
69
+ MCP Server definition using service account token (JSON):
70
+
71
+ ```json
72
+ {
73
+ "command": "uv",
74
+ "args": [
75
+ "run",
76
+ "--with",
77
+ "mcp-hydrolix",
78
+ "--python",
79
+ "3.13",
80
+ "mcp-hydrolix"
81
+ ],
82
+ "env": {
83
+ "HYDROLIX_HOST": "<hydrolix-host>",
84
+ "HYDROLIX_TOKEN": "<hydrolix-service-account-token>"
85
+ }
86
+ }
87
+ ```
88
+
89
+ MCP Server definition using username and password (YAML):
90
+
91
+ ```yaml
92
+ command: uv
93
+ args:
94
+ - run
95
+ - --with
96
+ - mcp-hydrolix
97
+ - --python
98
+ - "3.13"
99
+ - mcp-hydrolix
100
+ env:
101
+ HYDROLIX_HOST: <hydrolix-host>
102
+ HYDROLIX_USER: <hydrolix-user>
103
+ HYDROLIX_PASSWORD: <hydrolix-password>
104
+ ```
105
+
106
+ MCP Server definition using service account token (YAML):
107
+
108
+ ```yaml
109
+ command: uv
110
+ args:
111
+ - run
112
+ - --with
113
+ - mcp-hydrolix
114
+ - --python
115
+ - "3.13"
116
+ - mcp-hydrolix
117
+ env:
118
+ HYDROLIX_HOST: <hydrolix-host>
119
+ HYDROLIX_TOKEN: <hydrolix-service-account-token>
120
+ ```
121
+
122
+ ### Configuration Example (Claude Desktop)
123
+
124
+ 1. Open the Claude Desktop configuration file located at:
125
+ - On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
126
+ - On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
127
+
128
+ 2. Add a `mcp-hydrolix` server entry to the `mcpServers` config block to use username and password:
129
+
130
+ ```json
131
+ {
132
+ "mcpServers": {
133
+ "mcp-hydrolix": {
134
+ "command": "uv",
135
+ "args": [
136
+ "run",
137
+ "--with",
138
+ "mcp-hydrolix",
139
+ "--python",
140
+ "3.13",
141
+ "mcp-hydrolix"
142
+ ],
143
+ "env": {
144
+ "HYDROLIX_HOST": "<hydrolix-host>",
145
+ "HYDROLIX_USER": "<hydrolix-user>",
146
+ "HYDROLIX_PASSWORD": "<hydrolix-password>"
147
+ }
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ To leverage service account use the following config block:
154
+
155
+ ```json
156
+ {
157
+ "mcpServers": {
158
+ "mcp-hydrolix": {
159
+ "command": "uv",
160
+ "args": [
161
+ "run",
162
+ "--with",
163
+ "mcp-hydrolix",
164
+ "--python",
165
+ "3.13",
166
+ "mcp-hydrolix"
167
+ ],
168
+ "env": {
169
+ "HYDROLIX_HOST": "<hydrolix-host>",
170
+ "HYDROLIX_TOKEN": "<hydrolix-service-account-token>"
171
+ }
172
+ }
173
+ }
174
+ }
175
+ ```
176
+
177
+ 3. Update the environment variable definitions to point to your Hydrolix cluster.
178
+
179
+ 4. (Recommended) Locate the command entry for `uv` and replace it with the absolute path to the `uv` executable. This ensures that the correct version of `uv` is used when starting the server. You can find this path using `which uv` or `where.exe uv`.
180
+
181
+ 5. Restart Claude Desktop to apply the changes. If you are using Windows, ensure Claude is stopped completely by closing the client using the system tray icon.
182
+
183
+ ### Environment Variables
184
+
185
+ The following variables are used to configure the Hydrolix connection. These variables may be provided via the MCP config block (as shown above), a `.env` file, or traditional environment variables.
186
+
187
+ #### Required Variables
188
+ * `HYDROLIX_HOST`: The hostname of your Hydrolix server
189
+ * `HYDROLIX_TOKEN`: The Hydrolix service account token (omit if using username/password)
190
+ * `HYDROLIX_USER`: The username for authentication (omit if using service account)
191
+ * `HYDROLIX_PASSWORD`: The password for authentication (omit if using service account)
192
+
193
+ **Authentication precedence:** If both `HYDROLIX_TOKEN` and `HYDROLIX_USER`/`HYDROLIX_PASSWORD` are provided, the service account token takes precedence and username/password authentication will be ignored.
194
+
195
+ #### Optional Variables
196
+ * `HYDROLIX_PORT`: The port number of your Hydrolix server
197
+ * Default: `8088`
198
+ * Usually doesn't need to be set unless using a non-standard port
199
+ * `HYDROLIX_VERIFY`: Enable/disable SSL certificate verification
200
+ * Default: `"true"`
201
+ * Set to `"false"` to disable certificate verification (not recommended for production)
202
+ * `HYDROLIX_DATABASE`: Default database to use
203
+ *Default: None (uses server default)
204
+ * Set this to automatically connect to a specific database
205
+ * `HYDROLIX_MCP_SERVER_TRANSPORT`: Sets the transport method for the MCP server.
206
+ * Default: `"stdio"`
207
+ * Valid options: `"stdio"`, `"http"`, `"sse"`. This is useful for local development with tools like MCP Inspector.
208
+ * `HYDROLIX_MCP_BIND_HOST`: Host to bind the MCP server to when using HTTP or SSE transport
209
+ * Default: `"127.0.0.1"`
210
+ * Set to `"0.0.0.0"` to bind to all network interfaces (useful for Docker or remote access)
211
+ * Only used when transport is `"http"` or `"sse"`
212
+ * `HYDROLIX_MCP_BIND_PORT`: Port to bind the MCP server to when using HTTP or SSE transport
213
+ * Default: `"8000"`
214
+ * Only used when transport is `"http"` or `"sse"`
215
+
216
+
217
+ For MCP Inspector or remote access with HTTP transport:
218
+
219
+ ```env
220
+ HYDROLIX_HOST=localhost
221
+ HYDROLIX_USER=default
222
+ HYDROLIX_PASSWORD=myPassword
223
+ HYDROLIX_MCP_SERVER_TRANSPORT=http
224
+ HYDROLIX_MCP_BIND_HOST=0.0.0.0 # Bind to all interfaces
225
+ HYDROLIX_MCP_BIND_PORT=4200 # Custom port (default: 8000)
226
+ ```
227
+
228
+ When using HTTP transport, the server will run on the configured port (default 8000). For example, with the above configuration:
229
+ - MCP endpoint: `http://localhost:4200/mcp`
230
+ - Health check: `http://localhost:4200/health`
231
+
232
+ Note: The bind host and port settings are only used when transport is set to "http" or "sse".
@@ -0,0 +1,21 @@
1
+ from .mcp_server import mcp
2
+ from .mcp_env import get_config, TransportType
3
+
4
+
5
+ def main():
6
+ config = get_config()
7
+ transport = config.mcp_server_transport
8
+
9
+ # For HTTP and SSE transports, we need to specify host and port
10
+ http_transports = [TransportType.HTTP.value, TransportType.SSE.value]
11
+ if transport in http_transports:
12
+ # Use the configured bind host (defaults to 127.0.0.1, can be set to 0.0.0.0)
13
+ # and bind port (defaults to 8000)
14
+ mcp.run(transport=transport, host=config.mcp_bind_host, port=config.mcp_bind_port)
15
+ else:
16
+ # For stdio transport, no host or port is needed
17
+ mcp.run(transport=transport)
18
+
19
+
20
+ if __name__ == "__main__":
21
+ main()
@@ -7,6 +7,20 @@ and type conversion.
7
7
  from dataclasses import dataclass
8
8
  import os
9
9
  from typing import Optional
10
+ from enum import Enum
11
+
12
+
13
+ class TransportType(str, Enum):
14
+ """Supported MCP server transport types."""
15
+
16
+ STDIO = "stdio"
17
+ HTTP = "http"
18
+ SSE = "sse"
19
+
20
+ @classmethod
21
+ def values(cls) -> list[str]:
22
+ """Get all valid transport values."""
23
+ return [transport.value for transport in cls]
10
24
 
11
25
 
12
26
  @dataclass
@@ -18,15 +32,20 @@ class HydrolixConfig:
18
32
 
19
33
  Required environment variables:
20
34
  HYDROLIX_HOST: The hostname of the Hydrolix server
21
- HYDROLIX_USER: The username for authentication
22
- HYDROLIX_PASSWORD: The password for authentication
23
35
 
24
36
  Optional environment variables (with defaults):
37
+ HYDROLIX_TOKEN: Service account token to the Hydrolix Server (this or user+password is required)
38
+ HYDROLIX_USER: The username for authentication (this or token is required)
39
+ HYDROLIX_PASSWORD: The password for authentication (this or token is required)
25
40
  HYDROLIX_PORT: The port number (default: 8088)
26
41
  HYDROLIX_VERIFY: Verify SSL certificates (default: true)
27
42
  HYDROLIX_CONNECT_TIMEOUT: Connection timeout in seconds (default: 30)
28
43
  HYDROLIX_SEND_RECEIVE_TIMEOUT: Send/receive timeout in seconds (default: 300)
29
44
  HYDROLIX_DATABASE: Default database to use (default: None)
45
+ HYDROLIX_PROXY_PATH: Path to be added to the host URL. For instance, for servers behind an HTTP proxy (default: None)
46
+ HYDROLIX_MCP_SERVER_TRANSPORT: MCP server transport method - "stdio", "http", or "sse" (default: stdio)
47
+ HYDROLIX_MCP_BIND_HOST: Host to bind the MCP server to when using HTTP or SSE transport (default: 127.0.0.1)
48
+ HYDROLIX_MCP_BIND_PORT: Port to bind the MCP server to when using HTTP or SSE transport (default: 8000)
30
49
  """
31
50
 
32
51
  def __init__(self):
@@ -49,15 +68,39 @@ class HydrolixConfig:
49
68
  return int(os.environ["HYDROLIX_PORT"])
50
69
  return 8088
51
70
 
71
+ @property
72
+ def service_account(self) -> bool:
73
+ """Determine if service account is enabled
74
+
75
+ Defaults to false.
76
+ Can be overridden if HYDROLIX_TOKEN environment variable.
77
+ """
78
+ return "HYDROLIX_TOKEN" in os.environ
79
+
80
+ @property
81
+ def service_account_token(self) -> str:
82
+ """Get the service account token
83
+
84
+ Defaults to None.
85
+ Can be overridden if HYDROLIX_TOKEN environment variable.
86
+ """
87
+ if "HYDROLIX_TOKEN" in os.environ:
88
+ return os.environ["HYDROLIX_TOKEN"]
89
+ return None
90
+
52
91
  @property
53
92
  def username(self) -> str:
54
93
  """Get the Hydrolix username."""
55
- return os.environ["HYDROLIX_USER"]
94
+ if "HYDROLIX_USER" in os.environ:
95
+ return os.environ["HYDROLIX_USER"]
96
+ return None
56
97
 
57
98
  @property
58
99
  def password(self) -> str:
59
100
  """Get the Hydrolix password."""
60
- return os.environ["HYDROLIX_PASSWORD"]
101
+ if "HYDROLIX_PASSWORD" in os.environ:
102
+ return os.environ["HYDROLIX_PASSWORD"]
103
+ return None
61
104
 
62
105
  @property
63
106
  def database(self) -> Optional[str]:
@@ -88,6 +131,43 @@ class HydrolixConfig:
88
131
  """
89
132
  return int(os.getenv("HYDROLIX_SEND_RECEIVE_TIMEOUT", "300"))
90
133
 
134
+ @property
135
+ def proxy_path(self) -> str:
136
+ return os.getenv("HYDROLIX_PROXY_PATH")
137
+
138
+ @property
139
+ def mcp_server_transport(self) -> str:
140
+ """Get the MCP server transport method.
141
+
142
+ Valid options: "stdio", "http", "sse"
143
+ Default: "stdio"
144
+ """
145
+ transport = os.getenv("HYDROLIX_MCP_SERVER_TRANSPORT", TransportType.STDIO.value).lower()
146
+
147
+ # Validate transport type
148
+ if transport not in TransportType.values():
149
+ valid_options = ", ".join(f'"{t}"' for t in TransportType.values())
150
+ raise ValueError(f"Invalid transport '{transport}'. Valid options: {valid_options}")
151
+ return transport
152
+
153
+ @property
154
+ def mcp_bind_host(self) -> str:
155
+ """Get the host to bind the MCP server to.
156
+
157
+ Only used when transport is "http" or "sse".
158
+ Default: "127.0.0.1"
159
+ """
160
+ return os.getenv("HYDROLIX_MCP_BIND_HOST", "127.0.0.1")
161
+
162
+ @property
163
+ def mcp_bind_port(self) -> int:
164
+ """Get the port to bind the MCP server to.
165
+
166
+ Only used when transport is "http" or "sse".
167
+ Default: 8000
168
+ """
169
+ return int(os.getenv("HYDROLIX_MCP_BIND_PORT", "8000"))
170
+
91
171
  def get_client_config(self) -> dict:
92
172
  """Get the configuration dictionary for clickhouse_connect client.
93
173
 
@@ -97,8 +177,6 @@ class HydrolixConfig:
97
177
  config = {
98
178
  "host": self.host,
99
179
  "port": self.port,
100
- "username": self.username,
101
- "password": self.password,
102
180
  "secure": True,
103
181
  "verify": self.verify,
104
182
  "connect_timeout": self.connect_timeout,
@@ -110,6 +188,15 @@ class HydrolixConfig:
110
188
  if self.database:
111
189
  config["database"] = self.database
112
190
 
191
+ if self.proxy_path:
192
+ config["proxy_path"] = self.proxy_path
193
+
194
+ if self.service_account:
195
+ config["access_token"] = self.service_account_token
196
+ else:
197
+ config["username"] = self.username
198
+ config["password"] = self.password
199
+
113
200
  return config
114
201
 
115
202
  def _validate_required_vars(self) -> None:
@@ -119,7 +206,11 @@ class HydrolixConfig:
119
206
  ValueError: If any required environment variable is missing.
120
207
  """
121
208
  missing_vars = []
122
- for var in ["HYDROLIX_HOST", "HYDROLIX_USER", "HYDROLIX_PASSWORD"]:
209
+ if self.service_account:
210
+ required_vars = ["HYDROLIX_HOST", "HYDROLIX_TOKEN"]
211
+ else:
212
+ required_vars = ["HYDROLIX_HOST", "HYDROLIX_USER", "HYDROLIX_PASSWORD"]
213
+ for var in required_vars:
123
214
  if var not in os.environ:
124
215
  missing_vars.append(var)
125
216