Code Repositories
Synapse can index code repositories and give agents the ability to search them semantically. Agents describe what they're looking for in plain language and receive file names, line numbers, and relevant code snippets.
How it works
- You add a repo (local path on the server)
- Synapse walks the directory tree, chunks files by function/class/section
- Each chunk is embedded using a vector model and stored in PostgreSQL + pgvector
- Agents call
search_codebasewith a natural language query - Synapse returns the top-k most semantically similar chunks
Prerequisites
- PostgreSQL with the
pgvectorextension - An embedding model (Gemini by default, or any configured local embedding model)
Setting up PostgreSQL + pgvector
Automatic setup (recommended):
Go to Settings → Code Search Setup, enter your PostgreSQL credentials, and click Setup. Synapse creates the database and enables pgvector automatically.
Manual setup:
CREATE DATABASE synapse;
\c synapse
CREATE EXTENSION vector;
Set the connection string in settings:
{ "sql_connection_string": "postgresql://user:password@localhost:5432/synapse" }
Then enable code embeddings:
{ "embed_code": true }
Adding a repository
Go to Settings → Code Repos → Add Repo.
| Field | Default | Description |
|---|---|---|
| Name | — | Display name |
| Path | — | Absolute path to the repo on the server |
| Description | — | What this codebase does |
| Included patterns | .py .ts .tsx .js .jsx .rs .go .java .md .html .vue .css .scss .cpp .c | File types to index |
| Excluded patterns | node_modules __pycache__ venv .git *.pyc + dotfiles | Files/dirs to skip |
| Embedding model provider | gemini | Which provider to use for embeddings |
Indexing
Click Index to start indexing. Status transitions:
pending → indexing → indexed
Indexing progress shows the file count. Large repos (10k+ files) may take several minutes.
Re-indexing
After significant code changes, re-index to update the embeddings. Click Re-index on the repo card. The index is rebuilt incrementally where possible.
Assigning repos to agents
In the agent editor, set repos to the list of repo IDs:
"repos": ["repo-abc123"]
The code agent type is designed for this use case and includes system prompt guidance for using search_codebase effectively.
Filesystem access
The Filesystem MCP server can complement code search by giving agents full read/write access to the repo files:
{
"name": "filesystem",
"server_type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/repo"]
}
Together, search_codebase (find relevant files) + filesystem MCP (read/edit files) gives agents a complete software engineering workflow.
Embedding models
| Provider | Model | Notes |
|---|---|---|
gemini | text-embedding-004 | Default. Good quality, requires Gemini API key. |
local | Any local embedding model | Set local_compatible_embed_models in settings |
openai_compatible | Any compatible model | Set openai_compatible_embed_models in settings |