Skip to content

Conversation

@SimplyLiz
Copy link
Owner

Summary

  • MCP server now responds to initialize handshake in ~0.6s instead of 43+ seconds
  • Engine (SCIP index) is loaded lazily on first tool call, not during startup
  • Improved ckb setup UX for Claude Code configuration

Problem

The MCP server was loading the entire SCIP index synchronously before responding to the initialize handshake. For large codebases (e.g., 48MB index), this took 43+ seconds, causing Claude Code's health check to timeout and report "Failed to connect".

Changes

Lazy Engine Loading (internal/mcp/server.go)

  • Add NewMCPServerLazy() that accepts an engine loader function
  • Engine is created on first tool call that needs it
  • MCP handshake completes immediately

MCP Command (cmd/ckb/mcp.go)

  • Use lazy loading path for all scenarios
  • Temporarily disable multi-repo mode (TODO: add lazy support)

Setup Command (cmd/ckb/setup.go)

  • Detect if CKB is already configured correctly (no action needed)
  • Warn when configured path differs from current binary
  • Show note when switching between npx and local binary
  • Automatically update config instead of failing with "already exists"

Test plan

  • ckb setup --tool claude-code --global works when not configured
  • ckb setup --tool claude-code --global shows "already configured" when same path
  • ckb setup --tool claude-code --global warns and updates when path differs
  • claude mcp list shows CKB as connected (was failing before)
  • MCP handshake completes in <1s (was 43s)

🤖 Generated with Claude Code

MCP server was taking 43+ seconds to respond to initialize handshake
because it loaded the entire SCIP index synchronously before starting.

Changes:
- Add NewMCPServerLazy() that accepts an engine loader function
- Engine is now loaded on first tool call, not during startup
- MCP handshake completes in ~0.6s instead of 43s
- Temporarily disable multi-repo mode to use lazy path everywhere

Also improves `ckb setup` for Claude Code:
- Detect if CKB is already configured correctly (no action needed)
- Warn when configured path differs from current binary
- Show note when switching between npx and local binary
- Automatically update config instead of failing with "already exists"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link

🟡 Change Impact Analysis

Metric Value
Risk Level MEDIUM 🟡
Files Changed 3
Symbols Changed 106
Directly Affected 1
Transitively Affected 73

Blast Radius: 0 modules, 1 files, 74 unique callers

