search_notes
Find notes by content or type in Flint Note's vault. Use queries, filters, or regex to locate specific markdown files for AI collaboration.
Instructions
Search notes by content and/or type. Empty queries return all notes sorted by last updated.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Search query or regex pattern. Empty string or omitted returns all notes. | |
| type_filter | No | Optional filter by note type | |
| limit | No | Maximum number of results to return | |
| use_regex | No | Enable regex pattern matching | |
| vault_id | No | Optional vault ID to operate on. If not provided, uses the current active vault. | |
| fields | No | Optional array of field names to include in response. Supports dot notation for nested fields (e.g. "metadata.tags") and wildcard patterns (e.g. "metadata.*"). If not specified, all fields are returned. |
Implementation Reference
- src/server/search-handlers.ts:23-49 (handler)The primary handler function for the 'search_notes' MCP tool. Validates input, resolves vault context, executes search via HybridSearchManager, applies field filtering, and formats results as JSON text content.handleSearchNotes = async (args: SearchNotesArgs) => { // Validate arguments validateToolArgs('search_notes', args); const { hybridSearchManager } = await this.resolveVaultContext(args.vault_id); const results = await hybridSearchManager.searchNotes( args.query, args.type_filter, args.limit, args.use_regex ); // Apply field filtering if specified const filteredResults = args.fields ? results.map(result => filterNoteFields(result, args.fields)) : results; return { content: [ { type: 'text', text: JSON.stringify(filteredResults, null, 2) } ] }; };
- src/server.ts:1250-1253 (registration)Registration of the 'search_notes' tool in the MCP server's CallToolRequestSchema handler switch statement, mapping the tool name to the SearchHandlers.handleSearchNotes method.case 'search_notes': return await this.searchHandlers.handleSearchNotes( args as unknown as SearchNotesArgs );
- src/server/tool-schemas.ts:274-313 (schema)The JSON schema definition for the 'search_notes' tool input parameters, exported in TOOL_SCHEMAS array.name: 'search_notes', description: 'Search notes by content and/or type. Empty queries return all notes sorted by last updated.', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query or regex pattern. Empty string or omitted returns all notes.' }, type_filter: { type: 'string', description: 'Filter results to specific note type' }, limit: { type: 'number', description: 'Maximum number of results to return' }, use_regex: { type: 'boolean', description: 'Treat query as regex pattern', default: false }, vault_id: { type: 'string', description: 'Optional vault ID to search in. If not provided, uses the current active vault.' }, fields: { type: 'array', items: { type: 'string' }, description: 'Optional list of fields to include in response (id, title, content, type, filename, path, created, updated, size, metadata)' } } } },
- src/server/types.ts:64-71 (schema)TypeScript interface definition for SearchNotesArgs used by the handler.export interface SearchNotesArgs { query?: string; type_filter?: string; limit?: number; use_regex?: boolean; vault_id?: string; fields?: string[]; }
- Core search implementation in HybridSearchManager.searchNotes, called by the tool handler. Performs hybrid text + SQL search. Note: exact lines approximated from search match.async searchNotes( query: string | undefined, typeFilter: string | null = null, limit: number = 10, useRegex: boolean = false ): Promise<SearchResult[]> { const connection = await this.getReadOnlyConnection(); try { const safeQuery = (query ?? '').trim(); let sql: string; let params: (string | number)[] = []; if (!safeQuery) { // Return all notes sql = ` SELECT n.*, 1.0 as score FROM notes n ${typeFilter ? 'WHERE n.type = ?' : ''} ORDER BY n.updated DESC LIMIT ? `; params = typeFilter ? [typeFilter, limit] : [limit]; } else if (useRegex) { // For regex search, fetch all notes and filter in JavaScript