Skip to content

feat: optionally read connection settings from clickhouse-client config.yaml - #204

Open
costela wants to merge 1 commit into
ClickHouse:mainfrom
costela:feat/clickhouse-client-config-fallback
Open

feat: optionally read connection settings from clickhouse-client config.yaml#204
costela wants to merge 1 commit into
ClickHouse:mainfrom
costela:feat/clickhouse-client-config-fallback

Conversation

@costela

@costela costela commented Jun 18, 2026

Copy link
Copy Markdown

Closes #203

Adds an opt-in fallback that reads ClickHouse connection settings from a clickhouse-client config.yaml, so users who already run clickhouse-client don't have to duplicate auth into CLICKHOUSE_* env vars.

Behavior

  • Activated only when CLICKHOUSE_CONFIG_FILE points at a YAML file. Env vars always take precedence.
  • Reads host, user, password, database, and secure.
  • port is intentionally ignoredclickhouse-client ports are native TCP (9000/9440), but this server uses the HTTP interface (8123/8443). Set CLICKHOUSE_PORT explicitly if needed.
  • Supports both top-level keys and connections_credentials named profiles, selected via CLICKHOUSE_CONNECTION.
  • The parsed file is cached and re-read when its mtime changes, so edits are picked up without a restart.

Changes

  • mcp_clickhouse/mcp_env.py: env-then-file resolution in the config accessors + a _file_settings() loader.
  • pyproject.toml: add pyyaml dependency.
  • README.md: document the two new env vars + a "Config file fallback" section.
  • tests/test_client_config_file.py: cover precedence, named connections, port exclusion, mtime invalidation, and error paths.

Disclaimer: 🤖 Generated with help from Claude Code

…ig.yaml

Add an opt-in fallback that reads ClickHouse connection settings from a
clickhouse-client config.yaml pointed at by CLICKHOUSE_CONFIG_FILE, so users
don't have to duplicate auth into CLICKHOUSE_* env vars. Env vars always take
precedence; only host/user/password/database/secure are read. The native-TCP
port is intentionally ignored since this server uses the HTTP interface.

Supports both top-level keys and connections_credentials named profiles
(selected via CLICKHOUSE_CONNECTION). The parsed file is cached and
re-read when its mtime changes, so edits are picked up without a restart.

Closes ClickHouse#203

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@costela
costela marked this pull request as ready for review June 18, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: optionally support reading clickhouse-client's config for auth

1 participant