代码上下文 MCP 服务器
一个模型上下文协议 (MCP) 服务器,用于提供来自本地 Git 代码库的代码上下文。此服务器允许您:
本地克隆 git 存储库
处理分支和文件
为代码块生成嵌入
对代码执行语义搜索
特征
使用本地 git 存储库而不是 GitHub API
将数据存储在 SQLite 数据库中
将代码拆分成语义块
使用 Ollama 为代码块生成嵌入
提供代码语义搜索
先决条件
Node.js(v16+)
Git
带有嵌入模型的 Ollama
安装
配置
设置以下环境变量:
DATA_DIR:SQLite 数据库目录(默认值:'~/.codeContextMcp/data')REPO_CACHE_DIR:克隆存储库的目录(默认值:'~/.codeContextMcp/repos')
使用 Ollama
为了获得更快、更强大的嵌入,您可以使用 Ollama:
用法
与 Claude Desktop 一起使用
将以下配置添加到您的 Claude Desktop 配置文件( claude_desktop_config.json ):
工具
服务器提供以下工具:
查询Repo
克隆存储库、处理代码并执行语义搜索:
branch参数是可选的。如果没有提供,工具将自动使用仓库的默认分支。
keywords参数是可选的。如果提供,结果将被过滤,仅包含至少包含一个指定关键字的区块(不区分大小写匹配)。
filePatterns和excludePatterns参数是可选的。它们允许你使用 glob 模式(例如, **/*.ts表示所有 TypeScript 文件)来过滤需要处理和搜索的文件。
数据库架构
该服务器使用具有以下架构的 SQLite:
repository:存储有关存储库的信息branch:存储有关分支的信息file:存储有关文件的信息branch_file_association:将文件与分支关联file_chunk:存储代码块及其嵌入
执照
麻省理工学院
This server cannot be installed
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA specialized MCP server for in-depth analysis of git repositories, offering tools for branch overview, time period analysis, file changes, and merge recommendations.Last updated -42Apache 2.0
- -securityFlicense-qualityAn MCP server that enables Git repository operations and GitHub PR workflows, allowing users to manage repositories, create branches, commit changes, and create pull requests through natural language.Last updated -2
- AsecurityAlicenseAqualityAn MCP server that allows users to efficiently search and reference user-configured documents through document listing, grep searching, semantic searching with OpenAI Embeddings, and full document retrieval.Last updated -43MIT License