Skip to main content
Glama
fkesheh

Code Context MCP Server

by fkesheh

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

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

  1. Gitリポジトリをローカルにクローンする

  2. プロセスブランチとファイル

  3. コードチャンクの埋め込みを生成する

  4. コード上でセマンティック検索を実行する

特徴

  • GitHub APIの代わりにローカルのgitリポジトリを使用する

  • SQLiteデータベースにデータを保存する

  • コードを意味のあるチャンクに分割する

  • Ollamaを使用してコードチャンクの埋め込みを生成する

  • コード上のセマンティック検索を提供

Related MCP server: repobase-mcp

前提条件

  • 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 : コードチャンクとその埋め込みを保存する

ライセンス

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

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    maintenance
    A semantic code search MCP server that enables natural language queries against your codebase, supporting features like related file discovery and context expansion, all running locally.
    2
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that enables semantic search over local files or GitHub repositories by indexing content into a serverless vector database, allowing AI assistants to understand meaning rather than just keywords.
    24
    MIT
  • A
    license
    A
    quality
    F
    maintenance
    MCP server for semantic code search that indexes your codebase and allows AI editors to search using natural language queries.
    9
    53 npm
    53
    MIT