OpenSource-Hub

claude-context

命令行工具

zilliztech/claude-context

为AI编码代理提供全代码库语义搜索的MCP插件。

项目简介

Claude Context 是一个 MCP 服务器,让 Claude Code 等 AI 编程助手对整个代码库进行语义搜索。它通过向量嵌入高效检索相关代码片段,避免载入完整目录以降低成本。

README 预览

\n\n> 🆕 **Looking for persistent memory for Claude Code?** Check out [memsearch Claude Code plugin](https://github.com/zilliztech/memsearch#for-claude-code-users) — a markdown-first memory system that gives your AI agent long-term memory across sessions.\n\n### Your entire codebase as Claude's context\n\n[](https://opensource.org/licenses/MIT)\n[](https://nodejs.org/)\n[](docs/)\n[](https://marketplace.visualstudio.com/items?itemName=zilliz.semanticcodesearch)\n[](https://www.npmjs.com/package/@zilliz/claude-context-core)\n[](https://www.npmjs.com/package/@zilliz/claude-context-mcp)\n[](https://twitter.com/zilliz_universe)\n[](https://deepwiki.com/zilliztech/claude-context)\n\n\n\n\n**Claude Context** is an MCP plugin that adds semantic code search to Claude Code and other AI coding agents, giving them deep context from your entire codebase.\n\n🧠 **Your Entire Codebase as Context**: Claude Context uses semantic search to find all relevant code from millions of lines. No multi-round discovery needed. It brings results straight into the Claude's context.\n\n💰 **Cost-Effective for Large Codebases**: Instead of loading entire directories into Claude for every request, which can be very expensive, Claude Context efficiently stores your codebase in a vector database and only uses related code in context to keep your costs manageable.\n\n---\n\n## 🚀 Demo\n\n\n\nModel Context Protocol (MCP) allows you to integrate Claude Context with your favorite AI coding assistants, e.g. Claude Code.\n\n## Quick Start\n\n### Prerequisites\n\n\nGet a free vector database on Zilliz Cloud 👈\n\nClaude Context needs a vector database. You can [sign up](https://cloud.zilliz.com/signup?utm_source=github&utm_medium=referral&utm_campaign=2507-codecontext-readme) on Zilliz Cloud to get an API key.\n\n\n\nCopy your Personal Key to replace `your-zilliz-cloud-api-key` in the configuration examples.\n\n\n\nGet OpenAI API Key for embedding model\n\nYou need an OpenAI API key for the embedding mode

常见问题 (3)

故障排除
为什么Claude Code MCP服务器在启动时会崩溃并显示'Address is required and could not be resolved from token'?

您的Claude Code MCP配置缺少MILVUS_ADDRESS环境变量。确保在添加MCP服务器时提供Zilliz Cloud端点。示例:

claude mcp add claude-context \
  -e OPENAI_API_KEY=sk-your-openai-api-key \
  -e MILVUS_TOKEN=your-zilliz-cloud-api-key \
  -e MILVUS_ADDRESS=your-zilliz-cloud-api-endpoint \
  -- npx @zilliz/claude-context-mcp@latest

这可以防止出现“需要地址且无法从令牌解析”的错误。该修复已集成到最新的README中。

来源 Issue #311
故障排除
为什么我的代码库在崩溃后每次会话都强制重新索引?

这是一个已知的v0.1.6版本bug:在索引中断后,快照文件卡在0/0,导致无限重新索引循环。解决方法:编辑~/.context/mcp-codebase-snapshot.json,将受影响代码库的‘indexedFiles’和‘totalChunks’更新为Milvus中的实际行数(通过Milvus stats获取)。永久修复已在计划中(跟踪#295)。

来源 Issue #295
故障排除
为什么claude-context仍然会索引根级目录(如/Library/)内的文件,即使它在忽略文件中?

claude-context 未完全解析忽略模式中的前导斜杠(仅匹配根目录)和尾部斜杠(匹配目录及其内容)。标准工具(如 Git)将 /Library/ 视为“忽略根目录下的 Library 文件夹及其所有内容”。作为替代方案,请移除前导斜杠,并将尾部斜杠替换为 /**(例如 Library/**),或直接使用不含斜杠的 Library 以递归忽略该目录及其文件。此问题已记录为 #200。

来源 Issue #200