Skip to content

searchCode

Lexical code search via an embedded Zoekt index (lazy-started on first call).

searchCode(query: str, repo: str | None = None)
ParameterTypeRequiredDescription
querystringyesSearch query (text or regex)
repostringnoIf given, applied as a Zoekt r: filter scoping results to that one repo; omitted, results span every indexed repo
{
"query": "greet",
"hits": [
{ "repo": "toy-repo", "path": "toy/greeter.py", "lineNumber": 5, "lineText": "def greet(name):" }
],
"total": 1
}

This tool has no freshness fields — Zoekt has no per-commit index metadata to report.

Call:

{ "query": "greet" }

Response:

{
"query": "greet",
"hits": [
{ "repo": "toy-repo", "path": "toy/greeter.py", "lineNumber": 5, "lineText": "def greet(name):" }
],
"total": 1
}
{ "query": "nosuchtermanywhere", "hits": [], "total": 0 }

zoekt-webserver is lazy-started on the first searchCode call, tracked with a pidfile, and killed at server exit. The first call takes a couple seconds; subsequent calls return quickly. See Concepts: Zoekt.

Every tool returns a JSON object with an "error" string instead of raising:

{ "error": "zoekt-webserver failed to start" }