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

ライセンス

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

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

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fkesheh/code-context-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server