// Semantic code search with VectorCode using embeddings for finding code by meaning, not just keywords. Use when searching for code patterns, similar implementations, concept-based search, or when keyword search fails. Automatically available via MCP.
| name | VectorCode Semantic Search |
| description | Semantic code search with VectorCode using embeddings for finding code by meaning, not just keywords. Use when searching for code patterns, similar implementations, concept-based search, or when keyword search fails. Automatically available via MCP. |
| allowed-tools | mcp__vectorcode, Read, Grep, Glob |
Expert knowledge for using VectorCode's semantic code search capabilities through MCP integration. VectorCode indexes code using embeddings, enabling searches based on meaning and context rather than exact keyword matches.
Semantic Search
Index Management
Query Optimization
โ Use VectorCode when:
โ Use Grep/Glob instead when:
๐ Combine both when:
// Tool: mcp__vectorcode__ls
// Lists all projects that have been indexed by VectorCode
// Parameters: none
// Returns: List of project root paths
// Use this first to verify what's indexed
When to use:
// Tool: mcp__vectorcode__query
// Performs semantic search across indexed code
{
"n_query": 10, // Number of results to return
"query_messages": [ // Array of search keywords/phrases
"authentication",
"user login",
"session management"
],
"project_root": "/path/to/project" // Must match indexed path
}
Parameters:
n_query (number): Results to return (start with 10-20)query_messages (array): Distinct keywords or phrasesproject_root (string): Exact path from ls outputReturns:
// Tool: mcp__vectorcode__vectorise
// Adds files to VectorCode's embedding index
{
"paths": [
"/absolute/path/to/file1.py",
"/absolute/path/to/file2.js"
],
"project_root": "/path/to/project"
}
When to use:
Important: Use absolute paths for files
// Tool: mcp__vectorcode__files_ls
// Lists all files indexed for a specific project
{
"project_root": "/path/to/project"
}
When to use:
// Tool: mcp__vectorcode__files_rm
// Removes files from the index
{
"files": [
"/absolute/path/to/file1.py",
"/absolute/path/to/file2.js"
],
"project_root": "/path/to/project"
}
When to use:
โ Good queries:
// Concept-based
["database connection", "connection pooling"]
// Functional intent
["user authentication", "password validation"]
// Pattern-based
["error handling", "try catch", "exception"]
// Domain-specific
["HTTP request", "API endpoint", "REST"]
โ Poor queries:
// Too specific (use grep instead)
["function getUserById"]
// Single generic word
["data"]
// Implementation details (language-specific)
["async def", "try:"]
Conceptual, not literal
Distinct and orthogonal
Multiple perspectives
Domain language
# Round 1: Broad concept
query: ["authentication", "login"]
result: Too many results
# Round 2: Narrow with context
query: ["OAuth authentication", "token validation"]
result: Better, but missing some
# Round 3: Add related concepts
query: ["OAuth", "JWT token", "bearer authentication"]
result: Good coverage
# If still too broad, reduce n_query or use grep to filter
// Step 1: List indexed projects
mcp__vectorcode__ls()
// Step 2: Broad exploration
mcp__vectorcode__query({
n_query: 20,
query_messages: ["main entry point", "application startup", "initialization"],
project_root: "/path/to/project"
})
// Step 3: Follow specific area
mcp__vectorcode__query({
n_query: 15,
query_messages: ["database schema", "models", "ORM"],
project_root: "/path/to/project"
})
// Looking for similar error handling
mcp__vectorcode__query({
n_query: 10,
query_messages: ["error handling", "exception management", "retry logic"],
project_root: "/path/to/project"
})
// Looking for API patterns
mcp__vectorcode__query({
n_query: 15,
query_messages: ["REST API", "HTTP handler", "endpoint routing"],
project_root: "/path/to/project"
})
// Find authentication across different modules
mcp__vectorcode__query({
n_query: 20,
query_messages: ["authentication", "authorization", "access control"],
project_root: "/path/to/project"
})
// Results will include frontend, backend, middleware, etc.
// Find where external services are used
mcp__vectorcode__query({
n_query: 15,
query_messages: ["external API", "third party", "service integration"],
project_root: "/path/to/project"
})
// Find database access patterns
mcp__vectorcode__query({
n_query: 15,
query_messages: ["database query", "SQL", "data access"],
project_root: "/path/to/project"
})
// Find configuration handling
mcp__vectorcode__query({
n_query: 10,
query_messages: ["configuration", "settings", "environment variables"],
project_root: "/path/to/project"
})
// Find where feature is implemented
mcp__vectorcode__query({
n_query: 15,
query_messages: ["user registration", "signup", "account creation"],
project_root: "/path/to/project"
})
// Then use grep for specific details
// grep -r "createUser" <files-from-vectorcode>
# Stage 1: VectorCode for discovery
# Broad semantic search to find relevant areas
mcp__vectorcode__query({
n_query: 20,
query_messages: ["payment processing", "transaction"],
project_root: "/path/to/project"
})
# Results: src/payments/processor.py, src/api/checkout.py, ...
# Stage 2: Grep for specifics
# Now search specific files for exact patterns
grep -r "process_payment" src/payments/ src/api/
# Use VectorCode to find candidates
# Use Grep to verify exact matches
# 1. Semantic search
vectorcode: "configuration loading"
# Returns: config.py, settings.py, env.py
# 2. Verify with grep
grep -l "load_config\|read_settings" config.py settings.py env.py
# 1. Check if project is indexed
mcp__vectorcode__ls()
# 2. If not indexed, run vectorcode init (see vectorcode-init command)
# This typically happens automatically via git hooks
# 3. Verify files are indexed
mcp__vectorcode__files_ls({project_root: "/path/to/project"})
# 4. Add missing files if needed
mcp__vectorcode__vectorise({
paths: ["/path/to/new_file.py"],
project_root: "/path/to/project"
})
# After major changes
# 1. Add new files
mcp__vectorcode__vectorise({
paths: ["/path/to/new_module.py", "/path/to/new_util.js"],
project_root: "/path/to/project"
})
# 2. Remove deleted files
mcp__vectorcode__files_rm({
files: ["/path/to/old_file.py"],
project_root: "/path/to/project"
})
# 3. For updated files, re-vectorize
# (removing and re-adding automatically re-indexes)
# Check if file is indexed
mcp__vectorcode__files_ls({project_root: "/path/to/project"})
# Look for specific file in results
# If missing, add it
mcp__vectorcode__vectorise({
paths: ["/path/to/missing_file.py"],
project_root: "/path/to/project"
})
# Verify project root matches exactly
# Common mistake: "/path/to/project" vs "/path/to/project/"
// Combine multiple related concepts
mcp__vectorcode__query({
n_query: 25,
query_messages: [
"authentication",
"authorization",
"permission check",
"access control",
"role based"
],
project_root: "/path/to/project"
})
// Start broad
n_query: 30
query: ["feature X"]
// Analyze results, then narrow
n_query: 15
query: ["feature X", "specific aspect", "related concept"]
// Further refinement
n_query: 10
query: ["very specific aspect", "implementation detail"]
// VectorCode works across languages
mcp__vectorcode__query({
n_query: 20,
query_messages: ["async operations", "concurrency", "parallel execution"],
project_root: "/path/to/project"
})
// Will find async/await (JS), asyncio (Python), goroutines (Go), etc.
Query Size:
n_query: 10-15 for focused results20-30 for broad explorationQuery Formulation:
Project Root:
mcp__vectorcode__lsIndexing:
// Don't do this
query: ["def process_payment(amount, user_id):"]
// Do this instead
query: ["payment processing", "transaction handling"]
// Too broad
query: ["function"]
// Better
query: ["utility functions", "helper methods", "common operations"]
// If ls shows: "/Users/name/project"
// Don't use: "/Users/name/project/" โ
// Use: "/Users/name/project" โ
// VectorCode finds semantic similarity, not exact matches
// For exact matches, use grep
Combine with:
Workflow:
| Need | Tool | Why |
|---|---|---|
| Find by concept | VectorCode | Semantic understanding |
| Find exact string | grep/rg | Fast, exhaustive |
| Find files by name | fd/glob | File system patterns |
| Explore unknown code | VectorCode | No prior knowledge needed |
| Verify completeness | grep | Exhaustive search |
| Find similar code | VectorCode | Pattern recognition |
mcp__vectorcode__ls - List indexed projectsmcp__vectorcode__query - Semantic code searchmcp__vectorcode__vectorise - Add files to indexmcp__vectorcode__files_ls - List indexed filesmcp__vectorcode__files_rm - Remove files from indexn_query - Number of results (10-30 typical)query_messages - Array of distinct keywordsproject_root - Exact project path from ls// Exploration
["main functionality", "core logic", "entry point"]
// Feature location
["user authentication", "login flow", "session management"]
// Pattern discovery
["error handling", "retry logic", "fallback"]
// Architecture
["database access", "API integration", "service layer"]
vectorcode init --hooks to auto-index on commits.vectorcode.include and .vectorcode.exclude control indexing