search_code
Full-text code search with regex, repo filters, and language filters. Returns matched lines with context.
Code Search includes a built-in Model Context Protocol (MCP) server that lets AI assistants search your code, browse files, and navigate symbols directly.
The MCP server exposes 8 tools:
search_code
Full-text code search with regex, repo filters, and language filters. Returns matched lines with context.
list_repos
List all indexed repositories with filtering by name and status. Supports pagination.
get_repo_branches
Get branches and tags for a repository by ID.
get_file_tree
Browse directory contents in a repository at a specific path and ref.
get_file_content
Read file contents with automatic binary detection and language identification.
search_symbols
Search for symbol definitions — functions, classes, methods, variables.
go_to_definition
Jump to a symbol’s definition from a specific file location (line + column).
find_references
Find all usages of a symbol across the repository.
make build# Binary is at bin/mcp-server# Stdio mode — for Claude Desktop, Cursor, etc../bin/mcp-server --api-url http://localhost:8080# HTTP mode — for remote or browser-based clients./bin/mcp-server --api-url http://localhost:8080 \ --transport http \ --http-addr :9090Or use the Makefile shortcuts:
make dev-mcp # Stdio modemake dev-mcp-http # HTTP mode on :9090| Flag | Default | Description |
|---|---|---|
--api-url | http://localhost:8080 | Code Search API server URL |
--auth-token | — | Authentication token for the API (env: CODE_SEARCH_AUTH_TOKEN) |
--transport | stdio | Transport type: stdio or http |
--http-addr | :9090 | HTTP listen address (only for http transport) |
Environment variables override flags:
| Variable | Overrides | Description |
|---|---|---|
CODE_SEARCH_API_URL | --api-url | API server URL |
CODE_SEARCH_AUTH_TOKEN | --auth-token | API authentication token |
CODE_SEARCH_MCP_TRANSPORT | --transport | Transport type |
CODE_SEARCH_MCP_HTTP_ADDR | --http-addr | HTTP listen address |
Enterprise deployments with SSO/OIDC require an API token for MCP server access. Without a token, the API will reject requests with 401 Unauthorized.
Creating an API token:
cse_ prefix)Passing the token:
Via command-line flag:
./bin/mcp-server --api-url http://localhost:8080 --auth-token cse_your_token_hereVia environment variable:
export CODE_SEARCH_AUTH_TOKEN=cse_your_token_here./bin/mcp-server --api-url http://localhost:8080Add to your claude_desktop_config.json:
{ "mcpServers": { "code-search": { "command": "/path/to/bin/mcp-server", "args": ["--api-url", "http://localhost:8080"], "env": { "CODE_SEARCH_AUTH_TOKEN": "cse_your_token_here" } } }}Add to your .mcp.json or project settings:
{ "mcpServers": { "code-search": { "command": "/path/to/bin/mcp-server", "args": ["--api-url", "http://localhost:8080"], "env": { "CODE_SEARCH_AUTH_TOKEN": "cse_your_token_here" } } }}Add to Cursor’s MCP settings:
{ "mcpServers": { "code-search": { "command": "/path/to/bin/mcp-server", "args": ["--api-url", "http://localhost:8080"], "env": { "CODE_SEARCH_AUTH_TOKEN": "cse_your_token_here" } } }}For remote setups where the AI client can’t run local processes:
# Start MCP server in HTTP mode./bin/mcp-server --transport http --http-addr :9090 \ --api-url http://your-code-search:8080Then configure your client to connect to http://your-mcp-host:9090.
Search across all indexed repositories.
| Parameter | Required | Default | Description |
|---|---|---|---|
query | Yes | — | Search query (Zoekt syntax or regex) |
repos | No | all | Comma-separated repo filter |
languages | No | all | Comma-separated language filter |
file_patterns | No | all | File glob patterns |
is_regex | No | false | Treat query as regex |
case_sensitive | No | false | Case-sensitive matching |
context_lines | No | 2 | Lines of context around matches |
limit | No | 50 | Maximum results |
List indexed repositories.
| Parameter | Required | Default | Description |
|---|---|---|---|
search | No | — | Filter by name |
status | No | — | Filter by status |
limit | No | 50 | Maximum results |
offset | No | 0 | Pagination offset |
Browse directory contents.
| Parameter | Required | Default | Description |
|---|---|---|---|
repo_id | Yes | — | Repository ID |
path | No | root | Directory path |
ref | No | HEAD | Branch, tag, or commit |
Read a file.
| Parameter | Required | Default | Description |
|---|---|---|---|
repo_id | Yes | — | Repository ID |
path | Yes | — | File path |
ref | No | HEAD | Branch, tag, or commit |
Search for symbol definitions (requires SCIP indexing).
| Parameter | Required | Default | Description |
|---|---|---|---|
repo_id | Yes | — | Repository ID |
query | Yes | — | Symbol name pattern |
limit | No | 20 | Maximum results |
Jump to a symbol’s definition.
| Parameter | Required | Default | Description |
|---|---|---|---|
repo_id | Yes | — | Repository ID |
file | Yes | — | File path |
line | Yes | — | Line number (1-indexed) |
column | Yes | — | Column number (0-indexed) |
Find all references to a symbol.
| Parameter | Required | Default | Description |
|---|---|---|---|
repo_id | Yes | — | Repository ID |
file | Yes | — | File path |
line | Yes | — | Line number (1-indexed) |
column | Yes | — | Column number (0-indexed) |
limit | No | 50 | Maximum results |
AI Assistant (Claude, Cursor, etc.) │ │ MCP Protocol (stdio or HTTP) │ ▼MCP Server (bin/mcp-server) │ │ REST API (HTTP) │ ▼Code Search API Server (:8080) │ ├── PostgreSQL (metadata) ├── Redis (job queue) └── Zoekt (search index)The MCP server is a stateless proxy — it translates MCP tool calls into Code Search API requests. It can run alongside the AI client (stdio) or as a shared service (HTTP).