search_food_standards
Find specific food preparation standards, recipes, and cooking guidelines from food service literature using search queries.
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)Core handler function implementing the search_food_standards tool logic: expands query with synonyms, searches PDF content via pdfParser, removes duplicates, formats and returns search results.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 defining input validation for search_food_standards tool: requires query string, optional section 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:167-171 (registration)Tool registration in the MCP tool definitions array, including name, description, and input schema converted from Zod.{ 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 (handler)Dispatcher case in the MCP CallToolRequestSchema handler that validates arguments and invokes the searchFoodStandards function.case "search_food_standards": { const { query, section } = searchFoodStandardsSchema.parse(args); return await searchFoodStandards(query, section); }
- src/index.js:41-89 (helper)Helper function to expand search query using predefined synonyms for better matching in food standards search.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; }