Skip to content

Commit 271eed1

Browse files
committed
chore: add default value to CHDB_DATA_PATH
1 parent e407f52 commit 271eed1

File tree

5 files changed

+164
-148
lines changed

5 files changed

+164
-148
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
CLICKHOUSE_SECURE: "false"
4040
CLICKHOUSE_VERIFY: "false"
4141
CHDB_ENABLED: "true"
42-
CHDB_DATA_PATH: ":memory:"
4342
run: |
4443
uv run pytest tests
4544

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ The following environment variables are used to configure the ClickHouse and chD
224224
* Default: `"false"`
225225
* Set to `"true"` to enable chDB tools
226226
* `CHDB_DATA_PATH`: The path to the chDB data directory
227-
* Required when `CHDB_ENABLED=true`
228-
* Use `:memory:` for in-memory database (recommended for testing)
227+
* Default: `":memory:"` (in-memory database)
228+
* Use `:memory:` for in-memory database
229229
* Use a file path for persistent storage (e.g., `/path/to/chdb/data`)
230230

231231
#### Example Configurations
@@ -271,7 +271,7 @@ For chDB only (in-memory):
271271
# chDB configuration
272272
CHDB_ENABLED=true
273273
CLICKHOUSE_ENABLED=false
274-
CHDB_DATA_PATH=:memory:
274+
# CHDB_DATA_PATH defaults to :memory:
275275
```
276276

277277
For chDB with persistent storage:

mcp_clickhouse/mcp_env.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def enabled(self) -> bool:
181181
@property
182182
def data_path(self) -> str:
183183
"""Get the chDB data path."""
184-
return os.environ["CHDB_DATA_PATH"]
184+
return os.getenv("CHDB_DATA_PATH", ":memory:")
185185

186186
def get_client_config(self) -> dict:
187187
"""Get the configuration dictionary for chDB client.
@@ -199,8 +199,7 @@ def _validate_required_vars(self) -> None:
199199
Raises:
200200
ValueError: If any required environment variable is missing.
201201
"""
202-
if self.enabled and "CHDB_DATA_PATH" not in os.environ:
203-
raise ValueError("Missing required environment variable: CHDB_DATA_PATH")
202+
pass
204203

205204

206205
# Global instance placeholders for the singleton pattern

mcp_clickhouse/mcp_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ def _init_chdb_client():
325325

326326
if get_chdb_config().enabled:
327327
_chdb_client = _init_chdb_client()
328-
atexit.register(lambda: _chdb_client.close() if _chdb_client is not None else None)
328+
if _chdb_client:
329+
atexit.register(lambda: _chdb_client.close())
329330

330331
mcp.add_tool(run_chdb_select_query)
331332
chdb_prompt = Prompt.from_function(

0 commit comments

Comments
 (0)