Skip to main content
Glama
domdomegg

openfoodfacts-mcp

Select/crop product image

select_image

Crop, rotate, and assign product images to specific categories on Open Food Facts after uploading. This tool helps organize visual product data in the food database.

Instructions

Select, crop, and rotate a previously uploaded product image on Open Food Facts. Requires OFF_USER_ID and OFF_PASSWORD.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
barcodeYesProduct barcode
imgidYesImage ID (from upload_image response or product data)
imagefieldYesImage type to assign this image to
lcNoLanguage code (default: en)en
angleNoRotation angle in degrees
x1NoCrop: left coordinate
y1NoCrop: top coordinate
x2NoCrop: right coordinate
y2NoCrop: bottom coordinate

Implementation Reference

  • The implementation of the 'select_image' tool handler, which processes input parameters, calls the Open Food Facts API via 'offPost', and returns the result.
    async (args) => {
    	const body: Record<string, string> = {
    		code: args.barcode,
    		imgid: String(args.imgid),
    		id: `${args.imagefield}_${args.lc}`,
    	};
    
    	if (args.angle) {
    		body.angle = args.angle;
    	}
    
    	if (args.x1 !== undefined) {
    		body.x1 = String(args.x1);
    	}
    
    	if (args.y1 !== undefined) {
    		body.y1 = String(args.y1);
    	}
    
    	if (args.x2 !== undefined) {
    		body.x2 = String(args.x2);
    	}
    
    	if (args.y2 !== undefined) {
    		body.y2 = String(args.y2);
    	}
    
    	const data = await offPost(config, '/cgi/product_image_crop.pl', body);
    
    	return jsonResult(data as Record<string, unknown>);
    },
  • The input schema definition for the 'select_image' tool, including validation and field descriptions.
    const inputSchema = strictSchemaWithAliases(
    	{
    		barcode: z.string().describe('Product barcode'),
    		imgid: z.number().int().describe('Image ID (from upload_image response or product data)'),
    		imagefield: z.enum([
    			'front',
    			'ingredients',
    			'nutrition',
    			'packaging',
    			'other',
    		]).describe('Image type to assign this image to'),
    		lc: z.string().default('en').describe('Language code (default: en)'),
    		angle: z.enum([
    			'0',
    			'90',
    			'180',
    			'270',
    		]).optional().describe('Rotation angle in degrees'),
    		x1: z.number().optional().describe('Crop: left coordinate'),
    		y1: z.number().optional().describe('Crop: top coordinate'),
    		x2: z.number().optional().describe('Crop: right coordinate'),
    		y2: z.number().optional().describe('Crop: bottom coordinate'),
    	},
    	{
    		code: 'barcode',
    		id: 'imagefield',
    	},
    );
  • The registration function for the 'select_image' tool.
    export function registerSelectImage(server: McpServer, config: Config): void {
    	server.registerTool(
    		'select_image',
    		{
    			title: 'Select/crop product image',
    			description: 'Select, crop, and rotate a previously uploaded product image on Open Food Facts. Requires OFF_USER_ID and OFF_PASSWORD.',
    			inputSchema,
    			annotations: {
    				readOnlyHint: false,
    			},
    		},
    		async (args) => {
    			const body: Record<string, string> = {
    				code: args.barcode,
    				imgid: String(args.imgid),
    				id: `${args.imagefield}_${args.lc}`,
    			};
    
    			if (args.angle) {
    				body.angle = args.angle;
    			}
    
    			if (args.x1 !== undefined) {
    				body.x1 = String(args.x1);
    			}
    
    			if (args.y1 !== undefined) {
    				body.y1 = String(args.y1);
    			}
    
    			if (args.x2 !== undefined) {
    				body.x2 = String(args.x2);
    			}
    
    			if (args.y2 !== undefined) {
    				body.y2 = String(args.y2);
    			}
    
    			const data = await offPost(config, '/cgi/product_image_crop.pl', body);
    
    			return jsonResult(data as Record<string, unknown>);
    		},
    	);
    }
Behavior3/5

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

The annotation indicates readOnlyHint:false, and the description correctly implies mutation without contradiction. It adds the specific authentication requirement ('OFF_USER_ID and OFF_PASSWORD') which is valuable behavioral context not present in annotations, but lacks details on side effects (e.g., whether this overwrites existing image assignments), rate limits, or return structure.

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 consists of two efficient sentences. The first immediately establishes the operation and scope, while the second states the critical authentication requirement. No filler words or redundant information is present.

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

Completeness3/5

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

For a 9-parameter mutation tool requiring authentication, the description covers the essential operation and auth prerequisites. However, given the lack of an output schema, it omits important contextual details such as what the tool returns, whether the operation is idempotent, or what happens to previously selected images for the given field.

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?

With 100% schema description coverage, the schema adequately documents all 9 parameters including crop coordinates and rotation angles. The description provides a high-level mapping ('crop, and rotate') but does not add syntactic details, constraints, or examples beyond the schema, warranting the baseline score of 3.

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

Purpose4/5

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

The description uses specific verbs (select, crop, rotate) and identifies the resource (product image on Open Food Facts). The phrase 'previously uploaded' effectively distinguishes this from the sibling 'upload_image' tool, though it does not explicitly name the alternative.

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

Usage Guidelines3/5

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

The description states authentication prerequisites ('Requires OFF_USER_ID and OFF_PASSWORD'), which is crucial for an authenticated mutation tool. However, it lacks explicit workflow guidance (e.g., 'use this after upload_image') or clear exclusions for when not to use the tool.

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/domdomegg/openfoodfacts-mcp'

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