📝 Changed Symbols (106)
Symbol File Type Confidence
EngineLoader internal/mcp/server.go modified 100%
MCPServer#engineErr internal/mcp/server.go modified 100%
MCPServer#engineLoader internal/mcp/server.go modified 100%
MCPServer#engineOnce internal/mcp/server.go modified 100%
NewMCPServerLazy cmd/ckb/mcp.go modified 100%
attachments cmd/ckb/setup.go modified 100%
claudeConfigEntry cmd/ckb/setup.go modified 100%
claudeConfigEntry#Args cmd/ckb/setup.go modified 100%
claudeConfigEntry#Command cmd/ckb/setup.go modified 100%
claudeConfigEntry#Type cmd/ckb/setup.go modified 100%
claudeMcpAdd cmd/ckb/setup.go modified 100%
data internal/mcp/server.go modified 100%
err cmd/ckb/setup.go modified 100%
err cmd/ckb/setup.go modified 100%
err cmd/ckb/setup.go modified 100%
+91 more
🎯 Affected Downstream (20)
Symbol Module Distance Kind
unknown `` 1 type-dependency
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/cmd/ckb/runMCP(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#GetEngine(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#getIndexStaleness(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#getTelemetryStorage(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#streamFindReferences(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#streamSearchSymbols(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolAnalyzeChange(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolAnalyzeCoupling(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolAnalyzeImpact(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolAnnotateModule(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolAuditRisk(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolBatchGet(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolBatchSearch(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolCancelJob(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolCheckDocStaleness(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolCompareAPI(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolDoctor(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolExplainFile(). `` 2 transitive-caller
scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#toolExplainOrigin(). `` 2 transitive-caller

Recommendations

  • ⚠️ test: Significant transitive impact (73 symbols). Run comprehensive test suite.
    • Action: Run full test suite before merging

⚠️ Index is 0 commit(s) behind HEAD. Results may be incomplete.


Generated by CKB

@github-actions
Copy link

🔐 Security Audit Results

⚠️ Security gate passed with warnings - 7 issue(s) found (review recommended)

Category Findings
🔑 Secrets ✅ 0
🛡️ SAST ✅ 0
📦 Dependencies ⚠️ 7
📜 Licenses ⚠️ 119 non-permissive

📦 Dependency Vulnerabilities

Found 7 vulnerability(ies) across 2 scanner(s)

Details

Trivy (4 findings)

  • CVE-2026-22036 (MEDIUM): undici - undici: Undici: Denial of Service via excessive de...
  • CVE-2025-54410 (LOW): github.com/docker/docker - github.com/moby/moby: Moby's Firewalld reload remo...
  • GHSA-vrw8-fxc6-2r93 (MEDIUM): github.com/go-chi/chi/v5 - chi Allows Host Header Injection which Leads to Op...
  • CVE-2025-47908 (MEDIUM): github.com/rs/cors - github.com/rs/cors: Denial of service via maliciou...

OSV-Scanner (3 findings)

  • github.com/docker/docker: 2 vulnerabilities
  • github.com/go-chi/chi/v5: 1 vulnerabilities
  • github.com/rs/cors: 2 vulnerabilities

📜 License Issues

Found 119 non-permissive license(s)

Details
  • github.com/BurntSushi/toml: MIT (notice)
  • github.com/google/uuid: BSD-3-Clause (notice)
  • github.com/klauspost/compress: Apache-2.0 (notice)
  • github.com/klauspost/compress: BSD-3-Clause (notice)
  • github.com/klauspost/compress: MIT (notice)
  • github.com/pelletier/go-toml/v2: MIT (notice)
  • github.com/smacker/go-tree-sitter: MIT (notice)
  • github.com/sourcegraph/go-diff: MIT (notice)
  • github.com/sourcegraph/scip: Apache-2.0 (notice)
  • github.com/spf13/cobra: Apache-2.0 (notice)
  • ... and 109 more

Generated by CKB Security Audit | View Details | Security Tab

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 0% with 92 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/ckb/setup.go 0.0% 58 Missing ⚠️
internal/mcp/server.go 0.0% 28 Missing ⚠️
cmd/ckb/mcp.go 0.0% 6 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.0%) is below the target coverage (30.0%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop    #123     +/-   ##
=========================================
- Coverage     45.1%   45.0%   -0.1%     
=========================================
  Files          350     350             
  Lines        59747   59818     +71     
=========================================
+ Hits         26957   26961      +4     
- Misses       30963   31031     +68     
+ Partials      1827    1826      -1     
Flag Coverage Δ
unit 45.0% <0.0%> (-0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

CKB Analysis

Risk Files +181 -29 Modules

🎯 106 changed → 73 affected · 🔥 3 hotspots · 📊 3 complex · 📚 143 stale

Risk factors: Touches 3 hotspot(s)

Metric Value
Impact Analysis 106 symbols → 73 affected 🟡
Doc Coverage 9.090909090909092% ⚠️
Complexity 3 violations ⚠️
Coupling 0 gaps
Blast Radius 0 modules, 1 files
Index indexed (7s) 🆕
🎯 Change Impact Analysis · 🟡 MEDIUM · 106 changed → 20 affected
Metric Value
Symbols Changed 106
Directly Affected 1
Transitively Affected 73
Modules in Blast Radius 0
Files in Blast Radius 1

Symbols changed in this PR:

Downstream symbols affected:
Direct callers (1):

  • unknown
    Transitive callers (19):
  • scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/cmd/ckb/runMCP(). (depth 2)
  • scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#GetEngine(). (depth 2)
  • scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#getIndexStaleness(). (depth 2)
  • scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#getTelemetryStorage(). (depth 2)
  • scip-go gomod github.com/SimplyLiz/CodeMCP c603e225f436 github.com/SimplyLiz/CodeMCP/internal/mcp/MCPServer#streamFindReferences(). (depth 2)
  • … and 14 more transitive callers

Recommendations:

  • ⚠️ Significant transitive impact (73 symbols). Run comprehensive test suite.
    • Action: Run full test suite before merging

⚠️ Index is undefined commit(s) behind HEAD. Results may be incomplete. Run ckb index to refresh.

🔥 Hotspots · 3 volatile files
File Churn Score
cmd/ckb/mcp.go 10.46
cmd/ckb/setup.go 8.53
internal/mcp/server.go 9.84
📊 Complexity · 3 violations
File Cyclomatic Cognitive
cmd/ckb/mcp.go ⚠️ 29 ⚠️ 66
cmd/ckb/setup.go ⚠️ 27 ⚠️ 52
internal/mcp/server.go 9 ⚠️ 22
💡 Quick wins · 10 suggestions
📚 Stale docs · 143 broken references

Generated by CKB · Run details

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