Code Context MCP Server

by fkesheh
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Allows cloning and processing of local git repositories, extracting code context from different branches and files for semantic search.

コードコンテキストMCPサーバー

ローカルGitリポジトリからコードコンテキストを提供するためのモデルコンテキストプロトコル(MCP)サーバー。このサーバーでは以下のことが可能です。

  1. Gitリポジトリをローカルにクローンする
  2. プロセスブランチとファイル
  3. コードチャンクの埋め込みを生成する
  4. コード上でセマンティック検索を実行する

特徴

  • GitHub APIの代わりにローカルのgitリポジトリを使用する
  • SQLiteデータベースにデータを保存する
  • コードを意味のあるチャンクに分割する
  • Ollamaを使用してコードチャンクの埋め込みを生成する
  • コード上のセマンティック検索を提供

前提条件

  • Node.js (v16+)
  • ギット
  • 埋め込みモデルを備えたOllama

インストール

# Clone the repository git clone <repository-url> cd code-context-mcp # Install dependencies npm install # Build the project npm run build

構成

次の環境変数を設定します。

  • DATA_DIR : SQLite データベースのディレクトリ (デフォルト: '~/.codeContextMcp/data')
  • REPO_CACHE_DIR : クローンされたリポジトリのディレクトリ (デフォルト: '~/.codeContextMcp/repos')

Ollamaの使用

より高速で強力な埋め込みには、Ollama を使用できます。

# Install Ollama from https://ollama.ai/ # Pull an embedding model (unclemusclez/jina-embeddings-v2-base-code is recommended) ollama pull unclemusclez/jina-embeddings-v2-base-code

使用法

Claude Desktopでの使用

Claude Desktop 構成ファイル ( claude_desktop_config.json ) に次の構成を追加します。

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

ツール

サーバーは次のツールを提供します。

クエリリポジトリ

リポジトリのクローンを作成し、コードを処理し、セマンティック検索を実行します。

{ "repoUrl": "https://github.com/username/repo.git", "branch": "main", // Optional - defaults to repository's default branch "query": "Your search query", "keywords": ["keyword1", "keyword2"], // Optional - filter results by keywords "filePatterns": ["**/*.ts", "src/*.js"], // Optional - filter files by glob patterns "excludePatterns": ["**/node_modules/**"], // Optional - exclude files by glob patterns "limit": 10 // Optional - number of results to return, default: 10 }

branchパラメータはオプションです。指定されていない場合、ツールはリポジトリのデフォルトブランチを自動的に使用します。

keywordsパラメータはオプションです。指定した場合、結果は指定されたキーワードの少なくとも1つを含むチャンクのみにフィルタリングされます(大文字と小文字は区別されません)。

filePatternsおよびexcludePatternsパラメータはオプションです。これらを使用すると、処理および検索対象となるファイルを glob パターンでフィルタリングできます(例: すべての TypeScript ファイルの場合は**/*.ts )。

データベーススキーマ

サーバーは次のスキーマで SQLite を使用します。

  • repository :リポジトリに関する情報を保存します
  • branch : ブランチに関する情報を保存します
  • file : ファイルに関する情報を保存します
  • branch_file_association : ファイルをブランチに関連付ける
  • file_chunk : コードチャンクとその埋め込みを保存する

ライセンス

マサチューセッツ工科大学

-
security - not tested
A
license - permissive license
-
quality - not tested

ローカル Git リポジトリに対するセマンティック検索を提供する MCP サーバー。これにより、ユーザーはリポジトリのクローン作成、ブランチの処理、ベクトル化されたコード チャンクによるコードの検索が可能になります。

  1. Features
    1. Prerequisites
      1. Installation
        1. Configuration
          1. Using Ollama
        2. Usage
          1. Using with Claude Desktop
        3. Tools
          1. queryRepo
        4. Database Schema
          1. License
            ID: ciwrw699vq