Skip to main content
Glama
rogertheunissenmerge-oss

SommelierX Wine Pairing MCP

group_pairing

Find the best wine that pairs well with 2-10 different dishes at once, ideal for multi-course dinners. Input meal names to get top recommendations.

Instructions

Find the best wine that pairs well with multiple dishes at once. Provide 2-10 meal names and get wines that score well across all of them. Requires Pro tier. Best for: "What single wine works for a 3-course dinner?" | Auth: API key (Bearer sk_live_...) or x402 payment (USDC on Base) | Price: $0.03/call (PRO)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
meal_namesYesList of meal/dish names (e.g. ["Caesar salad", "grilled lamb", "chocolate mousse"])
languageNoLanguage code for results (e.g. "en", "nl", "fr"). Defaults to "en".

Implementation Reference

  • The main handler for the group_pairing tool. It resolves meal names to database IDs, calls the /api/v1/pairing/group endpoint, and formats the response. Requires Pro tier API key.
    export async function executeGroupPairing(
      client: SommelierXClient,
      config: ServerConfig,
      input: GroupPairingInput,
    ): Promise<string> {
      const language = input.language ?? config.defaultLanguage;
    
      // Step 1: Resolve all meal names
      const resolved = await Promise.all(
        input.meal_names.map((name) => resolveMeal(client, name, language)),
      );
    
      const matched = resolved.filter((r): r is ResolvedMeal & { id: number } => r.matched && r.id !== null);
      const unmatched = resolved.filter((r) => !r.matched);
    
      if (matched.length < 2) {
        const foundCount = matched.length;
        return [
          `Could only find ${foundCount} of ${input.meal_names.length} meals in the database.`,
          `Group pairing requires at least 2 matched meals.`,
          '',
          `Found: ${matched.map((m) => m.name).join(', ') || 'none'}`,
          `Not found: ${unmatched.map((u) => u.name).join(', ')}`,
          '',
          'Use search_meals to find the correct meal names.',
        ].join('\n');
      }
    
      // Step 2: Call group pairing
      const mealIds = matched.map((m) => m.id);
    
      let result: GroupPairingResult;
      try {
        result = await client.post<GroupPairingResult>('/api/v1/pairing/group', {
          mealIds,
          language,
        });
      } catch (error: unknown) {
        if (error instanceof SommelierXApiError && error.statusCode === 403) {
          return [
            'Group pairing 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',
          ].join('\n');
        }
        const message = error instanceof Error ? error.message : 'Unknown error';
        return `Error calculating group pairing: ${message}`;
      }
    
      return formatGroupPairingResponse(matched, unmatched, result.results);
    }
  • Zod schema defining the group_pairing input: meal_names (array of 2-10 strings) and optional language code.
    export const groupPairingSchema = z.object({
      meal_names: z
        .array(z.string().min(2))
        .min(2, 'At least 2 meals are required for group pairing')
        .max(10, 'Maximum 10 meals allowed')
        .describe('List of meal/dish names (e.g. ["Caesar salad", "grilled lamb", "chocolate mousse"])'),
      language: z
        .string()
        .min(2)
        .max(10)
        .optional()
        .describe('Language code for results (e.g. "en", "nl", "fr"). Defaults to "en".'),
    });
  • src/index.ts:147-158 (registration)
    Registers the 'group_pairing' tool with the MCP server using server.tool(), wiring the schema shape and async handler.
    // ── Tool 7: group_pairing ──
    
    server.tool(
      'group_pairing',
      'Find the best wine that pairs well with multiple dishes at once. Provide 2-10 meal names and get wines that score well across all of them. Requires Pro tier. Best for: "What single wine works for a 3-course dinner?" | Auth: API key (Bearer sk_live_...) or x402 payment (USDC on Base) | Price: $0.03/call (PRO)',
      groupPairingSchema.shape,
      async (input) => {
        const parsed = groupPairingSchema.parse(input);
        const result = await executeGroupPairing(client, config, parsed);
        return { content: [{ type: 'text' as const, text: result }] };
      },
    );
  • resolveMeal - helper that searches for a meal by name in the database and returns its ID or null if not found.
    async function resolveMeal(
      client: SommelierXClient,
      name: string,
      language: string,
    ): Promise<ResolvedMeal> {
      try {
        const result = await client.get<MealListResult>('/api/v1/meals', {
          search: name,
          language,
          perPage: '1',
        });
    
        if (result.data && result.data.length > 0) {
          return { name, id: result.data[0].id, matched: true };
        }
    
        return { name, id: null, matched: false };
      } catch {
        return { name, id: null, matched: false };
      }
    }
  • formatGroupPairingResponse - formats the API results into a human-readable string showing top 5 wines with per-meal breakdown.
    function formatGroupPairingResponse(
      matched: ResolvedMeal[],
      unmatched: ResolvedMeal[],
      wines: Array<WineMatch & { mealScores?: Array<{ mealId: number; mealName: string; match_percentage: number }> }>,
    ): string {
      const lines: string[] = [];
    
      lines.push(`Group wine pairing for: ${matched.map((m) => m.name).join(', ')}`);
    
      if (unmatched.length > 0) {
        lines.push(`Note: Could not find these meals: ${unmatched.map((u) => u.name).join(', ')}`);
      }
    
      lines.push('');
    
      const topWines = wines.slice(0, 5);
    
      if (topWines.length === 0) {
        lines.push('No wines found that pair well with all of these dishes.');
        return lines.join('\n');
      }
    
      lines.push('Best wines across all dishes:');
      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(`   Overall 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(', ')}`);
        }
    
        // Show per-meal breakdown if available
        if (wine.mealScores && wine.mealScores.length > 0) {
          lines.push('   Per-dish scores:');
          for (const ms of wine.mealScores) {
            lines.push(`     - ${ms.mealName}: ${ms.match_percentage}%`);
          }
        }
    
        lines.push('');
      }
    
      return lines.join('\n');
    }
Behavior5/5

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

With no annotations provided, the description fully covers behavioral traits: auth requirements (API key or x402), pricing ($0.03/call), tier requirement (Pro), and input constraints (2-10 meals). No contradictions.

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?

The description is extremely concise, packing purpose, usage, requirements, and pricing into a few sentences. It is front-loaded with the primary purpose, making it efficient for an AI agent to parse.

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 does not specify the return format (e.g., list of wines with scores). However, it covers all key operational details (inputs, auth, pricing) and is adequate for a tool that likely returns similar structure to siblings.

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

Parameters4/5

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

Schema coverage is 100%, so the schema already describes parameters. The description adds value by stating the input range ('2-10 meal names') and providing an example, which aids understanding beyond the schema's formal description.

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's purpose with a specific verb and resource: 'Find the best wine that pairs well with multiple dishes at once.' It distinguishes from siblings by focusing on multiple dishes, contrasting with single-dish tools like pair_wine_with_meal.

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 explicit usage context, including a best-use example ('What single wine works for a 3-course dinner?') and requirements (Pro tier, auth methods, pricing). It lacks explicit when-not-to-use guidance, but the context is clear.

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