search_inks_by_name
Find fountain pen inks by name using fuzzy search to match partial or similar ink names in the database.
Instructions
Search for fountain pen inks by name using fuzzy matching
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search term for ink name | |
| max_results | No | Maximum number of results to return (default: 20) |
Implementation Reference
- src/index.ts:325-354 (handler)The main handler function that executes fuzzy name search using Fuse.js on ink metadata, matches with color data, formats results with createSearchResult helper, and returns structured JSON response.private searchInksByName(query: string, maxResults: number): MCPTextResponse { const searchResults = this.fuse.search(query); const results: SearchResult[] = []; for (const result of searchResults.slice(0, maxResults)) { const metadata = result.item; const inkColor = this.inkColors.find((ink) => ink.ink_id === metadata.ink_id); if (inkColor) { results.push(createSearchResult(inkColor, metadata)); } } return { content: [ { type: 'text', text: JSON.stringify( { query, results_count: results.length, results, }, null, 2, ), }, ], } satisfies MCPTextResponse; }
- src/index.ts:143-157 (schema)JSON schema defining the input parameters for the tool: query (string, required) and max_results (number, optional default 20).inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search term for ink name', }, max_results: { type: 'number', description: 'Maximum number of results to return (default: 20)', default: 20, }, }, required: ['query'], },
- src/index.ts:140-158 (registration)Tool registration in the ListTools response, including name, description, and input schema.{ name: 'search_inks_by_name', description: 'Search for fountain pen inks by name using fuzzy matching', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search term for ink name', }, max_results: { type: 'number', description: 'Maximum number of results to return (default: 20)', default: 20, }, }, required: ['query'], }, },
- src/index.ts:271-275 (registration)Handler routing in the CallToolRequestSchema switch statement that invokes the searchInksByName method.case 'search_inks_by_name': return this.searchInksByName( args.query as string, (args.max_results as number) || 20, );
- src/utils.ts:351-363 (helper)Helper function used in the handler to format each search result with ink data, metadata, distance, and URLs to details/images.export function createSearchResult( ink: InkColor, metadata?: InkSearchData, distance?: number, ): SearchResult { return { ink, metadata, distance, url: `https://wilderwrites.ink/ink/${ink.ink_id}`, image_url: `https://wilderwrites.ink/images/inks/${ink.ink_id}-sq.jpg`, }; }