{
  "openapi": "3.1.1",
  "info": {
    "title": "Dog and Cat Food Calculator API",
    "version": "1.0.0",
    "summary": "Daily calories for your dog or cat and grams or cups of food from the label, as an estimate.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://hearthpetenergy.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Daily calories for your dog or cat and grams or cups of food from the label, as an estimate.",
        "description": "Estimates the daily energy a dog or cat needs from its weight and life stage — resting energy 70 × kg^0.75 times the published life-stage factor — and turns it into grams or cups per day and per meal from the calories on the food label, with treats taken off.\n\nMethodology:\n- Resting energy requirement RER = 70 × (body weight in kg)^0.75 kcal per day (NRC 2006), the same for dogs and cats.\n- Daily energy (MER) = RER × life-stage factor from the Pet Nutrition Alliance table linked by WSAVA: dog neutered 1.6, intact 1.8, inactive 1.2–1.4, weight loss 1.0, growth 2–3, pregnancy 1.6–2.0, nursing 2–6; cat neutered 1.2, intact 1.4, inactive 1.0, weight loss 0.8–1.0, growth 2–3, pregnancy 2–3, nursing 2–6. Growth uses 3.0 under 4 months and 2.0 from 4 months on (needs fall from about 4 months). The range shown uses the AAHA 2021 ranges where they are wider.\n- Food per day = (MER − treats) ÷ label kcal per kg × 1000 g, or ÷ kcal per cup; split into the meals you give.\n\nThis is an estimate to start from, not veterinary advice. Pets differ by up to half from these numbers; weigh your pet and check its body condition every few weeks and ask your vet before changing the diet — always for puppies, kittens, pregnant, nursing, ill or overweight animals.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "hearth_pet_energy",
        "x-owner-app": "hearth",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HearthPetEnergyInput"
              },
              "examples": {
                "example1": {
                  "summary": "Neutered 20 kg dog, dry food 3600 kcal/kg",
                  "value": {
                    "species": "dog",
                    "weightKg": 20,
                    "stage": "neutered",
                    "foodKcalPerKg": 3600,
                    "meals": 2
                  }
                },
                "example2": {
                  "summary": "Indoor cat 4 kg, wet food 900 kcal/kg, 20 kcal treats",
                  "value": {
                    "species": "cat",
                    "weightKg": 4,
                    "stage": "neutered",
                    "foodKcalPerKg": 900,
                    "treatKcal": 20,
                    "meals": 3
                  }
                },
                "example3": {
                  "summary": "Puppy 6 kg, 4 months on, kcal per cup",
                  "value": {
                    "species": "dog",
                    "weightKg": 6,
                    "stage": "growth-older",
                    "foodKcalPerKg": 3900,
                    "foodKcalPerCup": 400,
                    "meals": 3
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HearthPetEnergyResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "HearthPetEnergyInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "species": {
            "title": "Animal",
            "type": "string",
            "enum": [
              "dog",
              "cat"
            ],
            "default": "dog"
          },
          "weightKg": {
            "title": "Body weight (kg)",
            "description": "For weight loss enter the target weight your vet suggests.",
            "type": "number",
            "minimum": 0.3,
            "maximum": 120,
            "default": 20
          },
          "stage": {
            "title": "Life stage",
            "type": "string",
            "enum": [
              "neutered",
              "intact",
              "inactive",
              "weight-loss",
              "growth-young",
              "growth-older",
              "gestation",
              "lactation",
              "custom"
            ],
            "default": "neutered"
          },
          "factor": {
            "title": "My vet’s factor (× RER, only for “My vet’s factor”)",
            "type": "number",
            "minimum": 0,
            "maximum": 8,
            "default": 0
          },
          "foodKcalPerKg": {
            "title": "Food energy (kcal per kg, from the label)",
            "description": "Often printed as “metabolisable energy”; 0 = not known.",
            "type": "number",
            "minimum": 0,
            "maximum": 9000,
            "default": 3600
          },
          "foodKcalPerCup": {
            "title": "Food energy (kcal per cup, optional)",
            "type": "number",
            "minimum": 0,
            "maximum": 2000,
            "default": 0
          },
          "treatKcal": {
            "title": "Treats per day (kcal)",
            "type": "number",
            "minimum": 0,
            "maximum": 5000,
            "default": 0
          },
          "meals": {
            "title": "Meals per day",
            "type": "integer",
            "minimum": 1,
            "maximum": 6,
            "default": 2
          }
        },
        "required": []
      },
      "HearthPetEnergyResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "species",
              "weightKg",
              "stage",
              "rer",
              "factor",
              "factorRange",
              "mer",
              "merRange",
              "treatKcal",
              "foodKcal",
              "gramsPerDay",
              "gramsRange",
              "gramsPerMeal",
              "cupsPerDay",
              "meals"
            ],
            "properties": {
              "species": {
                "enum": [
                  "dog",
                  "cat"
                ]
              },
              "weightKg": {
                "type": "number"
              },
              "stage": {
                "type": "string"
              },
              "rer": {
                "type": "number"
              },
              "factor": {
                "type": "number"
              },
              "factorRange": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "mer": {
                "type": "number"
              },
              "merRange": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "treatKcal": {
                "type": "number"
              },
              "foodKcal": {
                "type": "number"
              },
              "gramsPerDay": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "gramsRange": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "number"
                }
              },
              "gramsPerMeal": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "cupsPerDay": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "meals": {
                "type": "integer"
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}