-
-
Notifications
You must be signed in to change notification settings - Fork 11
MCP Integration
CKB implements the Model Context Protocol (MCP) to provide code intelligence tools to AI assistants like Claude.
MCP is a standard protocol that allows AI assistants to interact with external tools and data sources. CKB exposes its code intelligence capabilities as MCP tools.
# Start MCP server (stdio mode)
ckb mcp
# Start with verbose logging
ckb mcp --verboseGet detailed information about a symbol.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
symbolId |
string | Yes | Stable symbol ID |
Example:
{
"tool": "getSymbol",
"arguments": {
"symbolId": "ckb:repo:sym:abc123"
}
}Response:
{
"symbol": {
"stableId": "ckb:repo:sym:abc123",
"name": "ProcessData",
"kind": "function",
"signature": "func ProcessData(input Input) (Output, error)",
"location": {
"fileId": "internal/service/processor.go",
"startLine": 42
},
"moduleId": "internal/service",
"visibility": "public"
}
}Search for symbols matching a query.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
query |
string | Yes | Search query |
scope |
string | No | Module to search within |
kinds |
string[] | No | Symbol kinds to include |
limit |
number | No | Max results (default: 50) |
Example:
{
"tool": "searchSymbols",
"arguments": {
"query": "Process",
"kinds": ["function", "method"],
"limit": 10
}
}Find all references to a symbol.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
symbolId |
string | Yes | Stable symbol ID |
scope |
string | No | Module to search within |
merge |
string | No | Backend merge strategy: "prefer-first" (default) or "union" |
limit |
number | No | Max references (default: 100) |
Example:
{
"tool": "findReferences",
"arguments": {
"symbolId": "ckb:repo:sym:abc123",
"merge": "prefer-first",
"limit": 100
}
}Get codebase architecture overview.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
depth |
number | No | Module depth (default: 2) |
includeExternal |
boolean | No | Include external deps |
Example:
{
"tool": "getArchitecture",
"arguments": {
"depth": 2
}
}Analyze the impact of changing a symbol.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
symbolId |
string | Yes | Stable symbol ID |
depth |
number | No | Analysis depth (default: 2) |
includeTests |
boolean | No | Include test impacts |
Example:
{
"tool": "analyzeImpact",
"arguments": {
"symbolId": "ckb:repo:sym:abc123",
"depth": 3
}
}Get system status.
Parameters: None
Example:
{
"tool": "getStatus",
"arguments": {}
}Run diagnostic checks.
Parameters: None
Example:
{
"tool": "doctor",
"arguments": {}
}Add CKB to your Claude Desktop MCP settings:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"ckb": {
"command": "/path/to/ckb",
"args": ["mcp"],
"cwd": "/path/to/your/repo"
}
}
}Configure multiple CKB instances for different repos:
{
"mcpServers": {
"ckb-frontend": {
"command": "/path/to/ckb",
"args": ["mcp"],
"cwd": "/path/to/frontend-repo"
},
"ckb-backend": {
"command": "/path/to/ckb",
"args": ["mcp"],
"cwd": "/path/to/backend-repo"
}
}
}CKB MCP server uses stdio transport:
- Input: JSON-RPC messages on stdin
- Output: JSON-RPC messages on stdout
- Logs: stderr (when --verbose)
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "searchSymbols",
"arguments": {
"query": "ProcessData"
}
}
}Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "{\"results\": [...]}"
}
]
}
}Errors are returned with CKB error codes:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32000,
"message": "Symbol not found",
"data": {
"ckbCode": "SYMBOL_NOT_FOUND",
"suggestedFixes": [...]
}
}
}- Start with getStatus - Check system health before queries
- Use searchSymbols first - Find symbol IDs before detailed queries
- Follow drilldowns - Use suggested queries for deeper exploration
- Respect truncation - Large results are truncated with suggestions
- Handle errors gracefully - Check suggestedFixes for recovery
1. getStatus()
→ Check backends are available
2. searchSymbols("UserService")
→ Get symbol ID: ckb:repo:sym:abc123
3. getSymbol("ckb:repo:sym:abc123")
→ Get full symbol details
4. findReferences("ckb:repo:sym:abc123")
→ Find all usages
5. analyzeImpact("ckb:repo:sym:abc123")
→ Understand change risk
# Check CKB is installed
which ckb
# Test manually
echo '{"jsonrpc":"2.0","id":1,"method":"initialize"}' | ckb mcp# Verify CKB is initialized in the repo
ls -la .ckb/
# Initialize if needed
ckb init- Check if SCIP index exists
- Run
ckb doctorto diagnose - Consider reducing query scope
Check Claude Desktop logs:
# macOS
tail -f ~/Library/Logs/Claude/mcp*.log# Start server
ckb mcp --verbose 2>mcp.log &
# Send test request
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | ckb mcp
# Check logs
tail -f mcp.logEnable verbose logging:
ckb mcp --verboseLogs include:
- Incoming requests
- Tool invocations
- Response times
- Errors