{
  "openapi": "3.1.0",
  "info": {
    "title": "UseTheLever Market Regime & GEO Readiness Gateway",
    "version": "1.2.0",
    "description": "Zero-install REST gateway for U.S. broad-market regime context (QQQ/SMH/VIX), deterministic prop-firm drawdown survival math, and live AI search readiness (GEO/SEO) website audits."
  },
  "servers": [
    {
      "url": "https://mcp.usethelever.com",
      "description": "Production Cloudflare Edge Gateway"
    }
  ],
  "paths": {
    "/api/regime": {
      "get": {
        "operationId": "getUsMarketRegime",
        "summary": "Get live EOD U.S. market regime (GREEN/YELLOW/RED) and QQQ/SMH/VIX metrics.",
        "description": "Returns published U.S. broad-market regime, risk score (0-100), QQQ vs 200d SMA, VIX vs 20d avg, SMH relative strength, distribution days, and educational risk context.",
        "parameters": [
          {
            "name": "include_methodology",
            "in": "query",
            "required": false,
            "description": "Set true to include indicator methodology notes.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published U.S. market regime telemetry JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "regime": {
                      "type": "string",
                      "description": "GREEN, YELLOW, or RED broad-market posture."
                    },
                    "risk_score": {
                      "type": "integer",
                      "description": "Composite risk score from 0 to 100."
                    },
                    "as_of": {
                      "type": "string",
                      "description": "Completed market session date (YYYY-MM-DD)."
                    },
                    "qqq_vs_mas": {
                      "type": "object",
                      "description": "QQQ close, 200d SMA, % distance, and drawdown."
                    },
                    "vix_vs_20d_avg": {
                      "type": "object",
                      "description": "VIX close and ratio vs 20-day moving average."
                    },
                    "smh_relative_strength": {
                      "type": "object",
                      "description": "SMH price and relative spread vs QQQ."
                    },
                    "distribution_day_count_25d": {
                      "type": "integer",
                      "description": "25-session institutional distribution count."
                    },
                    "educational_risk_sizing_posture": {
                      "type": "string",
                      "description": "Non-advisory educational sizing context."
                    },
                    "links": {
                      "type": "object",
                      "description": "Links to free blind replay drill and checklists."
                    },
                    "disclaimer": {
                      "type": "string",
                      "description": "Educational publisher exclusion notice."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/drawdown": {
      "get": {
        "operationId": "calculatePropFirmDrawdownGet",
        "summary": "Calculate prop-firm drawdown buffer and recommended 1R risk cap via GET.",
        "description": "Computes remaining trailing drawdown buffer, consecutive losses before daily or trailing rule breach, and survival-anchored 1R risk cap.",
        "parameters": [
          {
            "name": "account_size",
            "in": "query",
            "required": false,
            "description": "Nominal account balance in USD (default 50000).",
            "schema": {
              "type": "number",
              "default": 50000
            }
          },
          {
            "name": "max_trailing_drawdown",
            "in": "query",
            "required": false,
            "description": "Max trailing drawdown in USD (default 2000).",
            "schema": {
              "type": "number",
              "default": 2000
            }
          },
          {
            "name": "daily_loss_limit",
            "in": "query",
            "required": false,
            "description": "Daily loss limit in USD (default 1000).",
            "schema": {
              "type": "number",
              "default": 1000
            }
          },
          {
            "name": "risk_per_trade_usd",
            "in": "query",
            "required": false,
            "description": "Planned USD risk per trade.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "planned_stop_points",
            "in": "query",
            "required": false,
            "description": "Optional stop distance in points.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "point_value_usd",
            "in": "query",
            "required": false,
            "description": "USD per point per contract (default 20).",
            "schema": {
              "type": "number",
              "default": 20
            }
          },
          {
            "name": "consecutive_losses",
            "in": "query",
            "required": false,
            "description": "Losing streak count to test (default 3).",
            "schema": {
              "type": "integer",
              "default": 3
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deterministic drawdown survival calculation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "inputs": {
                      "type": "object",
                      "description": "Normalized calculator inputs."
                    },
                    "survival_math": {
                      "type": "object",
                      "description": "Remaining buffer, max loss streak, and 1R cap."
                    },
                    "next_steps": {
                      "type": "object",
                      "description": "Prop-Firm Shield and Blind Replay drill links."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "calculatePropFirmDrawdownPost",
        "summary": "Calculate prop-firm drawdown buffer and recommended 1R risk cap via POST.",
        "description": "Accepts JSON parameters for account size, trailing drawdown, daily limit, stop points, and risk per trade, returning deterministic survival math.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "account_size": {
                    "type": "number",
                    "default": 50000,
                    "description": "Nominal account balance in USD."
                  },
                  "max_trailing_drawdown": {
                    "type": "number",
                    "default": 2000,
                    "description": "Max trailing drawdown in USD."
                  },
                  "daily_loss_limit": {
                    "type": "number",
                    "default": 1000,
                    "description": "Daily loss limit in USD."
                  },
                  "current_drawdown_used": {
                    "type": "number",
                    "default": 0,
                    "description": "Drawdown already used in USD."
                  },
                  "risk_per_trade_usd": {
                    "type": "number",
                    "description": "Planned dollar risk per trade."
                  },
                  "planned_stop_points": {
                    "type": "number",
                    "description": "Planned stop distance in points."
                  },
                  "point_value_usd": {
                    "type": "number",
                    "default": 20,
                    "description": "USD value per point."
                  },
                  "consecutive_losses": {
                    "type": "integer",
                    "default": 3,
                    "description": "Consecutive losses to stress-test."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic drawdown survival calculation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "inputs": {
                      "type": "object",
                      "description": "Normalized calculator inputs."
                    },
                    "survival_math": {
                      "type": "object",
                      "description": "Remaining buffer, max loss streak, and 1R cap."
                    },
                    "next_steps": {
                      "type": "object",
                      "description": "Prop-Firm Shield and Blind Replay drill links."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/geo-check": {
      "get": {
        "operationId": "auditAiSearchReadiness",
        "summary": "Audit a public website for AI search crawlers, llms.txt, and JSON-LD schema.",
        "description": "Fetches robots.txt (OAI-SearchBot, PerplexityBot, ClaudeBot, GPTBot, Googlebot), /llms.txt, HTML metadata, canonical tags, and JSON-LD schema.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "Public http/https domain or page URL to audit (e.g., https://example.com).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Objective PASS/WARN/FAIL/UNMEASURED readiness report.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "audited_url": {
                      "type": "string",
                      "description": "Normalized target URL."
                    },
                    "overall_status": {
                      "type": "string",
                      "description": "PASS, WARN, FAIL, or UNMEASURED."
                    },
                    "checks": {
                      "type": "object",
                      "description": "Detailed crawler, llms.txt, HTML, and JSON-LD results."
                    },
                    "fix_first": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Prioritized remediation items."
                    },
                    "upgrade_and_tools": {
                      "type": "object",
                      "description": "Shareable report and GEO kit links."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid or non-public URL rejected.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Validation error details."
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}