Skip to main content
Glama
rogertheunissenmerge-oss

SommelierX Wine Pairing MCP

pair_wine_with_recipe_url

Extract ingredients from a recipe URL and get top 5 wine matches. Ideal for deciding what wine goes with your recipe.

Instructions

Extract ingredients from a recipe URL and find wine pairings. Provide a URL to a recipe page and get the recipe name, extracted ingredients, and top 5 wine matches. Requires Pro tier. Best for: "What wine goes with this recipe?" | Auth: API key (Bearer sk_live_...) or x402 payment (USDC on Base) | Price: $0.02/call (PRO)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL of a recipe page (e.g. "https://www.allrecipes.com/recipe/...")
languageNoLanguage code for results (e.g. "en", "nl", "fr"). Defaults to "en".

Implementation Reference

  • Main handler: extracts ingredients from a recipe URL via /api/v1/recipes/extract, filters matched ingredients, then calls /api/v1/pairing/calculate to get wine pairings, and formats the combined response.
    export async function executePairWineWithRecipeUrl(
      client: SommelierXClient,
      config: ServerConfig,
      input: PairWineWithRecipeUrlInput,
    ): Promise<string> {
      const language = input.language ?? config.defaultLanguage;
    
      // Step 1: Extract ingredients from the recipe URL
      let recipe: RecipeExtractResult;
      try {
        recipe = await client.post<RecipeExtractResult>('/api/v1/recipes/extract', {
          url: input.url,
          language,
        });
      } catch (error: unknown) {
        if (error instanceof SommelierXApiError) {
          if (error.statusCode === 403) {
            return [
              'Recipe extraction requires a Pro or Enterprise API key.',
              'The current MCP server is running without an API key or with a Free tier key.',
              '',
              'To use this feature:',
              '1. Get a Pro API key at https://api.sommelierx.com',
              '2. Set the SOMMELIERX_API_KEY environment variable in your MCP config',
              '',
              'Alternative: use pair_wine_with_ingredients and provide the ingredients manually.',
            ].join('\n');
          }
          return `Error extracting recipe: ${error.message}`;
        }
        const message = error instanceof Error ? error.message : 'Unknown error';
        return `Error extracting recipe: ${message}`;
      }
    
      // Step 2: Filter to matched ingredients with database IDs
      const matchedIngredients = recipe.ingredients.filter(
        (ing) => ing.id !== undefined && ing.id !== null && ing.matched !== false,
      );
    
      if (matchedIngredients.length === 0) {
        return [
          `Extracted recipe "${recipe.name}" from ${recipe.source}`,
          `Found ${recipe.ingredients.length} ingredients, but none could be matched to the database.`,
          '',
          'Try using pair_wine_with_ingredients with the ingredient names directly.',
        ].join('\n');
      }
    
      // Step 3: Calculate pairing
      const pairingInput = matchedIngredients.map((ing) => ({
        id: ing.id as number,
        amount: 'medium' as const,
      }));
    
      let pairingResult: PairingResult;
      try {
        pairingResult = await client.post<PairingResult>('/api/v1/pairing/calculate', {
          ingredients: pairingInput,
          language,
        });
      } catch (error: unknown) {
        const message = error instanceof Error ? error.message : 'Unknown error';
        return `Extracted recipe "${recipe.name}" but pairing calculation failed: ${message}`;
      }
    
      return formatRecipePairingResponse(recipe, matchedIngredients, pairingResult.results);
    }
  • Zod schema defining the input: a required 'url' (valid URL string) and optional 'language' (2-10 chars).
    export const pairWineWithRecipeUrlSchema = z.object({
      url: z
        .string()
        .url('Must be a valid URL')
        .describe('URL of a recipe page (e.g. "https://www.allrecipes.com/recipe/...")'),
      language: z
        .string()
        .min(2)
        .max(10)
        .optional()
        .describe('Language code for results (e.g. "en", "nl", "fr"). Defaults to "en".'),
    });
  • src/index.ts:110-119 (registration)
    Registration of the tool on the MCP server with its name, description, schema shape, and handler callback.
    server.tool(
      'pair_wine_with_recipe_url',
      'Extract ingredients from a recipe URL and find wine pairings. Provide a URL to a recipe page and get the recipe name, extracted ingredients, and top 5 wine matches. Requires Pro tier. Best for: "What wine goes with this recipe?" | Auth: API key (Bearer sk_live_...) or x402 payment (USDC on Base) | Price: $0.02/call (PRO)',
      pairWineWithRecipeUrlSchema.shape,
      async (input) => {
        const parsed = pairWineWithRecipeUrlSchema.parse(input);
        const result = await executePairWineWithRecipeUrl(client, config, parsed);
        return { content: [{ type: 'text' as const, text: result }] };
      },
    );
  • Helper function that formats the recipe name, matched ingredients, and top 5 wine recommendations into a human-readable string.
    function formatRecipePairingResponse(
      recipe: RecipeExtractResult,
      matchedIngredients: RecipeExtractResult['ingredients'],
      wines: WineMatch[],
    ): string {
      const lines: string[] = [];
    
      lines.push(`Recipe: ${recipe.name}`);
      lines.push(`Source: ${recipe.source}`);
      lines.push('');
    
      lines.push(`Ingredients (${matchedIngredients.length} matched):`);
      for (const ing of matchedIngredients) {
        const amountSuffix = ing.amount ? ` (${ing.amount})` : '';
        lines.push(`  - ${ing.name}${amountSuffix}`);
      }
      lines.push('');
    
      const topWines = wines.slice(0, 5);
    
      if (topWines.length === 0) {
        lines.push('No wine matches found for this recipe.');
        return lines.join('\n');
      }
    
      lines.push('Wine recommendations:');
      lines.push('');
    
      for (let i = 0; i < topWines.length; i++) {
        const wine = topWines[i];
        const rank = i + 1;
    
        lines.push(`${rank}. ${wine.name} (${wine.color})`);
        lines.push(`   Match: ${wine.score.match_percentage}%`);
    
        if (wine.region) {
          lines.push(`   Region: ${wine.region}`);
        }
    
        if (wine.grapes && wine.grapes.length > 0) {
          lines.push(`   Grapes: ${wine.grapes.join(', ')}`);
        }
    
        if (wine.score.basic_score !== undefined) {
          const parts: string[] = [];
          parts.push(`basic ${wine.score.basic_score}`);
          parts.push(`balance ${wine.score.balance_score ?? 0}`);
          if (wine.score.aromatic_score != null) {
            parts.push(`aromatic ${wine.score.aromatic_score}`);
          }
          lines.push(`   Score breakdown: ${parts.join(' | ')}`);
        }
    
        lines.push('');
      }
    
      return lines.join('\n');
    }
Behavior4/5

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

With no annotations, the description discloses authentication (API key or x402 payment), pricing ($0.02/call), Pro requirement, and expected outputs (recipe name, ingredients, top 5 wine matches). It could mention error handling but overall provides sufficient behavioral context.

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

Conciseness4/5

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

The description is relatively concise, front-loading the purpose in one sentence and then providing additional details. The line about authentication and price is useful but could be better formatted. Still efficient overall.

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?

Given no output schema, the description explains the return format. It covers authentication, pricing, and input requirements. The tool has only 2 parameters, so the description is adequately complete, though it lacks error handling details.

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?

Schema coverage is 100%, with both parameters already described in the schema. The description adds no new semantic value beyond restating the URL and language expectations, so a baseline score 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?

The description clearly states the tool takes a recipe URL, extracts ingredients, and finds wine pairings, listing specific outputs. It distinguishes from sibling tools like 'pair_wine_with_ingredients' and 'find_meals_for_wine'.

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?

The description provides a use case ('Best for: What wine goes with this recipe?') and notes Pro tier requirement and pricing. However, it does not explicitly specify when not to use it or mention alternatives for different scenarios.

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