Skip to main content

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

  1. You add a repo (local path on the server)
  2. Synapse walks the directory tree, chunks files by function/class/section
  3. Each chunk is embedded using a vector model and stored in PostgreSQL + pgvector
  4. Agents call search_codebase with a natural language query
  5. Synapse returns the top-k most semantically similar chunks

Prerequisites

  • PostgreSQL with the pgvector extension
  • 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.

FieldDefaultDescription
NameDisplay name
PathAbsolute path to the repo on the server
DescriptionWhat this codebase does
Included patterns.py .ts .tsx .js .jsx .rs .go .java .md .html .vue .css .scss .cpp .cFile types to index
Excluded patternsnode_modules __pycache__ venv .git *.pyc + dotfilesFiles/dirs to skip
Embedding model providergeminiWhich 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

ProviderModelNotes
geminitext-embedding-004Default. Good quality, requires Gemini API key.
localAny local embedding modelSet local_compatible_embed_models in settings
openai_compatibleAny compatible modelSet openai_compatible_embed_models in settings