Sponsored by Deepsite.site

ContextBridge

创建者
tijuthomas5a month ago
ContextBridge (CB) is a local-first retrieval layer that sits between your codebase and your AI coding agent. Instead of pasting raw source files into context or letting the AI guess which files matter, CB indexes your codebase's real structure (via Graphify) and returns a compact, ranked result — owner file, related files, key symbols, and dependency chains — grounded in your actual code. A typical response is ~4–8 KB instead of the 100+ KB of raw source an AI would otherwise need to read to answer the same question — roughly a 96% cut in input tokens sent to your cloud AI, with zero hallucinated file paths or method names.
内容

Why ContextBridge

Without CB, an AI coding agent either guesses which files are relevant, or you paste entire source files into the chat — burning thousands of input tokens on code that isn't needed. With CB, the AI calls a single MCP tool and gets back a ranked, grounded result instead.

Without CBWith CB
Paste 10–50 raw files into contextCB returns the 3–5 files that actually matter
AI guesses which code is relevantResult is grounded in your real codebase structure
High token cost, noisy contextLow token cost, focused context
Hallucinated file paths and method namesExact file paths, symbols, and line hints

What it does

  • Indexes your codebase's real structure (via Graphify output — not raw source) into a searchable graph of files, symbols, and dependency edges
  • Exposes a single primary MCP tool, search_context_hybrid(), that any MCP-compatible AI client can call to get ranked files, symbols, and dependency chains
  • An optional local AI analysis stage (Ollama by default, or OpenAI/Anthropic/OpenRouter if you opt in) validates and re-ranks results before they reach your cloud AI
  • Tracks UI-to-backend call mappings (dependency-edge enrichment) so frontend-to-API routing questions resolve to the real connected files, not just co-located ones

How the token savings actually happen

Without CB, answering a codebase question means the AI either pastes several full source files into its context window (often 10–50 files, tens of thousands of lines) or guesses at relevance from filenames alone. Both burn input tokens on code that usually isn't the actual answer.

CB cuts this in three stages:

  1. Retrieval, not dumpingsearch_context_hybrid() returns only the ranked owner file(s), directly related files, matched symbols, and a dependency summary — not full file contents.
  2. Compact result shape — the response is a structured JSON summary (facts, ranked files, symbol hits, dependency chains) instead of raw code blocks, so even the files it does surface are represented as targeted snippets and line hints, not entire files.
  3. Optional local AI compression — if enabled, a local model (Ollama by default) validates and re-ranks the result, decomposes multi-topic prompts, and passes a further-compressed, grounded summary to your cloud AI — so the cloud model only ever sees the distilled answer, not the raw retrieval output.

Measured result: a typical query response is ~4–8 KB, versus ~118 KB of raw source an AI would otherwise pull in to answer the same question — about a 96% reduction in tokens actually sent to your cloud AI.

Retrieval modes

  • Hybrid (recommended) — keyword-first with guarded vector assist
  • Semantic — vector-only, best for vague "how does X work" questions
  • Keyword — pure keyword search for exact known symbol/file names

Local-first by default

Core retrieval and indexing run entirely on your machine — your code never leaves it unless you explicitly configure a cloud LLM provider for the optional analysis stage.

Works with any AI client

Claude Code, Cursor, Codex, Antigravity, Gemini CLI, or anything that speaks MCP. Supports both SSE (recommended — one shared server for multiple clients) and stdio transport, so it works with clients that only support one or the other.

Generic engine, not project-specific

All project-specific ranking logic lives in a swappable profile plugin. Out of the box (project_profile: "default") you get pure generic scoring that works on any codebase, any stack.

服务器配置

{
  "mcpServers": {
    "context_bridge": {
      "url": "http://127.0.0.1:8755/sse"
    }
  }
}
推荐的 MCP Server
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
ChatWiseThe second fastest AI chatbot™
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
WindsurfThe new purpose-built IDE to harness magic
CursorThe AI Code Editor
Amap Maps高德地图官方 MCP Server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
DeepChatYour AI Partner on Desktop
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Serper MCP ServerA Serper MCP Server
Tavily Mcp
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Playwright McpPlaywright MCP server