{
  "openapi": "3.1.0",
  "info": {
    "title": "Hungry Goblin API",
    "version": "1.0.0",
    "description": "OAuth-protected meal-decision API for Hungry Goblin. Primary integration is MCP (Model Context Protocol) over Streamable HTTP. REST-style paths on this domain describe discovery and OAuth metadata.",
    "contact": {
      "name": "Hungry Goblin Support",
      "email": "info@hungrygoblin.com",
      "url": "https://hungrygoblin.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://hungrygoblin.com",
      "description": "Public discovery and documentation"
    },
    {
      "url": "https://zonykdtrkbptszqellsn.supabase.co/functions/v1/mcp-server",
      "description": "MCP Streamable HTTP server (JSON-RPC 2.0)"
    },
    {
      "url": "https://zonykdtrkbptszqellsn.supabase.co/functions/v1/oauth-server",
      "description": "OAuth 2.1 authorization server"
    }
  ],
  "tags": [
    {
      "name": "MCP",
      "description": "Model Context Protocol JSON-RPC tools"
    },
    {
      "name": "OAuth",
      "description": "Authorization and token endpoints"
    },
    {
      "name": "Discovery",
      "description": "Machine-readable metadata"
    }
  ],
  "paths": {
    "/mcp": {
      "get": {
        "tags": [
          "MCP"
        ],
        "summary": "MCP server entry (proxied to Streamable HTTP transport)",
        "description": "Returns MCP/OAuth challenge JSON when unauthenticated. POST JSON-RPC 2.0 requests after obtaining an OAuth access token.",
        "responses": {
          "401": {
            "description": "OAuth authorization required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "MCP"
        ],
        "summary": "MCP JSON-RPC request",
        "operationId": "mcpJsonRpc",
        "security": [
          {
            "oauth2": [
              "recipes:read",
              "recipes:write",
              "recipes:delete",
              "history:read",
              "history:write",
              "history:delete",
              "suggestions:read",
              "search:read",
              "offline_access"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC success or error",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/JsonRpcSuccess"
                    },
                    {
                      "$ref": "#/components/schemas/JsonRpcErrorResponse"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "API index",
        "operationId": "getApiIndex",
        "responses": {
          "200": {
            "description": "API discovery document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiIndex"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/oauth-authorization-server": {
      "get": {
        "tags": [
          "OAuth",
          "Discovery"
        ],
        "summary": "OAuth 2.1 authorization server metadata (RFC 8414)",
        "responses": {
          "200": {
            "description": "Authorization server metadata including scopes_supported",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/oauth-protected-resource": {
      "get": {
        "tags": [
          "OAuth",
          "Discovery"
        ],
        "summary": "Protected resource metadata (RFC 9728)",
        "responses": {
          "200": {
            "description": "MCP resource metadata including scopes_supported",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "description": "OAuth 2.1 with PKCE (S256). Dynamic Client Registration supported — no contact-sales required.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://zonykdtrkbptszqellsn.supabase.co/functions/v1/oauth-server/authorize",
            "tokenUrl": "https://zonykdtrkbptszqellsn.supabase.co/functions/v1/oauth-server/token",
            "scopes": {
              "recipes:read": "View your recipes",
              "recipes:write": "Create and edit recipes",
              "recipes:delete": "Delete recipes",
              "history:read": "View cooking history",
              "history:write": "Log meals you've cooked",
              "history:delete": "Delete history entries",
              "suggestions:read": "Get meal suggestions",
              "search:read": "Search recipes",
              "offline_access": "Maintain access when offline (refresh tokens)"
            }
          }
        }
      }
    },
    "schemas": {
      "ApiIndex": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "openapi": {
            "type": "string",
            "format": "uri"
          },
          "mcp_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "documentation": {
            "type": "string",
            "format": "uri"
          },
          "authentication": {
            "type": "object"
          },
          "errors": {
            "type": "object"
          }
        }
      },
      "JsonRpcRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "enum": [
              "2.0"
            ]
          },
          "id": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "method": {
            "type": "string"
          },
          "params": {
            "type": "object"
          }
        }
      },
      "JsonRpcSuccess": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "type": "string"
          },
          "id": {},
          "result": {
            "type": "object"
          }
        }
      },
      "JsonRpcError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object"
          }
        }
      },
      "JsonRpcErrorResponse": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "type": "string"
          },
          "id": {},
          "error": {
            "$ref": "#/components/schemas/JsonRpcError"
          }
        }
      },
      "ApiError": {
        "type": "object",
        "required": [
          "error",
          "error_description"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "error_description": {
            "type": "string"
          },
          "code": {
            "type": "integer"
          },
          "documentation": {
            "type": "string",
            "format": "uri"
          },
          "hint": {
            "type": "string"
          }
        },
        "example": {
          "error": "not_found",
          "error_description": "The requested resource does not exist.",
          "code": 404,
          "documentation": "https://hungrygoblin.com/developers#errors",
          "hint": "See /openapi.json for the full API surface."
        }
      }
    }
  },
  "x-mcp-tools": [
    {
      "name": "list_recipes",
      "scopes": [
        "recipes:read"
      ]
    },
    {
      "name": "get_recipe",
      "scopes": [
        "recipes:read"
      ]
    },
    {
      "name": "create_recipe",
      "scopes": [
        "recipes:write"
      ]
    },
    {
      "name": "update_recipe",
      "scopes": [
        "recipes:write"
      ]
    },
    {
      "name": "delete_recipe",
      "scopes": [
        "recipes:delete"
      ]
    },
    {
      "name": "get_meal_suggestion",
      "scopes": [
        "suggestions:read"
      ]
    },
    {
      "name": "log_cooked_meal",
      "scopes": [
        "history:write"
      ]
    },
    {
      "name": "get_cooking_history",
      "scopes": [
        "history:read"
      ]
    },
    {
      "name": "delete_history_entry",
      "scopes": [
        "history:delete"
      ]
    },
    {
      "name": "search_recipes",
      "scopes": [
        "search:read"
      ]
    }
  ]
}
