Skip to main content
Glama
rogertheunissenmerge-oss

SommelierX Wine Pairing MCP

search_ingredients

Discover which ingredients are available for wine pairing. Search by name to get ingredient IDs, names, and groups.

Instructions

Search for ingredients in the SommelierX database. Returns ingredient names, IDs, and groups. Use this to discover available ingredients before using pair_wine_with_ingredients. Best for: "What mushroom ingredients are available?" | Auth: API key (Bearer sk_live_...) or x402 payment (USDC on Base) | Price: $0.005/call

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch term for ingredients (e.g. "mushroom", "cheese", "salmon")
languageNoLanguage code for results (e.g. "en", "nl", "fr"). Defaults to "en".

Implementation Reference

  • The executeSearchIngredients function (line 36-56) is the main handler that calls the SommelierX API /api/v1/ingredients with search and language params, then formats results via formatIngredientResults (line 61-88).
    /**
     * Tool: search_ingredients
     *
     * Search for ingredients in the SommelierX database.
     * Useful for discovering available ingredients before using
     * the pair_wine_with_ingredients tool.
     */
    
    import { z } from 'zod';
    import type { SommelierXClient } from '../client.js';
    import type { ServerConfig } from '../config.js';
    import type { IngredientListResult, IngredientItem } from './types.js';
    
    /** Zod schema for tool input validation. */
    export const searchIngredientsSchema = z.object({
      query: z
        .string()
        .min(2, 'Search query must be at least 2 characters')
        .max(100)
        .describe('Search term for ingredients (e.g. "mushroom", "cheese", "salmon")'),
      language: z
        .string()
        .min(2)
        .max(10)
        .optional()
        .describe('Language code for results (e.g. "en", "nl", "fr"). Defaults to "en".'),
    });
    
    export type SearchIngredientsInput = z.infer<typeof searchIngredientsSchema>;
    
    /**
     * Execute the search_ingredients tool.
     *
     * Calls /api/v1/ingredients?search=... and formats the results.
     */
    export async function executeSearchIngredients(
      client: SommelierXClient,
      config: ServerConfig,
      input: SearchIngredientsInput,
    ): Promise<string> {
      const language = input.language ?? config.defaultLanguage;
    
      let result: IngredientListResult;
      try {
        result = await client.get<IngredientListResult>('/api/v1/ingredients', {
          search: input.query,
          language,
          perPage: '20',
        });
      } catch (error: unknown) {
        const message = error instanceof Error ? error.message : 'Unknown error';
        return `Error searching ingredients: ${message}`;
      }
    
      return formatIngredientResults(input.query, result.data, result.total);
    }
    
    /**
     * Format the ingredient search results into a human-readable string.
     */
    function formatIngredientResults(
      query: string,
      ingredients: IngredientItem[],
      total: number,
    ): string {
      const lines: string[] = [];
    
      lines.push(`Ingredient search results for "${query}" (${total} total):`);
      lines.push('');
    
      if (ingredients.length === 0) {
        lines.push('No ingredients found matching your search.');
        lines.push('Try a different search term or language.');
        return lines.join('\n');
      }
    
      for (const ingredient of ingredients) {
        const groupSuffix = ingredient.group ? ` [${ingredient.group}]` : '';
        lines.push(`- ${ingredient.name} (id: ${ingredient.id})${groupSuffix}`);
      }
    
      if (total > ingredients.length) {
        lines.push('');
        lines.push(`Showing ${ingredients.length} of ${total} results. Refine your search for more specific results.`);
      }
    
      return lines.join('\n');
    }
  • The searchIngredientsSchema Zod schema defines the input validation for the search_ingredients tool: a required 'query' (min 2 chars) and an optional 'language' parameter.
    /** Zod schema for tool input validation. */
    export const searchIngredientsSchema = z.object({
      query: z
        .string()
        .min(2, 'Search query must be at least 2 characters')
        .max(100)
        .describe('Search term for ingredients (e.g. "mushroom", "cheese", "salmon")'),
      language: z
        .string()
        .min(2)
        .max(10)
        .optional()
        .describe('Language code for results (e.g. "en", "nl", "fr"). Defaults to "en".'),
    });
  • src/index.ts:121-132 (registration)
    The tool is registered with MCP server.tool() at line 123-132 under the name 'search_ingredients' with its schema.shape and a handler that parses input and calls executeSearchIngredients.
    // ── Tool 5: search_ingredients ──
    
    server.tool(
      'search_ingredients',
      'Search for ingredients in the SommelierX database. Returns ingredient names, IDs, and groups. Use this to discover available ingredients before using pair_wine_with_ingredients. Best for: "What mushroom ingredients are available?" | Auth: API key (Bearer sk_live_...) or x402 payment (USDC on Base) | Price: $0.005/call',
      searchIngredientsSchema.shape,
      async (input) => {
        const parsed = searchIngredientsSchema.parse(input);
        const result = await executeSearchIngredients(client, config, parsed);
        return { content: [{ type: 'text' as const, text: result }] };
      },
    );
  • Barrel re-export of searchIngredientsSchema and executeSearchIngredients from the search-ingredients module for centralized tool registration.
    export {
      searchIngredientsSchema,
      executeSearchIngredients,
    } from './search-ingredients.js';
  • Type definitions used by the search_ingredients tool: IngredientItem (id, name, group, description) and IngredientListResult (paginated list with data, total, page, perPage).
    /** Ingredient from search/list. */
    export interface IngredientItem {
      id: number;
      name: string;
      group?: string;
      description?: string;
    }
    
    /** Paginated ingredient list. */
    export interface IngredientListResult {
      data: IngredientItem[];
      total: number;
      page: number;
      perPage: number;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description bears full burden. It discloses read-like behavior (search) and mentions auth and pricing, but does not cover pagination, rate limits, or exact side effects. Adequate but not exhaustive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences plus succinct best-use and auth/pricing lines. No filler, front-loaded with purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Missing output schema, but description mentions return fields (names, IDs, groups). For a simple search tool with few parameters, this is largely sufficient. Could benefit from hinting at result format.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% coverage with descriptions for both parameters. Description adds little beyond repeating parameter examples (e.g., 'mushroom'). Baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states it searches for ingredients in a specific database and returns names, IDs, and groups. It differentiates itself from sibling tools like pair_wine_with_ingredients by positioning itself as a discovery tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides a best-use example ('What mushroom ingredients are available?') and explicitly directs to use before pair_wine_with_ingredients. Mentions authentication and pricing, but lacks explicit guidance on when not to use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rogertheunissenmerge-oss/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server