code-context-mcp
MCP server for semantic code search and dependency graph analysis. Indexes codebases into a knowledge graph with vector embeddings for AI-powered code understanding.
README
code-context-mcp
MCP server for semantic code search and dependency graph analysis. Indexes codebases into a knowledge graph (Apache AGE) with vector embeddings (pgvector + Ollama) for AI-powered code understanding.
Supported Languages
- TypeScript (
.ts,.tsx) — functions, classes, types, interfaces, imports - Rust (
.rs) — functions, structs, enums, traits, impl blocks, modules, use declarations - Solidity (
.sol) — contracts, functions, events, modifiers, structs, enums, interfaces, imports - C - functions, enums
Prerequisites
- Docker and Docker Compose
- Node.js >= 18
Quick Start
# Start PostgreSQL (with AGE + pgvector) and Ollama
docker-compose up -d
# Install dependencies and build
npm install
npm run build
Indexing a Codebase
# Index a directory (project name auto-derived from directory basename)
node dist/cli/index.js index ./src
# Override the project name
node dist/cli/index.js index ./src --project my-project
# Index multiple codebases
node dist/cli/index.js index /path/to/frontend --project frontend
node dist/cli/index.js index /path/to/backend --project backend
The indexer will:
- Parse all supported source files (TypeScript, Rust, Solidity) using tree-sitter
- Build a code graph with functions, classes, types, contracts, traits, and their relationships
- Generate vector embeddings for semantic search via Ollama
- Show a progress bar during indexing
Re-running the indexer on the same directory skips unchanged files (detected via content hash).
Claude Desktop Configuration
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"code-context": {
"command": "node",
"args": ["dist/mcp/server.js"],
"cwd": "/path/to/code-context-mcp",
"env": {
"PGHOST": "localhost",
"PGPORT": "5433",
"PGDATABASE": "rag_db",
"PGUSER": "postgres",
"PGPASSWORD": "postgres",
"OLLAMA_URL": "http://localhost:11434"
}
}
}
}
MCP Tools
list_projects
List all indexed projects and their node counts.
Parameters: none
search_code
Semantic search across the indexed codebase. Finds functions, classes, types, and imports by meaning.
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string | yes | Natural language search query |
limit |
number | no | Maximum results (default: 10) |
project |
string | no | Scope search to a project |
get_call_stack
Trace the call dependency tree from a function.
| Parameter | Type | Required | Description |
|---|---|---|---|
functionName |
string | yes | Function to trace from |
depth |
number | no | Max traversal depth, 1-10 (default: 3) |
project |
string | no | Scope to a project |
get_function_context
Gather full context for a function: callers, callees, types it uses.
| Parameter | Type | Required | Description |
|---|---|---|---|
functionName |
string | yes | Function to get context for |
project |
string | no | Scope to a project |
get_impact_analysis
Analyze impact of changes to a file. Shows all external code that depends on definitions in the file.
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath |
string | yes | Relative path of the file (as indexed) |
project |
string | no | Scope to a project |
Environment Variables
| Variable | Default | Description |
|---|---|---|
PGHOST |
localhost |
PostgreSQL host |
PGPORT |
5433 |
PostgreSQL port |
PGDATABASE |
rag_db |
Database name |
PGUSER |
postgres |
Database user |
PGPASSWORD |
postgres |
Database password |
OLLAMA_URL |
http://localhost:11434 |
Ollama API endpoint |
Testing
Unit Tests
Unit tests run without Docker and cover extractors, scanner, registry, progress bar, embeddings, and DB queries.
npm test # Run all unit tests
npm run test:watch # Watch mode
Integration Tests
Integration tests require separate Docker containers to avoid interfering with development data.
# Start test infrastructure (separate ports: PG=5434, Ollama=11435)
docker compose -f docker-compose.test.yml up -d
# Run integration tests
npm run test:integration
Integration tests cover the full indexing pipeline and multi-language graph population.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.