search_ingredients
Find ingredient IDs by searching with ingredient names to manage your home bar inventory and discover cocktails.
Instructions
Search for ingredients by name to find their IDs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Ingredient name to search for | |
| bar_id | No | Bar ID (optional if BAR_ASSISTANT_BAR_ID is set) |
Implementation Reference
- src/bar_assistant_mcp/server.py:344-364 (handler)Handler for the search_ingredients tool: queries the ingredients API endpoint with a name filter, formats and returns the list of matching ingredients or a no-results message.elif name == "search_ingredients": bar_id = arguments.get("bar_id") or CONFIG["bar_id"] response = await client.get( f"{CONFIG['api_url']}/ingredients", headers=get_headers(bar_id), params={"filter[name]": arguments["name"]} ) response.raise_for_status() data = response.json() if not data.get('data'): return [TextContent(type="text", text="No ingredients found matching your search.")] result = "Found ingredients:\n\n" for ing in data.get('data', []): result += f"- **{ing['name']}** (ID: {ing['id']})\n" if ing.get('description'): result += f" {ing['description'][:100]}...\n" return [TextContent(type="text", text=result)]
- Input schema definition for the search_ingredients tool, specifying the required 'name' parameter and optional 'bar_id'.inputSchema={ "type": "object", "properties": { "name": { "type": "string", "description": "Ingredient name to search for" }, "bar_id": { "type": "number", "description": "Bar ID (optional if BAR_ASSISTANT_BAR_ID is set)" } }, "required": ["name"] }
- src/bar_assistant_mcp/server.py:205-222 (registration)Registration of the search_ingredients tool in the MCP app's tools list, including name, description, and input schema.Tool( name="search_ingredients", description="Search for ingredients by name to find their IDs", inputSchema={ "type": "object", "properties": { "name": { "type": "string", "description": "Ingredient name to search for" }, "bar_id": { "type": "number", "description": "Bar ID (optional if BAR_ASSISTANT_BAR_ID is set)" } }, "required": ["name"] } )