full_text_search
Search and retrieve relevant content from Obsidian vaults stored in iCloud Drive using tokenized queries. Summarize results to quickly find and interact with specific notes.
Instructions
Tokenize the user's query and the search engine tool will return relevant contents. summarized those contents based on the user's query.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- src/file-system.ts:367-414 (handler)The core handler function for 'full_text_search' that parses args, builds a flexsearch index from markdown files in the vault, searches for the query, and returns matching content snippets.export async function fullTextSearch(args?: Record<string, unknown>) { const parsed = FullTextSearchArgsSchema.safeParse(args) if (!parsed.success) { throw new Error(`Invalid arguments for full_text_search: ${parsed.error}`) } const filePaths = await getAllMarkdownPaths(process.argv.slice(2)) const documents = await readAllMarkdowns(filePaths) const index = new flexsearch.Document({ document: { id: 'id', store: true, index: [ { field: 'title', tokenize: 'forward', encoder: flexsearch.Charset.LatinBalance }, { field: 'content', tokenize: 'forward', encoder: flexsearch.Charset.LatinBalance } ] } }) documents.forEach((file) => { index.add(file) }) const searchedIds = index.search(parsed.data.query, { limit: 5 }) const filteredDocuments = documents .filter(({ id }) => searchedIds[0].result.includes(id)) .map((document) => document.content) return { content: [ { type: 'text', text: filteredDocuments.length > 0 ? filteredDocuments.join('\n---\n') : 'No matches found' } ] } }
- src/schemas.ts:55-57 (schema)Zod schema defining the input for full_text_search: a required 'query' string.export const FullTextSearchArgsSchema = z.object({ query: z.string() })
- src/index.ts:158-161 (registration)Tool registration in listToolsRequestHandler, specifying name, description from prompt, and input schema.name: 'full_text_search', description: fullTextSearchDirectoryPrompt(), inputSchema: zodToJsonSchema(FullTextSearchArgsSchema) as ToolInput }
- src/index.ts:215-217 (registration)Handler dispatch in callToolRequestHandler switch statement that invokes the fullTextSearch function.case 'full_text_search': { return fullTextSearch(args) }
- src/prompts.ts:54-56 (helper)Prompt string used in tool description for full_text_search.export const fullTextSearchDirectoryPrompt = () => "Tokenize the user's query and the search engine tool will return relevant contents. " + "summarized those contents based on the user's query."