A Model Context Protocol (MCP) server that provides intelligent code analysis and context retrieval for AI coding assistants.
Code Intelligence MCP Server enhances AI coding assistants with deep codebase understanding through:
- Semantic Search: Find code by meaning, not just keywords
- Graph-RAG: Context-aware code retrieval using knowledge graphs
- Call Chain Analysis: Trace function dependencies and impacts
- Smart Context: Automatically inject relevant code snippets into AI conversations
Perfect for use with Claude Code, Cline, or any MCP-compatible AI assistant.
Via npm (recommended):
npm install -g @ozbombor/code-intelligence-mcp
Via git:
git clone https://github.com/Darkbluelr/code-intelligence-mcp.git
cd code-intelligence-mcp
./install.sh- Node.js >= 18.0.0
- Bash shell
- ripgrep (optional, for faster search)
- jq (optional, for JSON processing)
As MCP Server (recommended):
Add to your MCP client configuration:
{
"mcpServers": {
"code-intelligence": {
"command": "code-intelligence-mcp",
"args": []
}
}
}Command Line:
ci-search "find authentication code"
ci-search --help# Natural language queries ci-search "how does user authentication work"
# Get relevant context with smart pruning ci_graph_rag --query "fix login bug" --budget 8000
# Trace function dependencies ci_call_chain --symbol "handleLogin" --depth 3
# Analyze change impact ci_impact --file "src/auth.ts"
# Intelligent bug locator ci_bug_locate --error "TypeError: Cannot read property 'user'"
| Tool | Description |
|---|---|
ci_search |
Semantic code search with embeddings |
ci_graph_rag |
Graph-based context retrieval with smart pruning |
ci_call_chain |
Function call chain tracing |
ci_bug_locate |
Intelligent bug location with impact analysis |
ci_complexity |
Code complexity analysis |
ci_hotspot |
High-churn file detection |
ci_impact |
Transitive impact analysis with confidence decay |
ci_arch_check |
Architecture rule validation |
ci_vuln |
Vulnerability scanning and dependency tracing |
ci_index_status |
Manage embedding index (status/build/clear) |
ci_boundary |
Code boundary detection (user/library/generated) |
ci_graph_store |
Graph store operations (init/query/stats) |
ci_federation |
Cross-repo API contract tracking |
ci_ast_delta |
Incremental AST parsing |
ci_cod |
Architecture visualization (Mermaid/D3.js) |
ci_intent |
Query history and preference learning |
20+ tools available - Each tool supports --help for detailed usage.
The server supports multiple embedding providers with automatic fallback:
Three-tier Fallback Strategy:
- Ollama (Local, Free) → Preferred, no network latency, privacy-safe
- OpenAI API (Cloud, Paid) → Automatic fallback when Ollama unavailable
- Keyword Search → Final fallback when no embedding service available
Installation:
# Install Ollama curl -fsSL https://ollama.com/install.sh | sh # Pull the embedding model ollama pull nomic-embed-text
Configuration:
# .devbooks/config.yaml embedding: provider: ollama # or 'auto' for automatic detection ollama: model: nomic-embed-text endpoint: http://localhost:11434 timeout: 30
Usage:
# Build the embedding index ci-search build # Search with Ollama ci-search "authentication code"
Setup:
# Set your API key export OPENAI_API_KEY="sk-..."
Configuration:
# .devbooks/config.yaml embedding: provider: openai openai: model: text-embedding-3-small api_key: ${OPENAI_API_KEY} # or set directly base_url: https://api.openai.com/v1 timeout: 30
Usage:
# Build index with OpenAI ci-search build # Or force OpenAI for a single search ci-search "user authentication" --provider openai
Keyword search works out of the box without any configuration:
# Force keyword search ci-search "error handling" --provider keyword
Automatic Provider Detection:
# .devbooks/config.yaml embedding: provider: auto # Tries Ollama → OpenAI → Keyword fallback_to_keyword: true auto_build: true
Command-line Override:
# Override provider for a single search ci-search "test" --provider ollama --ollama-model mxbai-embed-large # JSON output with custom settings ci-search "payment" --format json --top-k 10 --threshold 0.7
Environment Variables:
OPENAI_API_KEY- OpenAI API keyEMBEDDING_API_KEY- Generic embedding API keyPROJECT_ROOT- Project root directory
All features degrade gracefully:
- No embeddings? Falls back to keyword search
- No SCIP index? Uses regex parsing
- No external tools? Core features still work
- No git history? Hotspot analysis disabled
This means you can start using the MCP server immediately without any configuration.
For advanced usage, see the local documentation:
- Complete tool reference and examples
- Architecture and system design
- Performance tuning guide
- Troubleshooting tips
Run ./install.sh to access full documentation locally.
Enable automatic context injection for Claude Code:
ci-setup-hook
This installs a hook that automatically injects relevant code context when you interact with Claude, making your AI assistant more aware of your codebase without manual queries.
# Search with specific mode ci-search "user service" --mode semantic --limit 5 # Trace call chains ci_call_chain --symbol "processPayment" --direction both # Check architecture ci_arch_check --path src/
Run comprehensive demos with A/B comparison:
# Run quick comparison demo bash demo/00-quick-compare.sh # Run all demos bash demo/run-suite.sh # Compare versions (if available) bash demo/compare.sh baseline.json current.json
The demo suite showcases:
- Automatic context injection vs manual queries
- Semantic search and Graph-RAG capabilities
- Performance benchmarks and metrics
- A/B comparison between different configurations
Metrics are generated by python3 benchmarks/run_benchmarks.py into benchmark_result.json.
Use python3 benchmarks/update_readme.py to refresh this section.
Updated at: 2026年01月24日T06:27:38+00:00
| Metric | Value | Notes |
|---|---|---|
| Semantic search P95 latency | 222 ms | iterations=3 |
| Graph-RAG cold P95 latency | 862.64 ms | iterations=3 |
| Graph-RAG warm P95 latency | 69.37 ms | iterations=3 |
| Graph-RAG speedup | 91.96 % | cold vs warm |
| Retrieval MRR@10 | 0.4264 | dataset=self, queries=12 |
| Retrieval Recall@10 | 1.0 | dataset=self, queries=12 |
| Retrieval Precision@10 | 0.3377 | dataset=self, queries=12 |
| Retrieval P95 latency | 6.10 ms | dataset=self, queries=12 |
| Cache hit P95 latency | 75 ms | iterations=20 |
| Full query P95 latency | 89 ms | iterations=20 |
| Precommit staged P95 | 35 ms | iterations=20 |
| Precommit deps P95 | 27 ms | iterations=20 |
| Compression latency | 8.95 ms | iterations=1 |
Contributions welcome! Please read CONTRIBUTING.md first.
MIT License - see LICENSE file for details.
Built with: Model Context Protocol, tree-sitter, SCIP
Need help? Open an issue on your repo or check docs/TECHNICAL.md.