mcp-hydrolix 0.1.0__tar.gz → 0.1.3__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.
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-hydrolix
3
+ Version: 0.1.3
4
+ Summary: An MCP server for Hydrolix.
5
+ Project-URL: Home, https://github.com/hydrolix/mcp-hydrolix
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.13
9
+ Requires-Dist: clickhouse-connect>=0.8.16
10
+ Requires-Dist: mcp[cli]>=1.3.0
11
+ Requires-Dist: pip-system-certs>=4.0
12
+ Requires-Dist: python-dotenv>=1.0.1
13
+ Requires-Dist: uvicorn>=0.34.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest; extra == 'dev'
16
+ Requires-Dist: ruff; extra == 'dev'
17
+ Description-Content-Type: text/markdown
18
+
19
+ # Hydrolix MCP Server
20
+ [![PyPI - Version](https://img.shields.io/pypi/v/mcp-hydrolix)](https://pypi.org/project/mcp-hydrolix)
21
+
22
+ An MCP server for Hydrolix.
23
+
24
+ ## Tools
25
+
26
+ * `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.
30
+
31
+ * `list_databases`
32
+ - List all databases on your Hydrolix cluster.
33
+
34
+ * `list_tables`
35
+ - List all tables in a database.
36
+ - Input: `database` (string): The name of the database.
37
+
38
+ ## Effective Usage
39
+
40
+ 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:
41
+
42
+ * 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 ...")
43
+ - This encourages the model to use the MCP tools available and minimizes hallucinations.
44
+ * 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
+ - 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
+
47
+ ## Configuration
48
+
49
+ 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
+
51
+ 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
+
53
+ MCP Server definition (JSON):
54
+
55
+ ```json
56
+ {
57
+ "command": "uv",
58
+ "args": [
59
+ "run",
60
+ "--with",
61
+ "mcp-hydrolix",
62
+ "--python",
63
+ "3.13",
64
+ "mcp-hydrolix"
65
+ ],
66
+ "env": {
67
+ "HYDROLIX_HOST": "<hydrolix-host>",
68
+ "HYDROLIX_USER": "<hydrolix-user>",
69
+ "HYDROLIX_PASSWORD": "<hydrolix-password>"
70
+ }
71
+ }
72
+ ```
73
+
74
+ MCP Server definition (YAML):
75
+
76
+ ```yaml
77
+ command: uv
78
+ args:
79
+ - run
80
+ - --with
81
+ - mcp-hydrolix
82
+ - --python
83
+ - "3.13"
84
+ - mcp-hydrolix
85
+ env:
86
+ HYDROLIX_HOST: <hydrolix-host>
87
+ HYDROLIX_USER: <hydrolix-user>
88
+ HYDROLIX_PASSWORD: <hydrolix-password>
89
+ ```
90
+
91
+ ### Configuration Example (Claude Desktop)
92
+
93
+ 1. Open the Claude Desktop configuration file located at:
94
+ - On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
95
+ - On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
96
+
97
+ 2. Add a `mcp-hydrolix` server entry to the `mcpServers` config block:
98
+
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "mcp-hydrolix": {
103
+ "command": "uv",
104
+ "args": [
105
+ "run",
106
+ "--with",
107
+ "mcp-hydrolix",
108
+ "--python",
109
+ "3.13",
110
+ "mcp-hydrolix"
111
+ ],
112
+ "env": {
113
+ "HYDROLIX_HOST": "<hydrolix-host>",
114
+ "HYDROLIX_USER": "<hydrolix-user>",
115
+ "HYDROLIX_PASSWORD": "<hydrolix-password>"
116
+ }
117
+ }
118
+ }
119
+ }
120
+ ```
121
+
122
+ 3. Update the environment variable definitions to point to your Hydrolix cluster.
123
+
124
+ 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`.
125
+
126
+ 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.
127
+
128
+ ### Environment Variables
129
+
130
+ 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.
131
+
132
+ #### Required Variables
133
+ * `HYDROLIX_HOST`: The hostname of your Hydrolix server
134
+ * `HYDROLIX_USER`: The username for authentication
135
+ * `HYDROLIX_PASSWORD`: The password for authentication
136
+
137
+ #### Optional Variables
138
+ * `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
141
+ * `HYDROLIX_VERIFY`: Enable/disable SSL certificate verification
142
+ - Default: `"true"`
143
+ - Set to `"false"` to disable certificate verification (not recommended for production)
144
+ * `HYDROLIX_DATABASE`: Default database to use
145
+ - Default: None (uses server default)
146
+ - Set this to automatically connect to a specific database
@@ -0,0 +1,128 @@
1
+ # Hydrolix MCP Server
2
+ [![PyPI - Version](https://img.shields.io/pypi/v/mcp-hydrolix)](https://pypi.org/project/mcp-hydrolix)
3
+
4
+ An MCP server for Hydrolix.
5
+
6
+ ## Tools
7
+
8
+ * `run_select_query`
9
+ - Execute SQL queries on your Hydrolix cluster.
10
+ - Input: `sql` (string): The SQL query to execute.
11
+ - All Hydrolix queries are run with `readonly = 1` to ensure they are safe.
12
+
13
+ * `list_databases`
14
+ - List all databases on your Hydrolix cluster.
15
+
16
+ * `list_tables`
17
+ - List all tables in a database.
18
+ - Input: `database` (string): The name of the database.
19
+
20
+ ## Effective Usage
21
+
22
+ 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:
23
+
24
+ * 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 ...")
25
+ - This encourages the model to use the MCP tools available and minimizes hallucinations.
26
+ * 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.
27
+ - 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/)
28
+
29
+ ## Configuration
30
+
31
+ 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.
32
+
33
+ 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.
34
+
35
+ MCP Server definition (JSON):
36
+
37
+ ```json
38
+ {
39
+ "command": "uv",
40
+ "args": [
41
+ "run",
42
+ "--with",
43
+ "mcp-hydrolix",
44
+ "--python",
45
+ "3.13",
46
+ "mcp-hydrolix"
47
+ ],
48
+ "env": {
49
+ "HYDROLIX_HOST": "<hydrolix-host>",
50
+ "HYDROLIX_USER": "<hydrolix-user>",
51
+ "HYDROLIX_PASSWORD": "<hydrolix-password>"
52
+ }
53
+ }
54
+ ```
55
+
56
+ MCP Server definition (YAML):
57
+
58
+ ```yaml
59
+ command: uv
60
+ args:
61
+ - run
62
+ - --with
63
+ - mcp-hydrolix
64
+ - --python
65
+ - "3.13"
66
+ - mcp-hydrolix
67
+ env:
68
+ HYDROLIX_HOST: <hydrolix-host>
69
+ HYDROLIX_USER: <hydrolix-user>
70
+ HYDROLIX_PASSWORD: <hydrolix-password>
71
+ ```
72
+
73
+ ### Configuration Example (Claude Desktop)
74
+
75
+ 1. Open the Claude Desktop configuration file located at:
76
+ - On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
77
+ - On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
78
+
79
+ 2. Add a `mcp-hydrolix` server entry to the `mcpServers` config block:
80
+
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "mcp-hydrolix": {
85
+ "command": "uv",
86
+ "args": [
87
+ "run",
88
+ "--with",
89
+ "mcp-hydrolix",
90
+ "--python",
91
+ "3.13",
92
+ "mcp-hydrolix"
93
+ ],
94
+ "env": {
95
+ "HYDROLIX_HOST": "<hydrolix-host>",
96
+ "HYDROLIX_USER": "<hydrolix-user>",
97
+ "HYDROLIX_PASSWORD": "<hydrolix-password>"
98
+ }
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ 3. Update the environment variable definitions to point to your Hydrolix cluster.
105
+
106
+ 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`.
107
+
108
+ 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.
109
+
110
+ ### Environment Variables
111
+
112
+ 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.
113
+
114
+ #### Required Variables
115
+ * `HYDROLIX_HOST`: The hostname of your Hydrolix server
116
+ * `HYDROLIX_USER`: The username for authentication
117
+ * `HYDROLIX_PASSWORD`: The password for authentication
118
+
119
+ #### Optional Variables
120
+ * `HYDROLIX_PORT`: The port number of your Hydrolix server
121
+ - Default: `8088`
122
+ - Usually doesn't need to be set unless using a non-standard port
123
+ * `HYDROLIX_VERIFY`: Enable/disable SSL certificate verification
124
+ - Default: `"true"`
125
+ - Set to `"false"` to disable certificate verification (not recommended for production)
126
+ * `HYDROLIX_DATABASE`: Default database to use
127
+ - Default: None (uses server default)
128
+ - Set this to automatically connect to a specific database
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://glama.ai/mcp/schemas/server.json",
3
+ "maintainers": [
4
+ "aggarwaa",
5
+ "dsztykman",
6
+ "emanb29"
7
+ ]
8
+ }
@@ -127,5 +127,17 @@ class HydrolixConfig:
127
127
  raise ValueError(f"Missing required environment variables: {', '.join(missing_vars)}")
128
128
 
129
129
 
130
- # Global instance for easy access
131
- config = HydrolixConfig()
130
+ # Global instance placeholder for the singleton pattern
131
+ _CONFIG_INSTANCE = None
132
+
133
+
134
+ def get_config():
135
+ """
136
+ Gets the singleton instance of HydrolixConfig.
137
+ Instantiates it on the first call.
138
+ """
139
+ global _CONFIG_INSTANCE
140
+ if _CONFIG_INSTANCE is None:
141
+ # Instantiate the config object here, ensuring load_dotenv() has likely run
142
+ _CONFIG_INSTANCE = HydrolixConfig()
143
+ return _CONFIG_INSTANCE
@@ -8,7 +8,7 @@ from clickhouse_connect.driver.binding import quote_identifier, format_query_val
8
8
  from dotenv import load_dotenv
9
9
  from mcp.server.fastmcp import FastMCP
10
10
 
11
- from mcp_hydrolix.mcp_env import config
11
+ from mcp_hydrolix.mcp_env import get_config
12
12
 
13
13
  MCP_SERVER_NAME = "mcp-hydrolix"
14
14
 
@@ -56,10 +56,11 @@ def list_tables(database: str, like: str = None):
56
56
 
57
57
  # Get all table comments in one query
58
58
  table_comments_query = (
59
- f"SELECT name, comment FROM system.tables WHERE database = {format_query_value(database)}"
59
+ f"SELECT name, comment, primary_key FROM system.tables WHERE database = {format_query_value(database)} and engine = 'TurbineStorage' and total_rows > 0"
60
60
  )
61
61
  table_comments_result = client.query(table_comments_query)
62
62
  table_comments = {row[0]: row[1] for row in table_comments_result.result_rows}
63
+ primary_keys = {row[0]: row[2] for row in table_comments_result.result_rows}
63
64
 
64
65
  # Get all column comments in one query
65
66
  column_comments_query = f"SELECT table, name, comment FROM system.columns WHERE database = {format_query_value(database)}"
@@ -98,6 +99,7 @@ def list_tables(database: str, like: str = None):
98
99
  "comment": table_comments.get(table),
99
100
  "columns": columns,
100
101
  "create_table_query": create_table_result,
102
+ "primary_key": primary_keys.get(table)
101
103
  }
102
104
 
103
105
  tables = []
@@ -212,7 +214,7 @@ def run_select_query(query: str):
212
214
 
213
215
 
214
216
  def create_hydrolix_client():
215
- client_config = config.get_client_config()
217
+ client_config = get_config().get_client_config()
216
218
  logger.info(
217
219
  f"Creating Hydrolix client connection to {client_config['host']}:{client_config['port']} "
218
220
  f"as {client_config['username']} "
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mcp-hydrolix"
3
- version = "0.1.0"
3
+ version = "0.1.3"
4
4
  description = "An MCP server for Hydrolix."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -10,7 +10,7 @@ dependencies = [
10
10
  "mcp[cli]>=1.3.0",
11
11
  "python-dotenv>=1.0.1",
12
12
  "uvicorn>=0.34.0",
13
- "clickhouse-connect>=0.8.0",
13
+ "clickhouse-connect>=0.8.16",
14
14
  "pip-system-certs>=4.0",
15
15
  ]
16
16