@kenkaiiii/kencode-search
v0.3.4
Published
Code search MCP server for AI agents. Grep-style literal search across 2M+ public GitHub repos, plus live repo discovery.
Maintainers
Readme
@kenkaiiii/kencode-search
npm:
@kenkaiiii/kencode-search· github:KenKaiii/kencode-search
Code search MCP server for AI agents. Point an agent at code you just wrote and it finds how real projects implement the same thing.
Two tools, one backend abstraction:
discoverRepos— live GitHub repository discovery by keyword, language, topic, stars, and recency.searchCode— literal grep-style code search for known anchors.
Two search backends:
sourcegraph(default) — 2M+ public repos via Sourcegraph's public streaming API. Free, no auth, but unmetered and intermittently flaky: it can return empty results and never complete. The tool retries once and reports a backend fault rather than pretending your query found nothing.ripgrep— your local directory of<owner>/<name>checkouts.
searchCode is the core tool: give it a literal anchor from your code (an import, API call, config key) and it returns matching implementations with snippets, stars, and licence. discoverRepos finds candidate repos by popularity when you don't have an anchor yet. Output is LLM-optimized: snippet merging, junk-path filtering (no node_modules/tests/generated noise), per-repo diversity cap, peek mode, pagination, total-count summary.
Why this exists
grep.app's MCP is rate-limited. Their open API is gated by a Vercel bot challenge, so scripts can't hit it. Sourcegraph's public stream API has none of those problems and indexes more repos. We wrap it cleanly.
Install
npm install -g @kenkaiiii/kencode-searchor run on demand without installing:
npx @kenkaiiii/kencode-searchRequirements
- Node.js ≥ 20
- For the
ripgrepbackend only:ripgreponPATH(brew install ripgrep).
Quick start
Most MCP clients (Claude Code, Cursor, Windsurf, etc.) take this in their config:
{
"mcpServers": {
"kencode-search": {
"command": "npx",
"args": ["-y", "@kenkaiiii/kencode-search"]
}
}
}That's it — default sourcegraph backend, no config.
Run manually
# Default: sourcegraph backend, no config needed.
kencode-search
# Local repo tree:
CFM_BACKEND=ripgrep CFM_REPOS_DIR=/path/to/repos kencode-searchBuild from source
git clone https://github.com/KenKaiii/kencode-search.git
cd kencode-search
npm install
npm run build
node dist/index.jsPin to the ripgrep backend
{
"mcpServers": {
"kencode-search": {
"command": "npx",
"args": ["-y", "@kenkaiiii/kencode-search"],
"env": {
"CFM_BACKEND": "ripgrep",
"CFM_REPOS_DIR": "/absolute/path/to/repos"
}
}
}
}Inspector
npm run inspectorTest
npm test # offline smoke (ripgrep backend)
npm run test:sourcegraph # live integration (hits sourcegraph.com)
npm run test:all # bothSkip the network leg with CFM_SKIP_NETWORK=1.
Suggested workflow
- Use
discoverReposwhen you need fresh GitHub popularity/ranking or sources outside the curated map. - Fetch README/source/examples for the best candidate repos.
- Use
searchCodewith concrete anchors: repo names, imports, API calls, component names, config keys, or file paths.
Architecture
MCP client (agent)
│ stdio
▼
src/index.ts ── McpServer ┬─ discoverRepos tool
└─ searchCode tool
│
▼
SearchBackend (interface)
│ │
▼ ▼
SourcegraphBackend RipgrepBackend
(default; remote) (local; CFM_REPOS_DIR)The backend boundary is the whole point: tomorrow we can add Zoekt, on-demand cold-path clones, or stack backends without touching the MCP layer.
Benchmarks
bench/compare.mjs compares sourcegraph.com to grep.app's open API. As of last run:
- grep.app direct API: 0/30 successful (Vercel bot challenge, 429 on every call)
- sourcegraph.com: 30/30 successful, p50 ≈ 1.3s. Later testing found this is not reliable — see the backend note above.
node bench/compare.mjs 20 10Roadmap
- [x] MCP server +
searchCodetool with grep.app-style output - [x] Live GitHub repository discovery (
discoverRepos) - [x] Ripgrep backend (works against any local checkout tree)
- [x] Sourcegraph backend (2M+ public repos, context fetched from raw endpoint)
- [ ] Optional fallback chain (Sourcegraph → ripgrep)
- [ ] Repo crawler for ripgrep corpus (clone top-N by stars, incremental refresh)
- [ ] Zoekt backend (sub-100ms regex on a self-hosted index)
- [ ] On-demand cold path (clone + index any GitHub repo on first miss)
- [ ] HTTP transport for remote hosting
