尚未检测到更新。GitHub 发布版本后会显示在这里。
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证制作者的介绍仅有上面的一句话。 更多详情请阅读仓库 README。 仓库 README ↗
正在加载完整 README。
查看完整 README ↗Millisecond code search and reading at pinned Git revisions — for people, scripts and AI agents.
Live demo · Documentation · Reference docs · Contributing · 简体中文
Context Source Graph is a self-hosted code search service built on Go, Git and Zoekt. It keeps a trigram index of each repository, resolves every request to an exact commit, and exposes the same operations through a web UI, an HTTP API, an MCP server and a CLI.
It is built for the workload AI coding agents generate: many small, precise search → read round trips against code the agent does not have checked out.
grep or rg over a local checkout.repositories, availability, resolve, search, read, list, diff and prepare. MCP adds read_many for several reads in one call. See interfaces.<name>.sourcegraph.wasm) that change how read and read_many present files. See repository plugins.Measured against the public demo (context4ai/context, 2,359 indexed files) and a local checkout of the same commit:
| Query | Context Source Graph (server) | rg (local) | git grep (local) | grep -r (local) |
|---|---|---|---|---|
| Literal, 13 matching files | 0.7–0.9 ms | 61 ms | — | — |
| Literal, ~100+ matching files | 3.6–5.2 ms | 61 ms | 39 ms | 3.6 s |
| Regex, no matches | 0.4 ms | 62 ms | — | — |
Server time is Zoekt's reported search duration. Local tools ran on an Apple M4 Pro with a warm page cache; grep -r excluded node_modules, .git and dist. The service returns a bounded first page of results, so very broad queries do not grow without limit. Add the network round trip between caller and server — a few milliseconds within one region — to get end-to-end latency.
The index does the work that grep and rg repeat on every call, so the gap widens as repositories grow. Local tools also require a checkout of every repository at the right revision; the service does not.
Open the live demo — it indexes context4ai/context and context4ai/sourcegraph and allows anonymous reading.
Connect an MCP client that supports Streamable HTTP:
{
"mcpServers": {
"sourcegraph": { "url": "https://context4ai.org/sourcegraph/mcp" }
}
}
Or call the HTTP API directly:
curl -s -X POST 'https://context4ai.org/sourcegraph/api/search?repo=context4ai/context' \
-H 'content-type: application/json' \
-d '{"Pattern":"TODO","FixedStrings":true}'
The site's Connect page always shows current HTTP and client examples. See interfaces for MCP, HTTP and CLI details.
docker build -t context-sourcegraph .
docker volume create sourcegraph-data
docker run --rm -p 8080:8080 -v sourcegraph-data:/data \
-e SOURCEGRAPH_ORIGIN=http://localhost:8080 \
-e SOURCEGRAPH_SEED_DEMO=true \
context-sourcegraph
Open http://localhost:8080/sourcegraph/. Public GitHub repositories need no token; a custom Git host can be added in system settings or a startup file (code sources). Without OAuth credentials the site is an anonymous, read-only instance; add Google or GitHub OAuth to enable administration — the first verified user becomes the administrator (authentication).
All environment variables are listed in DEVELOPMENT.md.
Each instance owns its Git mirrors and Zoekt indexes on local disk. Search speed comes from that locality, so plan capacity around disk, not CPU.
Recommended at scale: sharded instances with repository-sticky routing. Run several instances that share one PostgreSQL or MongoDB database, each serving a disjoint set of repositories from its own data volume. Configure the access layer to route every request by its repository key (owner/repository) to the owning instance — for example with consistent hashing or an explicit repository → instance table. Every repository then has one warm index, capacity grows by adding instances, and losing one instance affects only its shard. See deployment for the required settings.
Simple: one instance with a large disk. For a single team or a moderate number of repositories, one instance on a large, fast persistent volume is the easiest option. Size the volume for bare Git repositories plus indexes, and keep headroom above SOURCEGRAPH_MIN_FREE_BYTES.
Either way, place instances in the same region as the agents and services that call them — that is what keeps end-to-end latency below 100 ms.
[!IMPORTANT] Do not run multiple replicas over the same repositories or the same data directory. Index ownership is per process; scale by sharding repositories, not by cloning instances.
Fly.io configuration, databases, backups and recovery are covered in deployment.
The Source Graph documentation on the Context site covers the concepts and day-to-day use:
| Section | Pages |
|---|---|
| How It Works | Overview · Pinned Search and Reads · Evidence for Context |
| Guides | Connecting · Self-Hosting · Registering Repositories · Authentication and Access Control · Operations |
| Reference | CLI · Configuration · HTTP and MCP · Query Syntax |
The reference documents in this repository describe the current implementation:
| Authentication | Google / GitHub sign-in, administrator bootstrap, registration policy |
| Deployment | Fly.io, databases, backups and recovery |
| Interfaces | Browser, HTTP, MCP and CLI |
| Repository plugins | Wasm plugins for read / read_many |
| Development | Build, test, run locally and configure |
MIT. Context Source Graph uses Zoekt (Apache-2.0) and other open-source components; see NOTICE. The project name does not imply affiliation with the Sourcegraph platform.
Source Graph is part of Context for AI. Context reads code evidence through it remotely (Evidence for Context), and Portal serves it at /sourcegraph/.
Read CONTRIBUTING.md before opening a pull request. Ask questions in GitHub Discussions (see SUPPORT.md) and report vulnerabilities through SECURITY.md. Participation is governed by the Code of Conduct.