Code Context MCP Server logo

Code Context MCP Server

by fkesheh

A Model Context Protocol (MCP) server for providing code context from local git repositories. It allows you to clone, process, and semantically search code within git repositories.

View on GitHub

Last updated: N/A

What is Code Context MCP Server?

Code Context MCP Server is a server that provides code context from local git repositories. It clones repositories, processes branches and files, generates embeddings for code chunks, and performs semantic search over the code.

How to use Code Context MCP Server?

  1. Clone the repository.
  2. Install dependencies using npm install.
  3. Build the project using npm run build.
  4. Configure environment variables like DATA_DIR and REPO_CACHE_DIR.
  5. Optionally, install and configure Ollama for faster embeddings.
  6. Add the server configuration to your Claude Desktop configuration file.
  7. Use the queryRepo tool to clone repositories, process code, and perform semantic search.

Key features of Code Context MCP Server

  • Uses local git repositories instead of GitHub API

  • Stores data in SQLite database

  • Splits code into semantic chunks

  • Generates embeddings for code chunks using Ollama

  • Provides semantic search over code

Use cases of Code Context MCP Server

  • Semantic code search within a project

  • Providing code context to language models

  • Analyzing codebases for specific patterns or keywords

  • Integrating with Claude Desktop for enhanced code understanding

FAQ from Code Context MCP Server

What is the purpose of this server?

To provide code context from local git repositories for semantic search and integration with tools like Claude Desktop.

What are the prerequisites for running this server?

Node.js (v16+), Git, and Ollama with an embedding model.

How do I configure the server?

Set the environment variables DATA_DIR and REPO_CACHE_DIR. Optionally, configure Ollama for embeddings.

How do I perform a semantic search?

Use the queryRepo tool with the repository URL, branch (optional), query, keywords (optional), and file patterns (optional).

What database does the server use?

The server uses SQLite to store information about repositories, branches, files, and code chunks.