Claude Context开源:减少40% token消耗的代码检索MCP工具

𝗚𝗿𝗲𝗽-𝘀𝘁𝘆𝗹𝗲 𝘀𝗲𝗮𝗿𝗰𝗵 𝗶𝗻 𝗖𝗹𝗮𝘂𝗱𝗲 𝗖𝗼𝗱𝗲 𝘄𝗼𝗿𝗸𝘀 𝗳𝗼𝗿 𝗰𝗼𝗱𝗲 ...

精选理由

如果你用Claude Code、Codex CLI或Cline写代码,试试这个MCP工具,能省掉40%的token费用,而且搜代码更准。

AI 摘要

Claude Context是一个开源MCP工具,针对Claude Code等代理的代码检索场景,将token消耗降低约40%。它通过向量数据库和嵌入模型实现语义匹配、智能过滤和上下文感知检索,解决了grep模式的信息过载、语义盲点和上下文缺失问题。该工具在GitHub上获得12,000+星标,并登上日榜第一。底层使用Milvus进行BM25+稠密向量混合搜索,支持OpenAI、VoyageAI和Ollama多种嵌入模型。

原文 · Milvus

𝗚𝗿𝗲𝗽-𝘀𝘁𝘆𝗹𝗲 𝘀𝗲𝗮𝗿𝗰𝗵 𝗶𝗻 𝗖𝗹𝗮𝘂𝗱𝗲 𝗖𝗼𝗱𝗲 𝘄𝗼𝗿𝗸𝘀 𝗳𝗼𝗿 𝗰𝗼𝗱𝗲 ...

