Code Context MCP Server
代码上下文 MCP 服务器
一个模型上下文协议 (MCP) 服务器,用于提供来自本地 Git 代码库的代码上下文。此服务器允许您:
本地克隆 git 存储库
处理分支和文件
为代码块生成嵌入
对代码执行语义搜索
特征
使用本地 git 存储库而不是 GitHub API
将数据存储在 SQLite 数据库中
将代码拆分成语义块
使用 Ollama 为代码块生成嵌入
提供代码语义搜索
Related MCP server: repobase-mcp
先决条件
Node.js(v16+)
Git
带有嵌入模型的 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"]
}
}
}工具
服务器提供以下工具:
查询Repo
克隆存储库、处理代码并执行语义搜索:
{
"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参数是可选的。如果提供,结果将被过滤,仅包含至少包含一个指定关键字的区块(不区分大小写匹配)。
filePatterns和excludePatterns参数是可选的。它们允许你使用 glob 模式(例如, **/*.ts表示所有 TypeScript 文件)来过滤需要处理和搜索的文件。
数据库架构
该服务器使用具有以下架构的 SQLite:
repository:存储有关存储库的信息branch:存储有关分支的信息file:存储有关文件的信息branch_file_association:将文件与分支关联file_chunk:存储代码块及其嵌入
执照
麻省理工学院
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceA 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
- AlicenseNot gradedqualityDmaintenanceMCP server for indexing and searching Git repositories with AI. Enables tools like listing repos, semantic search, file globbing, and regex grep.2416MIT
- AlicenseNot gradedqualityCmaintenanceAn 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.24MIT
- AlicenseAqualityFmaintenanceMCP server for semantic code search that indexes your codebase and allows AI editors to search using natural language queries.911253MIT
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
A MCP server built for developers enabling Git based project management with project and personal…
Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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