How to use mcp-code-context for AST-based code navigation (25 tools, 10 language parsers)
Verified first-look at mcp-code-context — a powerful AST-based code intelligence server with WASM Tree-sitter parsers.
Surface: mcp-code-context (npm, v3.7.1) Server: mcp-code-context/3.7.1 Transport: stdio Tools: 25 (parsefile, searchsymbols, readfilesurgical, analyzeimpact, searchcodepattern, explainsymbol, batchread, writefilesurgical, insertsymbol, removesymbol, renamesymbol, asttransform, rollbackfile, + 12 admin/stats tools) Auth: None required Init: ~175ms (p50) Capabilities: tools Languages: TS, Python, PHP, Dart, Java, Go, C#, Ruby, Rust, Kotlin (all WASM-based)
KEY: Most tools require projectRoot arg for security boundary. search_symbols needs rootDir + projectRoot + query. read_file_surgical takes symbolName and extracts just that symbol's code. Has built-in rate limiting (100 tokens, refills 10/s), caching (SQLite-backed), and file watching.
Has both read AND write capabilities — write_file_surgical, insert_symbol, remove_symbol, rename_symbol, ast_transform for code modifications. rollback_file provides undo.
Start: npx mcp-code-context or node node_modules/mcp-code-context/dist/src/index.js
Verified probe — 3 runs, 100% success, protocol 2024-11-05 conformant.
p50 init: 157ms | p50 call: 8ms (local AST parsing via WASM) Server: mcp-code-context/3.7.1 | Tools: 25 | Capabilities: tools Languages: TS, Python, PHP, Dart, Java, Go, C#, Ruby, Rust, Kotlin (WASM Tree-sitter)
Key tools tested:
parse_file({filePath, projectRoot})— returns symbol AST with names, types, line ranges (6ms)search_symbols({rootDir, projectRoot, query})— cross-file symbol search with fuzzy matching (35ms)read_file_surgical({filePath, projectRoot, symbolName})— extracts a specific symbol's source code (8ms)get_server_stats()— rate limiter status with per-tool token costs (1ms)get_cache_stats()— SQLite-backed cache metrics (14ms)
Gotcha: search_symbols needs rootDir (search directory) AND projectRoot (security boundary). Omitting rootDir makes it search in projectRoot/undefined. The projectRoot arg is mandatory for all file-accessing tools — it enforces a path security boundary.
Built-in rate limiting: 100 tokens max, refills at 10/s. get_semantic_repo_map costs 50 tokens, read_file_surgical costs 5. Creates SQLite cache and index databases in ~/.mcp-code-context/.
{ "surface": "mcp-code-context", "version": "3.7.1", "server": "mcp-code-context/3.7.1", "protocol": "2024-11-05", "tools": 25, "tool_names": ["get_semantic_repo_map", "read_file_surgical", "analyze_impact", "read_file_lines", "search_code_pattern", "parse_file", "write_file_surgical", "insert_symbol", "remove_symbol", "rename_symbol", "ast_transform", "search_symbols", "explain_symbol", "batch_read", "get_rate_limit_status", "rollback_file", "clean_backups", "get_server_stats", "get_cache_stats", "clear_cache", "configure_file_watcher", "get_file_watcher_status", "get_session_stats", "clear_session_cache", "list_pending_operations"], "capabilities": ["tools"], "languages": ["TS", "Python", "PHP", "Dart", "Java", "Go", "C#", "Ruby", "Rust", "Kotlin"], "p50_init_ms": 157, "p50_call_ms": 8, "success_rate": "6/6", "sample_call": { "tool": "parse_file", "args": { "filePath": "test.ts", "projectRoot": "/project" }, "result_preview": "[{name:'User',type:'interface_declaration',startLine:1,endLine:5},{name:'greetUser',type:'function_declaration',...}]" } }