Skip to content

Split pkg/server/server.go into logical files#85

Merged
Slach merged 8 commits into
feature/unified-toolsfrom
feature/server-split
May 5, 2026
Merged

Split pkg/server/server.go into logical files#85
Slach merged 8 commits into
feature/unified-toolsfrom
feature/server-split

Conversation

@BorisTyshkevich
Copy link
Copy Markdown
Collaborator

Summary

Pure reorganization, no behavior changes. server.go had grown to ~3.1k lines with 89 functions spanning OAuth, JWE, client resolution, dynamic tools, OpenAPI handlers, query parsing, and settings. Splitting gives Auth0 work (and any future OAuth/IdP changes) a much smaller surface to land on.

Base is feature/unified-tools (PR #84), not main, to avoid conflicts with PR #84's ~800 line addition.

Layout

File Lines Contents
server.go 491 struct, constructor, Add/Register, HandleExecuteQuery, HandleReadOnlyQuery, context key constants
server_auth_oauth.go 548 OAuth validation, JWT parsing, JWKS/OpenID discovery
server_auth_jwe.go 99 JWE token extraction and claim parsing
server_client.go 308 ClickHouse client resolution from JWE/OAuth context
server_dynamic_tools.go 910 Discovery and handlers for dynamic read/write tools
server_openapi.go 415 OpenAPI REST handlers
server_query.go 150 SELECT detection + AST-based blocked-clause checks
server_resources.go 163 MCP resources and prompts
server_settings.go 169 tool_input_settings allowlist and parsing

Same package, same exported symbols. server_test.go stays as one file (test-only; split can come later if needed).

Test plan

  • go build ./...
  • go vet ./...
  • TESTCONTAINERS_RYUK_DISABLED=true go test ./pkg/server/ — all tests pass except TestOAuthOpenAPIFullFlow/complete_oauth_openapi_flow, which fails identically on the pre-split branch due to a sandbox isolator restriction on ExtraHosts (unrelated)
  • CI green on GHA runners

BorisTyshkevich and others added 8 commits April 17, 2026 17:27
Pure reorganization, no behavior changes. server.go grew to ~3.1k lines
with 89 functions spanning OAuth, JWE, client resolution, dynamic tools,
OpenAPI handlers, query parsing, and settings. Review and further work
(Auth0 OAuth flow) land on a much smaller surface now.

Layout:
- server.go (491 lines) — struct, constructor, Add/Register, HandleExecuteQuery,
  HandleReadOnlyQuery, context key constants
- server_auth_oauth.go (548) — OAuth validation, JWT parsing, JWKS/OpenID discovery
- server_auth_jwe.go (99) — JWE token extraction and claim parsing
- server_client.go (308) — ClickHouse client resolution from JWE/OAuth context
- server_dynamic_tools.go (910) — discovery and handlers for dynamic read/write tools
- server_openapi.go (415) — OpenAPI REST handlers
- server_query.go (150) — SELECT detection and AST-based blocked-clause checks
- server_resources.go (163) — MCP resources and prompts
- server_settings.go (169) — tool_input_settings allowlist and parsing

Verified with go build, go vet, and the full pkg/server test suite.
The only failing test (TestOAuthOpenAPIFullFlow/complete_oauth_openapi_flow)
fails identically on the pre-split branch due to a sandbox isolator
restriction on ExtraHosts — unrelated to the split.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ure/server-split

# Conflicts:
#	pkg/server/server.go
Extract auth/JWE, client, dynamic tools, query, resources, and settings
tests into separate files for maintainability; remove isSelectQuery from
server_query.go as it moved to the query test package.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Mirrors the existing JWE split: extracts all OAuth-related test
functions and helpers (mintSelfIssuedToken, testOAuthProvider,
TestOAuth*, TestValidateAuth, TestResolveOAuthJWKSURL, etc.) from
server_test.go into a dedicated server_auth_oauth_test.go file.
Removes now-unused imports (crypto/rand, crypto/rsa, sync, jose)
from server_test.go.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
'*' does not match branch names containing '/' in GitHub Actions patterns,
so PRs targeting feature/* branches were never triggering CI.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@Slach Slach merged commit afd1d07 into feature/unified-tools May 5, 2026
4 checks passed
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.

2 participants