Run local semantic code search on any codebase using Docker, Milvus, and Code Context MCP. Works with Claude Code, Gemini CLI, ChatGPT Desktop, and more.
- Docker Desktop (or Docker Engine)
- Git
git clone git@github.com:cstuncsik/local-code-llm-mcp.git
cd local-code-llm-mcp⚙️ Local Setup
Pros:
- Faster file access (especially on macOS)
- Easier debugging and inspection
- Persistent index stored in
~/.code-context
Cons:
- Requires local installation of Ollama
- Slightly more setup steps
You run code-context-mcp and ollama locally, only Milvus runs in Docker.
-
Install Ollama locally
curl -fsSL https://ollama.com/install.sh | sh # or use brew on MacOS brew install ollama
-
Start Ollama and pull required models
Start the Ollama service and download the required models:
ollama serve & # Or use Homebrew services to run Ollama in the background brew services start ollama ollama pull llama3 ollama pull nomic-embed-text
This ensures that the required models are available for embeddings.
-
Start Milvus in Docker
Spin up a Milvus container only (the same
docker-compose.ymlis used):docker compose up -d milvus
-
Add MPC server
claude mcp add local-code-mcp -e EMBEDDING_PROVIDER=Ollama -e OLLAMA_MODEL=llama3 -e EMBEDDING_MODEL=nomic-embed-text -e MILVUS_ADDRESS=localhost:19530 -e OLLAMA_HOST=http://localhost:11434 -- npx @zilliz/code-context-mcp@latestOr the config directly
{
"mcpServers": {
"local-code-mcp": {
"command": "npx",
"args": ["@zilliz/code-context-mcp@latest"],
"env": {
"EMBEDDING_PROVIDER": "Ollama",
"OLLAMA_MODEL": "llama3",
"EMBEDDING_MODEL": "nomic-embed-text",
"MILVUS_ADDRESS": "localhost:19530",
"OLLAMA_HOST": "http://localhost:11434"
}
}
}
}See other MCP Client Configurations at @zilliz/code-context-mc github page
Start MCP from your code directory for debugging purpose
npm install -g @zilliz/code-context-mcp@latest
EMBEDDING_PROVIDER=Ollama \
OLLAMA_MODEL=llama3 \
EMBEDDING_MODEL=nomic-embed-text \
code-context-mcp start \
--milvus-uri localhost:19530 \
--ollama-host http://localhost:11434✅ Required environment variables for local setup (can be set in a
.envfile or exported in your shell):EMBEDDING_PROVIDER=Ollama OLLAMA_MODEL=llama3 EMBEDDING_MODEL=nomic-embed-text MILVUS_ADDRESS=localhost:19530 OLLAMA_HOST=http://localhost:11434These must be set when running
code-context-mcpoutside of Docker to avoid fallback to OpenAI.
💡 This setup avoids Docker overhead and speeds up indexing, especially on large codebases.
✅ Tip: If running MCP locally (not in Docker), it uses
~/.code-contextfor index cache by default, so the data persists automatically between runs.
If you're on Windows, the recommended approach is to use WSL2 with Ubuntu.
🧰 Prerequisites
• WSL2 with Ubuntu Install from Microsoft Store if not already:
wsl --install -d Ubuntu• Docker Desktop for Windows
• Enable the “Use WSL 2 based engine” in Docker settings.
• Allow Docker to integrate with your WSL distribution.
• Ollama (inside WSL2) (Ollama now supports Linux/WSL via .deb)
curl -fsSL https://ollama.com/install.sh | sh• Node.js inside WSL2
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejsAfter installing Ollama and Node.js inside your WSL2 environment, and Docker Desktop on Windows with WSL integration enabled, all setup steps are the same as described above.
💡 Make sure Docker is accessible from WSL and the Ollama service is started with ollama serve & before launching MCP.
You can pull the models like this:
ollama pull llama3
ollama pull nomic-embed-textThen run the same docker compose up -d milvus, code-context-mcp start, and claude mcp add commands as described.
🐋 Docker Setup (All-in-One)
Pros:
- Easy to set up with a single command
- Clean separation from host environment
- Consistent across different machines
Cons:
- Slower indexing due to Docker filesystem I/O
- Index is ephemeral unless volume is persisted
- Could be harder to debug inside the container
docker compose up --build -dRun this command from inside the project folder you want to index:
claude mcp add local-code-mcp -s user -- \
docker run --rm -i \
-v .:/workspace \
-e EMBEDDING_PROVIDER=Ollama \
-e OLLAMA_MODEL=llama3 \
-e EMBEDDING_MODEL=nomic-embed-text \
-e MILVUS_ADDRESS=host.docker.internal:19530 \
-e OLLAMA_HOST=http://host.docker.internal:11434 \
-w /workspace \
code-context-mcp \
code-context-mcp start --workspace /workspaceBy default, when running docker run --rm, the container is removed after each run. This means the .code-context folder containing the index is lost, and the codebase will be re-indexed every time you restart the process.
To avoid this, mount a persistent volume or bind mount the .code-context folder from your local project:
-v "$(pwd)/.code-context":/workspace/.code-context# Full Claude CLI command with persistent index volume
claude mcp add local-code-mcp -s user -- \
docker run --rm -i \
-v .:/workspace \
-v "$(pwd)/.code-context":/workspace/.code-context \
-e EMBEDDING_PROVIDER=Ollama \
-e OLLAMA_MODEL=llama3 \
-e EMBEDDING_MODEL=nomic-embed-text \
-e MILVUS_ADDRESS=host.docker.internal:19530 \
-e OLLAMA_HOST=http://host.docker.internal:11434 \
-w /workspace \
code-context-mcp \
code-context-mcp start --workspace /workspaceThis will reuse the cached chunks and embeddings from .code-context for faster startup and better performance.
💡 Tip: You can safely commit
.code-contextto.gitignoreto avoid versioning large embedding data.
✅ Tip: When asking Claude to index the codebase, explicitly specify the path as
.:Index this repo for semantic search with MCP local-code-mcp at path .This ensures the correct path is passed to the MCP container and avoids issues with mismatched host paths.
Ask your LLM:
Where are the webhook handlers defined?
What happens when a user logs in?
How is the checkout process handled?
Show me the API routes related to orders.
- Local code indexing for LLM context (reduces token usage)
- AST-based code chunking
- Ollama-powered local embeddings
- Fast semantic search via Milvus