Home / MCP / Code Context MCP Server

Code Context MCP Server

Provides code context from local git repositories via MCP, including embedding generation and semantic search.

typescript
Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
    "mcpServers": {
        "code_context_mcp": {
            "command": "/path/to/your/node",
            "args": [
                "/path/to/code-context-mcp/dist/index.js"
            ],
            "env": {
                "DATA_DIR": "~/.codeContextMcp/data",
                "REPO_CACHE_DIR": "~/.codeContextMcp/repos"
            }
        }
    }
}

This MCP server provides code context from your local git repositories. It processes repositories, generates semantic code chunks, and enables fast semantic search to help you understand and navigate your codebase offline.

How to use

To use this MCP server, connect your MCP client to the local stdio endpoint exposed by the server. You will run the server locally, build the project, and then start it so your client can query code context from your repositories.

Key capabilities you can use through the MCP client include cloning repositories locally, processing code across branches, generating embeddings for code chunks, and performing semantic searches over code slices.

How to install

Prerequisites you need on your machine:

- Node.js v16+

- Git

- Ollama with an embedding model if you want to use local embeddings for faster search

Step-by-step commands to set up the MCP server locally:

# Clone the repository
git clone <repository-url>
cd code-context-mcp

# Install dependencies
npm install

# Build the project
npm run build

Additional information

Configuration options define where data is stored and how repositories are cached.

Environment variables you can set to customize behavior include:

DATA_DIR=~/.codeContextMcp/data
REPO_CACHE_DIR=~/.codeContextMcp/repos

Usage with a client configuration

If you are configuring a desktop client that runs the MCP server locally, you will point the client at the local command that starts the server. The following example shows how a Claude Desktop client could be configured to start the local MCP server using your runtime and built bundle.

{
  "mcpServers": {
    "code_context_mcp": {
      "command": "/path/to/your/node",
      "args": ["/path/to/code-context-mcp/dist/index.js"]
    }
  }
}

Available tools

queryRepo

Clones a repository, processes code, and performs semantic search