{
  "openapi": "3.1.0",
  "info": {
    "title": "PieFolio AI Agent API",
    "version": "1.0.0",
    "description": "Public, unauthenticated endpoints that let AI agents use PieFolio AI's financial calculators and read its content as markdown. All results are educational estimates, not financial advice.",
    "contact": { "email": "contact@getpiefolio.com", "url": "https://getpiefolio.com" }
  },
  "servers": [
    { "url": "https://qmnogxbwxfwtmuqzvgrd.supabase.co/functions/v1/agent-mcp" }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "health",
        "summary": "Service health",
        "responses": { "200": { "description": "Service is healthy" } }
      }
    },
    "/tools/list_piefolio_content": {
      "post": {
        "operationId": "listContent",
        "summary": "List public pages, calculators and articles",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": { "type": "string", "enum": ["page", "tool", "article"] }
                }
              }
            }
          }
        },
        "responses": { "200": { "description": "Content list" } }
      }
    },
    "/tools/get_page_markdown": {
      "post": {
        "operationId": "getPageMarkdown",
        "summary": "Fetch a page as markdown",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["path"],
                "properties": { "path": { "type": "string", "example": "/blog/what-is-coast-fire" } }
              }
            }
          }
        },
        "responses": { "200": { "description": "Markdown body" } }
      }
    },
    "/tools/calculate_coast_fire": {
      "post": {
        "operationId": "calculateCoastFire",
        "summary": "Calculate a Coast FIRE number",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["currentAge", "retirementAge", "annualExpenses"],
                "properties": {
                  "currentAge": { "type": "number" },
                  "retirementAge": { "type": "number" },
                  "annualExpenses": { "type": "number" },
                  "currentInvested": { "type": "number" },
                  "realReturnPct": { "type": "number", "default": 6 },
                  "withdrawalRatePct": { "type": "number", "default": 4 },
                  "currency": { "type": "string", "default": "USD" }
                }
              }
            }
          }
        },
        "responses": { "200": { "description": "Coast FIRE result" } }
      }
    },
    "/tools/project_dividend_income": {
      "post": {
        "operationId": "projectDividendIncome",
        "summary": "Project dividend income year by year",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["startingCapital", "dividendYieldPct", "years"],
                "properties": {
                  "startingCapital": { "type": "number" },
                  "monthlyContribution": { "type": "number" },
                  "dividendYieldPct": { "type": "number" },
                  "dividendGrowthPct": { "type": "number", "default": 5 },
                  "priceGrowthPct": { "type": "number", "default": 5 },
                  "years": { "type": "number", "default": 20 },
                  "reinvestDividends": { "type": "boolean", "default": true },
                  "currency": { "type": "string", "default": "USD" }
                }
              }
            }
          }
        },
        "responses": { "200": { "description": "Projection with yearly schedule" } }
      }
    },
    "/tools/get_calculator_link": {
      "post": {
        "operationId": "getCalculatorLink",
        "summary": "Build a pre-filled calculator link",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tool"],
                "properties": {
                  "tool": {
                    "type": "string",
                    "enum": ["retirement", "dividend", "coast-fire", "rent-vs-buy"]
                  },
                  "prefill": { "type": "object", "additionalProperties": true }
                }
              }
            }
          }
        },
        "responses": { "200": { "description": "URL to the interactive calculator" } }
      }
    }
  }
}
