Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ The following environment variables are used to configure the ClickHouse and chD
* `CLICKHOUSE_CONNECT_TIMEOUT`: Connection timeout in seconds
* Default: `"30"`
* Increase this value if you experience connection timeouts
* `CLICKHOUSE_SEND_RECEIVE_TIMEOUT`: Send/receive timeout in seconds
* Default: `"300"`
* Increase this value for long-running queries
* `CLICKHOUSE_SEND_RECEIVE_TIMEOUT`: Send/receive timeout in seconds for the underlying HTTP connection
* Default: automatically set to `CLICKHOUSE_MCP_QUERY_TIMEOUT + 5` so worker threads unblock shortly after a query timeout
* If explicitly set, the value is used as-is (e.g. `"300"` for long-running queries)
* `CLICKHOUSE_DATABASE`: Default database to use
* Default: None (uses server default)
* Set this to automatically connect to a specific database
Expand All @@ -503,9 +503,14 @@ The following environment variables are used to configure the ClickHouse and chD
* `CLICKHOUSE_MCP_BIND_PORT`: Port to bind the MCP server to when using HTTP or SSE transport
* Default: `"8000"`
* Only used when transport is `"http"` or `"sse"`
* `CLICKHOUSE_MCP_QUERY_TIMEOUT`: Timeout in seconds for SELECT tools
* `CLICKHOUSE_MCP_QUERY_TIMEOUT`: Timeout in seconds for query tool calls
* Default: `"30"`
* Increase this if you see `Query timed out after ...` errors for heavy queries
* When a query times out, the server issues a `KILL QUERY` on the ClickHouse server to cancel it
* Unless `CLICKHOUSE_SEND_RECEIVE_TIMEOUT` is explicitly set, the HTTP read timeout is automatically aligned to this value plus a small buffer, so worker threads unblock shortly after a timeout
* `CLICKHOUSE_MCP_MAX_WORKERS`: Maximum number of concurrent query worker threads
* Default: `"10"`
* Increase if your workload requires many concurrent tool calls
* `CLICKHOUSE_MCP_AUTH_TOKEN`: Authentication token for HTTP/SSE transports
* Default: None
* **Required** when using HTTP or SSE transport (unless `CLICKHOUSE_MCP_AUTH_DISABLED=true`)
Expand Down
4 changes: 4 additions & 0 deletions mcp_clickhouse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from .mcp_server import (
create_clickhouse_client,
_clear_client_cache,
_resolve_client_config,
list_databases,
Comment on lines 3 to 7
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__init__.py exports _clear_client_cache and _resolve_client_config via __all__, effectively making private, underscore-prefixed helpers part of the public package API. This makes future refactors harder and encourages external callers to rely on internals. Prefer keeping these unexported (tests can import from mcp_clickhouse.mcp_server) or renaming/dropping the underscore if they’re intended to be public API.

Copilot uses AI. Check for mistakes.
list_tables,
run_query,
Expand All @@ -27,6 +29,8 @@
"list_tables",
"run_query",
"create_clickhouse_client",
"_clear_client_cache",
"_resolve_client_config",
"create_chdb_client",
"run_chdb_select_query",
"chdb_initial_prompt",
Expand Down
9 changes: 9 additions & 0 deletions mcp_clickhouse/mcp_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class MCPServerConfig:
CLICKHOUSE_MCP_BIND_HOST: Bind host for HTTP/SSE (default: 127.0.0.1)
CLICKHOUSE_MCP_BIND_PORT: Bind port for HTTP/SSE (default: 8000)
CLICKHOUSE_MCP_QUERY_TIMEOUT: SELECT tool timeout in seconds (default: 30)
CLICKHOUSE_MCP_MAX_WORKERS: Maximum thread pool workers for query execution (default: 10)
CLICKHOUSE_MCP_AUTH_TOKEN: Authentication token for HTTP/SSE transports (required
unless CLICKHOUSE_MCP_AUTH_DISABLED=true)
CLICKHOUSE_MCP_AUTH_DISABLED: Disable authentication (default: false, use
Expand All @@ -317,6 +318,14 @@ def bind_port(self) -> int:
def query_timeout(self) -> int:
return int(os.getenv("CLICKHOUSE_MCP_QUERY_TIMEOUT", "30"))

@property
def max_workers(self) -> int:
"""Maximum thread pool workers for query execution.

Default: 10
"""
return int(os.getenv("CLICKHOUSE_MCP_MAX_WORKERS", "10"))

@property
def auth_token(self) -> Optional[str]:
"""Get the authentication token for HTTP/SSE transports."""
Expand Down
Loading
Loading