claude-context-local
🔒 Privacy-first MCP server for Claude using PostgreSQL + Ollama. Local alternative to cloud-based code context with full data sovereignty. No API keys, no external calls, 100% local.
claude mcp add --transport stdio mikeo-ai-claude-context-local node /absolute/path/to/claude-context-local/packages/mcp/dist/index-postgres.js \ --env OLLAMA_HOST="http://localhost:11434" \ --env OLLAMA_MODEL="DC1LEX/nomic-embed-text-v1.5-multimodal" \ --env POSTGRES_HOST="localhost" \ --env POSTGRES_PORT="5432" \ --env POSTGRES_USER="postgres" \ --env POSTGRES_DATABASE="embeddings" \ --env POSTGRES_PASSWORD="postgres" \ --env EMBEDDING_PROVIDER="Ollama"
How to use
The claude-context-local MCP server provides a fully local, privacy-first code context assistant that uses a PostgreSQL database with pgvector for vector storage and Ollama for local embeddings. It replaces cloud dependencies with local components to ensure your code and data never leave your machine. The server is configured to connect to a local PostgreSQL database and a locally running Ollama service to generate embeddings from your code and related content. You can run it directly with Node.js using the provided index-postgres.js entry point, or install via npm and run with the included CLI tool. Tools exposed by this MCP include indexing a local codebase, performing semantic search over indexed code, and serving code context suggestions during your coding workflow. The configuration example demonstrates how to wire the MCP into Claude Code or other clients, including embedding provider, Ollama model, and PostgreSQL connection details.
How to install
Prerequisites:
- PostgreSQL installed and pgvector extension available
- Ollama installed and running with the required embedding model
- Node.js installed
Installation steps:
-
Clone the repository: git clone https://github.com/MikeO-AI/claude-context-local.git cd claude-context-local
-
Install dependencies (Node.js project): pnpm install
-
Build the MCP server package (PostgreSQL-based): pnpm build
-
Ensure external services are running:
- PostgreSQL with database named embeddings and pgvector extension
- Ollama server running and the model DC1LEX/nomic-embed-text-v1.5-multimodal available
-
Run tests (optional): node test-postgres.js
-
Run the MCP server (direct method): node packages/mcp/dist/index-postgres.js
-
Alternative: install the MCP CLI globally and run via CLI: npm install -g @mikeo-ai/claude-context-local-mcp claude-context-local-mcp
-
Optional: run with environment variables for custom configuration, e.g.: POSTGRES_HOST=your-db POSTGRES_PASSWORD=your-pass node packages/mcp/dist/index-postgres.js
Additional notes
Tips:
- Ensure Ollama is accessible at the configured host and port; if you change the host, update OLLAMA_HOST in the environment.
- If pgvector extension is missing, install it and create the extension in your embeddings database.
- The MCP can be configured for Claude Code integration by embedding the server details in your Claude config JSON under mcpServers.
- When using Docker, you can map local PostgreSQL and Ollama services to the containerized MCP as needed. Check MCP-SETUP-GUIDE.md for additional setup guidance.
- Common issues: model not found in Ollama, connection failures to PostgreSQL, or missing vector extension. Validate each service independently before starting the MCP.
Related MCP Servers
serena
A powerful coding agent toolkit providing semantic retrieval and editing capabilities (MCP server & other integrations)
claude-context
Code search MCP for Claude Code. Make entire codebase the context for any coding agent.
claude-context-local
Code search MCP for Claude Code. Make entire codebase the context for any coding agent. Embeddings are created and stored locally. No API cost.
velocity
Local-first workspace for Claude Code, Codex CLI, and Gemini CLI with sessions, analytics, workflows, and tools
heuristic
Enhanced MCP server for semantic code search with call-graph proximity, recency ranking, and find-similar-code. Built for AI coding assistants.
mcp-ragex
MCP server for intelligent code search: semantic (RAG), symbolic (tree-sitter), and regex (ripgrep) search modes. Built for Claude Code and AI coding assistants.