𝗚𝗿𝗲𝗽-𝘀𝘁𝘆𝗹𝗲 𝘀𝗲𝗮𝗿𝗰𝗵 𝗶𝗻 𝗖𝗹𝗮𝘂𝗱𝗲 𝗖𝗼𝗱𝗲 𝘄𝗼𝗿𝗸𝘀 𝗳𝗼𝗿 𝗰𝗼𝗱𝗲 𝗿𝗲𝘁𝗿𝗶𝗲𝘃𝗮𝗹, 𝗯𝘂𝘁 𝗶𝘁 𝗯𝘂𝗿𝗻𝘀 𝘁𝗵𝗿𝗼𝘂𝗴𝗵 𝘁𝗼𝗸𝗲𝗻𝘀 𝘂𝗻𝗻𝗲𝗰𝗲𝘀𝘀𝗮𝗿𝗶𝗹𝘆. 𝗪𝗲 𝗯𝘂𝗶𝗹𝘁 𝗖𝗹𝗮𝘂𝗱𝗲 𝗖𝗼𝗻𝘁𝗲𝘅𝘁, 𝗮𝗻 𝗼𝗽𝗲𝗻-𝘀𝗼𝘂𝗿𝗰𝗲 𝗠𝗖𝗣 𝘁𝗼𝗼𝗹 𝘁𝗵𝗮𝘁 𝗰𝘂𝘁𝘀 𝘁𝗼𝗸𝗲𝗻 𝘂𝘀𝗮𝗴𝗲 𝗯𝘆 ~𝟰𝟬%. Grep-style code retrieval has drawn plenty of community discussion. For pure recall, literal matching gets the job done. But in a large codebase, it forces the model to wade through massive amounts of irrelevant code to find the few lines that matter. 𝗧𝗵𝗿𝗲𝗲 𝘁𝗵𝗶𝗻𝗴𝘀 𝗺𝗮𝗸𝗲 𝘁𝗵𝗶𝘀 𝗲𝘅𝗽𝗲𝗻𝘀𝗶𝘃𝗲 𝗮𝘁 𝘀𝗰𝗮𝗹𝗲: • 𝗜𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻 𝗼𝘃𝗲𝗿𝗹𝗼𝗮𝗱. Large repos produce hundreds of literal matches for common terms. Most are noise, but they all consume tokens and inference time. • 𝗦𝗲𝗺𝗮𝗻𝘁𝗶𝗰 𝗯𝗹𝗶𝗻𝗱𝗻𝗲𝘀𝘀. Grep matches characters, not meaning. compute_final_cost() and calculate_total_price() do the same thing, but a string match won't connect them. • 𝗜𝗻𝗰𝗼𝗺𝗽𝗹𝗲𝘁𝗲 𝗰𝗼𝗻𝘁𝗲𝘅𝘁. Line-level matches strip away the surrounding class and method structure. The model compensates by reading more files, burning more tokens. 𝗪𝗲 𝗼𝗽𝗲𝗻-𝘀𝗼𝘂𝗿𝗰𝗲𝗱 𝗖𝗹𝗮𝘂𝗱𝗲 𝗖𝗼𝗻𝘁𝗲𝘅𝘁 𝘁𝗼 𝗮𝗱𝗱𝗿𝗲𝘀𝘀 𝗲𝘅𝗮𝗰𝘁𝗹𝘆 𝘁𝗵𝗶𝘀. 𝗜𝘁 𝗵𝗶𝘁 #𝟭 𝗼𝗻 𝗚𝗶𝘁𝗛𝘂𝗯'𝘀 𝗱𝗮𝗶𝗹𝘆 𝘁𝗿𝗲𝗻𝗱𝗶𝗻𝗴 𝗰𝗵𝗮𝗿𝘁 𝗮𝗻𝗱 𝗰𝘂𝗿𝗿𝗲𝗻𝘁𝗹𝘆 𝗵𝗮𝘀 𝗼𝘃𝗲𝗿 𝟭𝟮,𝟬𝟬𝟬 𝘀𝘁𝗮𝗿𝘀. 𝗜𝗻 𝗼𝘂𝗿 𝗯𝗲𝗻𝗰𝗵𝗺𝗮𝗿𝗸, 𝗖𝗹𝗮𝘂𝗱𝗲 𝗖𝗼𝗻𝘁𝗲𝘅𝘁 𝗿𝗲𝗱𝘂𝗰𝗲𝗱 𝘁𝗼𝗸𝗲𝗻 𝗰𝗼𝗻𝘀𝘂𝗺𝗽𝘁𝗶𝗼𝗻 𝗯𝘆 ~𝟰𝟬% 𝗮𝘁 𝗲𝗾𝘂𝗶𝘃𝗮𝗹𝗲𝗻𝘁 𝗿𝗲𝘁𝗿𝗶𝗲𝘃𝗮𝗹 𝗾𝘂𝗮𝗹𝗶𝘁𝘆. It's a code retrieval MCP server that integrates a vector database and embedding model into the search layer. It plugs into Claude Code and is also compatible with Codex CLI, Gemini CLI, Qwen Code, Cline, Cursor, Windsurf, and other MCP-compatible agents. 𝗜𝘁 𝗱𝗼𝗲𝘀 𝘁𝗵𝗿𝗲𝗲 𝘁𝗵𝗶𝗻𝗴𝘀 𝗱𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝘁𝗹𝘆: • 𝗦𝗺𝗮𝗿𝘁 𝗳𝗶𝗹𝘁𝗲𝗿𝗶𝗻𝗴. Vector similarity ranks code by relevance, surfacing the most related results first instead of every literal match. • 𝗖𝗼𝗻𝗰𝗲𝗽𝘁 𝗺𝗮𝘁𝗰𝗵𝗶𝗻𝗴. Dense retrieval can match conceptually related code even when function names differ entirely. • 𝗖𝗼𝗻𝘁𝗲𝘅𝘁-𝗮𝘄𝗮𝗿𝗲 𝗿𝗲𝘁𝗿𝗶𝗲𝘃𝗮𝗹. Results are chunked around complete syntactic units (functions, classes, methods), giving the model enough structural context to reason about behavior. Under the hood, Claude Context uses MCP as its interface layer and Milvus for codebase indexing and hybrid search (BM25 + dense vectors). Embeddings support OpenAI, VoyageAI (which ships a code-specific model), and Ollama for local deployment when privacy matters. C github.com/zilliztech/cla… arsing by default, splitting along sem milvus.io/blog/claude-co… d of cutting at arbitrary line counts. For files AST can't parse, LangChain's text splitter handles the fallback. For incremental updates, Claude Context uses Merkle-tree change detection. If the root hash hasn't changed, the index stays untouched. When it changes, the system identifies exactly which files were modified and re-embeds only those. Change one function, and you don't re-index the entire project. 🔗 https://t.co/yyWCfHbgZv 📝 Full benchmark and architecture: https://t.co/Sevmvp37HT 💬 0 🔄 0 ❤️ 0 👀 22 ⚡