@kenkaiiii/kencode-search
v0.1.11
Published
Self-hosted code search MCP server for AI agents. No rate limits, no shared infra. Searches 2M+ public repos via Sourcegraph or any local checkout via ripgrep.
Downloads
1,369
Maintainers
Readme
@kenkaiiii/kencode-search
npm:
@kenkaiiii/kencode-search· github:KenKaiii/kencode-search
Self-hosted code search MCP server. Your own grep.app for your AI agents — no rate limits, no shared infra.
One tool (searchCode), two backends:
sourcegraph(default) — 2M+ public repos via Sourcegraph's public streaming API. Free, no auth.ripgrep— your local directory of<owner>/<name>checkouts.
Schema mirrors grep.app's searchGitHub so agents already trained on that surface "just work" against this server. 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, no rate limits.
Run manually
# Default: sourcegraph backend, no config needed.
kencode-search-mcp
# Local repo tree:
CFM_BACKEND=ripgrep CFM_REPOS_DIR=/path/to/repos kencode-search-mcpBuild 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.
Tool: searchCode
| Field | Type | Notes |
|---|---|---|
| query | string | Literal pattern (or regex if useRegexp: true). |
| useRegexp | boolean? | RE2 regex syntax. Prefix (?s) for multi-line. |
| matchCase | boolean? | Default false. |
| matchWholeWords | boolean? | Honored by ripgrep; ignored by sourcegraph (use \b in regex). |
| language | string[]? | e.g. ["TypeScript"], ["Python"]. |
| repo | string? | owner/name substring match. |
| path | string? | File path substring filter. |
| maxResults | number? | Default 50, hard cap 200. |
| contextLines | number? | Lines of context per side. Default 5. |
Environment
| Var | Default | Purpose |
|---|---|---|
| CFM_BACKEND | sourcegraph | sourcegraph or ripgrep. |
| CFM_REPOS_DIR | ./repos | Root for ripgrep backend. |
| CFM_SOURCEGRAPH_URL | https://sourcegraph.com | Override base URL. |
| CFM_SOURCEGRAPH_TOKEN | (unset) | Optional access token for higher limits. |
Architecture
MCP client (agent)
│ stdio
▼
src/index.ts ── McpServer ── 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, no rate limit hit
node bench/compare.mjs 20 10Roadmap
- [x] MCP server +
searchCodetool with grep.app-style output - [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
