refactor: remove single collection param, use collections array only

BREAKING: collection param removed from structured_search.
Use collections: ['name'] for single collection filter.
This commit is contained in:
Tobi Lütke 2026-02-18 22:16:15 -05:00
parent efb39616e6
commit 77e4d8f378
No known key found for this signature in database
4 changed files with 8 additions and 14 deletions

View File

@ -82,11 +82,11 @@ Note: `-term` and `OR` only work in lex queries, not vec/hyde.
### Collection Filtering
```json
{ "collection": "docs" } // Single collection
{ "collections": ["docs", "notes"] } // Multiple (OR)
{ "collections": ["docs"] } // Single
{ "collections": ["docs", "notes"] } // Multiple (OR)
```
Omit both to search all collections.
Omit to search all collections.
## Other MCP Tools

View File

@ -261,11 +261,10 @@ function createMcpServer(store: Store): McpServer {
),
limit: z.number().optional().default(10).describe("Maximum number of results (default: 10)"),
minScore: z.number().optional().default(0).describe("Minimum relevance score 0-1 (default: 0)"),
collection: z.string().optional().describe("Filter to a single collection by name"),
collections: z.array(z.string()).optional().describe("Filter to multiple collections (OR match)"),
collections: z.array(z.string()).optional().describe("Filter to specific collections (OR match)"),
},
},
async ({ searches, limit, minScore, collection, collections }) => {
async ({ searches, limit, minScore, collections }) => {
// Map to internal format
const subSearches: StructuredSubSearch[] = searches.map(s => ({
type: s.type,
@ -273,7 +272,6 @@ function createMcpServer(store: Store): McpServer {
}));
const results = await structuredSearch(store, subSearches, {
collection,
collections,
limit,
minScore,
@ -581,7 +579,6 @@ export async function startMcpHttpServer(port: number, options?: { quiet?: boole
}));
const results = await structuredSearch(store, subSearches, {
collection: params.collection,
collections: params.collections,
limit: params.limit ?? 10,
minScore: params.minScore ?? 0,

View File

@ -2135,7 +2135,7 @@ async function querySearch(query: string, opts: OutputOptions, _embedModel: stri
process.stderr.write(`${c.dim}└─ Searching...${c.reset}\n`);
results = await structuredSearch(store, structuredQueries, {
collection: singleCollection,
collections: singleCollection ? [singleCollection] : undefined,
limit: opts.all ? 500 : (opts.limit || 10),
minScore: opts.minScore || 0,
hooks: {

View File

@ -3199,8 +3199,7 @@ export interface StructuredSubSearch {
}
export interface StructuredSearchOptions {
collection?: string; // Single collection filter
collections?: string[]; // Multiple collections filter (OR)
collections?: string[]; // Filter to specific collections (OR match)
limit?: number; // default 10
minScore?: number; // default 0
candidateLimit?: number; // default RERANK_CANDIDATE_LIMIT
@ -3237,9 +3236,7 @@ export async function structuredSearch(
const candidateLimit = options?.candidateLimit ?? RERANK_CANDIDATE_LIMIT;
const hooks = options?.hooks;
// Normalize collection filter to array (undefined = all collections)
const collections: string[] | undefined = options?.collections
?? (options?.collection ? [options.collection] : undefined);
const collections = options?.collections;
if (searches.length === 0) return [];