Search code across any project — find symbols, references, files by content or meaning. Drop it into any directory, index it, then query via MCP tools (search_code, get_symbol, find_references). Works with Claude Desktop, Cursor, or any MCP-compatible AI agent.
Built at «Богатый Мир Упаковки», Veliky Novgorod
MCP server for code search — ask in chat instead of opening IDE.Разработано в компании «Богатый Мир Упаковки», Великий Новгород
OpenCode Codebase Indexer
Code search via BM25 + embeddings (k-NN HNSW). MCP server for AI agents. Not Google, but good enough to find your way around.
Tools (MCP)
| Tool | What it does |
|------|--------------|
| search_code | Hybrid search (BM25 + k‑NN). Set hybrid=true for semantic search. Filters by language, directory, package. regex mode. include_source=true to return full file body. |
| get_symbol | Find symbol definition(s) by name. Supports multiple names (batch). fuzzy=true for substring matching. include_source=true to return symbol source code. |
| find_references | Find all usages of a symbol. Supports multiple symbols at once. limit caps results. |
| get_file_symbols | List all symbols in a file. Supports multiple files (batch). include_source=true to include each symbol's source code. |
| index_directory | Index a directory (or multiple). Defaults to workspace_path if not specified. |
| analyze_code | Code metrics analysis: file sizes, function counts, long methods, average/max method length. language filter. threshold sets method length limit (default 50 lines). |
| get_stats | Index statistics: document count, size in bytes. |
| list_directory | List directory contents (dirs first, sorted by name). include_hidden to show dotfiles. max_depth sets recursion depth. |
Quick Start
# Start OpenSearch
docker-compose up -d
# Build tools
go build -o indexer ./cmd/indexer
go build -o mcp-server ./cmd/mcp-server
# Index a project via CLI
./indexer index /path/to/project --settings settings.json
# Or run the MCP server (auto-indexes workspace on startup)
./mcp-server --settings settings.json --transport stdio
Indexing a Specific Directory
1. Via settings.json
Set workspace_path to your target project:
{
"workspace_path": "/home/user/my-project",
"indexed_extensions": [".go", ".ts", ".py"],
"auto_index_on_start": true
}
Then start the server — it will index the directory automatically:
./mcp-server --settings settings.json --transport stdio
2. Via CLI indexer (any directory, no config needed)
# Index a single directory
./indexer index /home/user/my-project --settings settings.json
# Index multiple directories
./indexer index /home/user/project-a --settings settings.json
./indexer index /home/user/project-b --settings settings.json
3. Via Docker Compose (mount your project)
Edit docker-compose.yml to mount your target project:
services:
mcp-server:
volumes:
- /home/user/my-project:/workspace # mount your project
- ./settings.docker.json:/app/settings.json
docker-compose up -d
The server will auto-index /workspace on startup.
4. Via MCP tool index_directory at runtime
After the server is running, call the index_directory tool with any path:
index_directory(path: "/home/user/my-project")
This works over both stdio and HTTP transport and does not require a server restart.
Architecture
- Indexer (
cmd/indexer) — scans files, parses with tree-sitter, stores in OpenSearch - File Tracker (
internal/filetracker) — SQLite for incremental indexing (hash + size tracking) - MCP Server (
cmd/mcp-server) — MCP server exposing search & index tools
Project Structure
cmd/
indexer/ # CLI indexer
mcp-server/ # MCP server for AI agents
internal/
config/ # settings.json loader
filetracker/ # SQLite file tracking
scanner/ # filesystem scanner
parser/ # tree-sitter Go parser
opensearch/ # OpenSearch client
mcp/ # MCP server implementation
Configuration
See settings.json:
indexed_extensions— file types to index (.go)exclude_patterns— directories/files to skipworkspace_path— project root to auto-index (.resolves to settings.json dir)auto_index_on_start— whether to index workspace on MCP server startupopensearch— connection settings
MCP Server
Running
# stdio (for Claude Desktop, etc.)
./mcp-server --transport stdio --settings settings.json
# HTTP (with health endpoint)
./mcp-server --transport http --port 3000 --settings settings.json
Docker Compose
docker-compose up -d
- OpenSearch: http://localhost:20900
- MCP HTTP: http://localhost:3000
- Health: http://localhost:3000/health
The current directory is mounted as /workspace inside the container.
TODO
- [ ] Test indexing on non-
.goextensions (.ts,.py,.js,.rs) - [ ] Drop-in file watcher —
watch --dirs ./project-a,./project-b— no Docker needed, just point at folders and go - [ ] Multi-project support — watch several repos simultaneously, keep all indices in one OpenSearch instance