Skip to main content
Glama
caleb-conner

Open Food Facts MCP Server

by caleb-conner

get_product

Retrieve detailed food product information, including nutritional data and environmental scores, by entering the product barcode using the Open Food Facts MCP Server.

Instructions

Retrieve detailed information about a food product by its barcode

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
barcodeYesThe barcode/ID of the product (e.g., '3017620422003')

Implementation Reference

  • The main handler function for the 'get_product' tool. Fetches product data using the client, handles not found cases, formats the product information, and returns it as formatted text content.
    async handleGetProduct(barcode: string) { const response = await this.client.getProduct(barcode); if (response.status === 0 || !response.product) { return { content: [ { type: "text" as const, text: `Product not found for barcode: ${barcode}`, }, ], }; } const product = response.product; const formattedProduct = this.formatProduct(product); return { content: [ { type: "text" as const, text: formattedProduct, }, ], }; }
  • The tool schema definition including name, description, and input schema requiring a 'barcode' string.
    name: "get_product", description: "Retrieve detailed information about a food product by its barcode", inputSchema: { type: "object", properties: { barcode: { type: "string", description: "The barcode/ID of the product (e.g., '3017620422003')", }, }, required: ["barcode"], }, },
  • src/index.ts:45-46 (registration)
    Registration of the 'get_product' tool in the main switch statement that dispatches tool calls to the appropriate handler.
    case 'get_product': return await handlers.handleGetProduct(args.barcode);

Other Tools

Related 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/caleb-conner/open-food-facts-mcp'

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