食谱生成服务器

一个基于AI的食谱生成与转换工具,可根据饮食偏好生成个性化食谱,并调整现有食谱以满足营养目标。

  • by valetdotdev
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 blaideinc/recipe-mcp

使用说明

配方MCP服务器

MCP(模型上下文协议)服务器,提供人工智能驱动的配方生成和转换工具。根据饮食偏好生成个性化食谱,改造现有食谱以满足营养目标等等。

特性

  • 🍳 生成食谱 -根据自然语言描述创建自定义食谱
  • 🔄 变换食谱 -修改现有的食谱(做素食主义者,调整卡路里等)
  • 🥗 饮食支持 -处理过敏、限制和食物偏好
  • 📊 营养目标 -目标特定卡路里和蛋白质需求
  • 🆓 开放获取 -不需要API密钥(速率受限)

安装

适用于克劳德桌面

  1. 安装MCP服务器:
npm install -g @cookwith/recipe-mcp
  1. 添加到您的Claude Desktop配置中:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • 窗户: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "recipe-mcp": {
      "command": "npx",
      "args": ["@cookwith/recipe-mcp"],
      "env": {
        "COOKWITH_API_URL": "https://cookwith.co"
      }
    }
  }
}
  1. 重新启动克劳德桌面

为了发展

# Clone the repository
git clone https://github.com/cookwith/recipe-mcp.git
cd recipe-mcp

# Install dependencies
npm install

# Run in development mode
npm run dev

使用示例

生成配方

// In Claude Desktop, you can say:
"Generate a healthy Mediterranean pasta dish with lots of vegetables"

// The tool will be called with:
{
  "prompt": "A healthy Mediterranean pasta dish with lots of vegetables",
  "dietaryRestrictions": ["vegetarian"],
  "calories": "450",
  "servings": 4
}

转换配方

// After generating or providing a recipe:
"Make this recipe vegan and reduce the calories by 200"

// The tool will be called with:
{
  "recipe": { /* existing recipe object */ },
  "instructions": "Make this vegan and reduce calories by 200",
  "calories": "350"
}

工具

generate_recipe

根据自然语言指令生成新配方。

参数:

  • prompt (字符串,必填)-自然语言描述
  • dietaryRestrictions (string[],可选)-例如,[“素食主义者”,“无麸质”]
  • allergies (string[],可选)-要避免的成分
  • dislikes (string[],可选)-要排除的食物
  • calories (字符串,可选)-每份目标卡路里
  • protein (字符串,可选)-目标蛋白质(克)
  • servings (数字,可选)-份数(1-20,默认值:4)

transform_recipe

根据说明转换现有配方。

参数:

  • recipe (对象,必填)-要转换的配方
  • instructions (字符串,必填)-如何修改配方
  • calories (字符串,可选)-新的目标卡路里
  • protein (字符串,可选)-新的目标蛋白
  • servings (数量,可选)-新的份数

速率限制

公共API有以下费率限制:

  • 匿名访问:每个IP地址每小时20个请求
  • 不要求进行验证
  • 超出限制时提供标头后重试

配方对象格式

interface Recipe {
  title: string;
  description: string;
  ingredients: string[];      // e.g., ["2 cups flour", "1 tsp salt"]
  instructions: string[];      // Step-by-step instructions
  servings: number;
  prepTime?: number;          // Minutes
  cookTime?: number;          // Minutes
  totalTime?: number;         // Minutes
  cuisine?: string;           // e.g., "Italian", "Mexican"
  course?: string;            // e.g., "main", "dessert"
  difficulty?: string;        // e.g., "easy", "medium", "hard"
  calories?: number;          // Per serving
  protein?: number;           // Grams per serving
  carbs?: number;            // Grams per serving
  fat?: number;              // Grams per serving
  fiber?: number;            // Grams per serving
  sugar?: number;            // Grams per serving
  sodium?: number;           // Milligrams per serving
}

配置

环境变量

  • COOKWITH_API_URL -API端点(默认值:https://cookwith.co)

自定义API终结点

对于开发或自托管实例:

export COOKWITH_API_URL=http://localhost:3000
npx @cookwith/recipe-mcp

例子

基本配方生成

// Request
{
  "prompt": "Quick and easy chicken stir-fry"
}

// Response
{
  "title": "Quick Chicken Stir-Fry",
  "description": "A delicious and speedy chicken stir-fry...",
  "ingredients": [
    "2 chicken breasts, sliced",
    "2 cups mixed vegetables",
    "3 tbsp soy sauce",
    // ...
  ],
  "instructions": [
    "Heat oil in a large wok or skillet",
    "Add chicken and cook until golden",
    // ...
  ],
  "servings": 4,
  "prepTime": 10,
  "cookTime": 15,
  "calories": 320,
  "protein": 28
}

配方转换

// Request
{
  "recipe": {
    "title": "Classic Beef Lasagna",
    "ingredients": ["1 lb ground beef", "ricotta cheese", ...],
    // ... full recipe
  },
  "instructions": "Make this vegetarian and lower in calories"
}

// Response
{
  "title": "Vegetarian Light Lasagna",
  "description": "A healthier vegetarian version...",
  "ingredients": [
    "2 cups chopped mushrooms",
    "1 cup low-fat ricotta",
    // ... transformed ingredients
  ],
  // ... rest of transformed recipe
}

故障排除

速率限制错误

如果您收到429错误,则表示您已超过速率限制。等待中指定的时间 retryAfter 字段,然后再提出另一个请求。

连接问题

确保您的互联网连接稳定,并且API端点可访问。

无效参数

检查您的参数是否符合预期的格式和限制(例如,1-20份之间的份量)。

贡献

欢迎投稿!请查看我们的 贡献指南 了解详情。

许可证

MIT许可证-请参阅 许可证 文件以获取详细信息。

支持

技术支持