search_food_standards
Find specific food preparation standards, recipes, and cooking guidelines from food service literature by searching with keywords or phrases.
Instructions
Search for specific food preparation standards, recipes, or cooking guidelines in the food service literature
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search term or phrase to look for in the food standards document | |
| section | No |
Implementation Reference
- src/index.js:284-325 (handler)The primary handler function that executes the 'search_food_standards' tool logic: expands the search query with synonyms, performs multiple searches on the PDF parser, deduplicates results, and returns formatted text output.async function searchFoodStandards(query, section) { // Расширенный поиск с синонимами const expandedQueries = expandSearchQuery(query); let allResults = []; for (const searchQuery of expandedQueries) { const results = pdfParser.searchContent(searchQuery, section); if (results.results) { allResults.push(...results.results); } } // Удаляем дубликаты const uniqueResults = allResults.filter((result, index, self) => index === self.findIndex(r => r.content === result.content) ); let response = `Search results for "${query}"`; if (section) { response += ` in section "${section}"`; } response += `:\n\nFound ${uniqueResults.length} matches\n\n`; if (uniqueResults.length === 0) { response += "No matching content found."; } else { uniqueResults.slice(0, 15).forEach((result, index) => { response += `Result ${index + 1}:\n`; if (result.before) response += `Context: ${result.before}\n`; response += `> ${result.content}\n`; if (result.after) response += `Context: ${result.after}\n`; response += "\n"; }); } return { content: [{ type: "text", text: response }] }; }
- src/index.js:92-95 (schema)Zod schema for input validation of the 'search_food_standards' tool, defining 'query' as required string and 'section' as optional string.const searchFoodStandardsSchema = z.object({ query: z.string().describe("Search term or phrase to look for in the food standards document"), section: z.string().optional().describe("Optional: specific section to search within"), });
- src/index.js:168-171 (registration)Tool registration in the list_tools response: defines name, description, and converts Zod schema to JSON schema for MCP protocol.name: "search_food_standards", description: "Search for specific food preparation standards, recipes, or cooking guidelines in the food service literature", inputSchema: zodToJsonSchema(searchFoodStandardsSchema) },
- src/index.js:222-225 (registration)Dispatcher case in the CallToolRequestSchema handler that parses input with schema and invokes the tool handler function.case "search_food_standards": { const { query, section } = searchFoodStandardsSchema.parse(args); return await searchFoodStandards(query, section); }
- src/index.js:41-89 (helper)Helper function used by the handler to expand search queries using a synonyms dictionary for more comprehensive PDF content matching.function expandSearchQuery(query) { const synonyms = { // Синонимы для блюд 'котлеты': ['котлеты', 'биточки', 'зразы'], 'картофельные': ['картофельные', 'картофель', 'из картофеля'], 'морковные': ['морковные', 'морковь', 'из моркови', 'морковочные'], 'творог': ['творог', 'творожный', 'сыр творожный', 'кварк'], 'суп': ['суп', 'похлебка', 'бульон', 'борщ', 'щи', 'солянка'], 'пиво': ['пиво', 'пивной', 'с пивом', 'на пиве'], 'сладкий': ['сладкий', 'десертный', 'фруктовый'], 'плов': ['плов', 'рис с мясом', 'узбекский плов'], 'борщ': ['борщ', 'свекольный суп', 'украинский борщ'], 'паста': ['паста', 'макароны', 'спагетти', 'лапша'], 'тирамису': ['тирамису', 'итальянский десерт', 'маскарпоне'], 'пельмени': ['пельмени', 'вареники', 'манты', 'хинкали'], 'салат': ['салат', 'оливье', 'овощной'], 'десерт': ['десерт', 'сладкое', 'торт', 'пирог', 'выпечка'], // Синонимы для процессов 'приготовление': ['приготовление', 'готовка', 'варка', 'жарка', 'тушение'], 'температура': ['температура', 'градус', 'нагрев', 'охлаждение'], 'безопасность': ['безопасность', 'гигиена', 'санитария', 'чистота'], 'хранение': ['хранение', 'консервация', 'сохранность'], // Синонимы для ингредиентов 'мясо': ['мясо', 'говядина', 'свинина', 'баранина', 'курица'], 'овощи': ['овощи', 'морковь', 'лук', 'капуста', 'картофель'], 'специи': ['специи', 'приправы', 'пряности', 'соль', 'перец'] }; const queryWords = query.toLowerCase().split(/\s+/); const expandedQueries = [query]; // Включаем оригинальный запрос // Добавляем варианты с синонимами for (const word of queryWords) { if (synonyms[word]) { for (const synonym of synonyms[word]) { if (synonym !== word) { const newQuery = query.replace(new RegExp(word, 'gi'), synonym); if (!expandedQueries.includes(newQuery)) { expandedQueries.push(newQuery); } } } } } return expandedQueries; }