search_notes
Search and filter notes by content, type, or regex pattern in the Flint Note system. Retrieve specific fields or limit results for precise note discovery.
Instructions
Search notes by content and/or type. Empty queries return all notes sorted by last updated.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| 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. | |
| limit | No | Maximum number of results to return | |
| query | No | Search query or regex pattern. Empty string or omitted returns all notes. | |
| type_filter | No | Optional filter by note type | |
| use_regex | No | Enable regex pattern matching | |
| vault_id | No | Optional vault ID to operate on. If not provided, uses the current active vault. |
Input Schema (JSON Schema)
{
"properties": {
"fields": {
"description": "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.",
"items": {
"type": "string"
},
"type": "array"
},
"limit": {
"default": 10,
"description": "Maximum number of results to return",
"type": "number"
},
"query": {
"description": "Search query or regex pattern. Empty string or omitted returns all notes.",
"type": "string"
},
"type_filter": {
"description": "Optional filter by note type",
"type": "string"
},
"use_regex": {
"default": false,
"description": "Enable regex pattern matching",
"type": "boolean"
},
"vault_id": {
"description": "Optional vault ID to operate on. If not provided, uses the current active vault.",
"type": "string"
}
},
"required": [],
"type": "object"
}
Implementation Reference
- src/server/search-handlers.ts:23-49 (handler)The handleSearchNotes method implements the core execution logic for the 'search_notes' MCP tool. It validates input arguments, resolves the vault context, performs a hybrid search using the search manager, applies optional field filtering, and returns the results as formatted 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/tool-schemas.ts:274-313 (schema)The input schema definition for the 'search_notes' tool, specifying properties like query, type_filter, limit, use_regex, vault_id, and fields with their types and descriptions.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.ts:1250-1253 (registration)Registration of the 'search_notes' tool in the MCP server's CallToolRequestSchema handler. Maps tool calls to the SearchHandlers.handleSearchNotes method.case 'search_notes': return await this.searchHandlers.handleSearchNotes( args as unknown as SearchNotesArgs );
- src/server.ts:582-624 (registration)Tool listing and schema exposure for 'search_notes' in the ListToolsRequestSchema handler, making the tool discoverable to MCP clients.{ 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: 'Optional filter by note type' }, limit: { type: 'number', description: 'Maximum number of results to return', default: 10 }, use_regex: { type: 'boolean', description: 'Enable regex pattern matching', default: false }, vault_id: { type: 'string', description: 'Optional vault ID to operate on. If not provided, uses the current active vault.' }, fields: { type: 'array', items: { type: 'string' }, description: '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.' } }, required: [] } },
- src/server/search-handlers.ts:17-29 (helper)The SearchHandlers class constructor and method declaration, providing the handler instance used by the server.export class SearchHandlers { constructor(private resolveVaultContext: (vaultId?: string) => Promise<VaultContext>) {} /** * Handles basic note search with optional type filtering and regex support */ handleSearchNotes = async (args: SearchNotesArgs) => { // Validate arguments validateToolArgs('search_notes', args); const { hybridSearchManager } = await this.resolveVaultContext(args.vault_id); const results = await hybridSearchManager.searchNotes(