Repository navigation
Refactor server internals into focused modules - #240
Merged
Merged
Conversation
chernser
approved these changes
Sep 18, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No functional blockers were found; only two minor ASCII punctuation fixes remain.
Pull request overview
Refactors the monolithic server implementation into focused modules while preserving MCP behavior and compatibility exports.
Changes:
- Separates authentication, transport, clients, queries, metadata, health, chDB, serialization, and executors.
- Makes operational state and worker pools assembly-owned.
- Updates tests and documentation for the new ownership boundaries.
File summaries
| File | Description |
|---|---|
mcp_clickhouse/mcp_server.py |
Assembles and registers server components. |
mcp_clickhouse/auth.py |
Owns authentication and dotenv handling. |
mcp_clickhouse/transport.py |
Owns secured HTTP/SSE construction. |
mcp_clickhouse/clients.py |
Owns client configuration, caching, and leases. |
mcp_clickhouse/queries.py |
Owns execution, validation, and cancellation. |
mcp_clickhouse/metadata.py |
Owns discovery and pagination. |
mcp_clickhouse/health.py |
Owns health probes and caching. |
mcp_clickhouse/chdb_backend.py |
Owns optional chDB state and execution. |
mcp_clickhouse/executors.py |
Defines assembly-owned worker pools. |
mcp_clickhouse/serialization.py |
Centralizes JSON result encoding. |
README.md |
Documents the new module layout. |
CHANGELOG.md |
Records internal import compatibility changes. |
AGENTS.md |
Updates the repository architecture guidance. |
.claude/agents/docs-drift-reviewer.md |
Updates documentation-review guidance. |
tests/conftest.py |
Updates health-cache cleanup ownership. |
tests/test_auth_config.py |
Targets extracted authentication helpers. |
tests/test_chdb_tool.py |
Targets assembly-owned chDB state. |
tests/test_client_cache.py |
Targets assembly-owned client caches and executors. |
tests/test_connection_errors.py |
Targets extracted client diagnostics. |
tests/test_context_config_override.py |
Updates client and metadata ownership references. |
tests/test_destructive_ops.py |
Targets extracted query guards. |
tests/test_grants_advisory.py |
Targets assembly-owned advisory state. |
tests/test_health_cache.py |
Targets extracted health state. |
tests/test_http_security_boundary.py |
Targets extracted auth and transport logic. |
tests/test_mcp_server.py |
Updates query-owner test patches. |
tests/test_optional_chdb.py |
Updates chDB and health ownership tests. |
tests/test_pagination.py |
Imports metadata models from their owner. |
tests/test_pagination_validation.py |
Updates pagination-owner references. |
tests/test_protocol_compat.py |
Updates query execution references. |
tests/test_query_cancellation.py |
Tests assembly-owned cancellation state. |
tests/test_query_parameters.py |
Targets extracted query and client helpers. |
tests/test_serialization.py |
Targets extracted serializers and chDB backend. |
tests/test_tls_config.py |
Targets extracted client settings. |
Review details
Suppressed comments (1)
mcp_clickhouse/clients.py:163
- Use ASCII punctuation here; the repository writing style prohibits em dashes in new code and user-facing messages.
"only — it is not MCP or ingress TLS. Use true for HTTPS database "
- Files reviewed: 33/34 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Over time
mcp_server.pyhad grown to nearly 3K lines and was getting hard to follow. This PR splits it into smaller modules and leaves ~180 lines in this file for startup, registration and cleanup. The README has a guide about the new layout.There aren't any new features. Tools, settings and documented Python imports still work the same.
If you're importing internals from
mcp_server, these names have moved. All the paths below are undermcp_clickhouse:The execution helpers and worker pools now belong to each server instance. They aren't standalone module exports or new public APIs.