{
  "openapi": "3.1.0",
  "info": {
    "title": "MCLL Real Estate — public read API",
    "version": "1.0.0",
    "description": "Read-only access to published listings. For richer agent use, see the MCP server card at /.well-known/mcp/server-card.json."
  },
  "servers": [
    {
      "url": "https://mcllrealestate.com"
    }
  ],
  "paths": {
    "/api/listings": {
      "get": {
        "summary": "Search published listings",
        "description": "Filters take ids (UUIDs), not names. For name-based search (\"condos in Phuket\") use the MCP search_listings tool, which resolves names to ids. Rate-limited to 120 requests/min per IP.",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "sale",
                "rent"
              ]
            }
          },
          {
            "name": "locale",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "fr",
                "th",
                "zh"
              ]
            }
          },
          {
            "name": "city",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "area",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "propertyType",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "bedrooms",
            "in": "query",
            "description": "Minimum bedrooms (matches listings with at least this many).",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "bathrooms",
            "in": "query",
            "description": "Minimum bathrooms.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "priceMin",
            "in": "query",
            "description": "Minimum price in THB.",
            "schema": {
              "type": "number",
              "minimum": 0
            }
          },
          {
            "name": "priceMax",
            "in": "query",
            "description": "Maximum price in THB.",
            "schema": {
              "type": "number",
              "minimum": 0
            }
          },
          {
            "name": "sizeMin",
            "in": "query",
            "description": "Minimum interior size in m².",
            "schema": {
              "type": "number",
              "minimum": 0
            }
          },
          {
            "name": "sizeMax",
            "in": "query",
            "description": "Maximum interior size in m².",
            "schema": {
              "type": "number",
              "minimum": 0
            }
          },
          {
            "name": "furnished",
            "in": "query",
            "description": "Rent only; \"true\" returns furnished listings.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "features",
            "in": "query",
            "description": "Comma-separated feature ids (UUIDs); a listing must have all of them.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "newest",
                "price_asc",
                "price_desc",
                "size_asc",
                "size_desc",
                "featured"
              ]
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total",
                    "page",
                    "results"
                  ],
                  "properties": {
                    "total": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ListingSummary"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid type or locale"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/api/listings/{type}/{slug}": {
      "get": {
        "summary": "Get one listing detail by type + slug",
        "description": "Rate-limited to 120 requests/min per IP.",
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "sale",
                "rent"
              ]
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "locale",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "fr",
                "th",
                "zh"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Listing detail.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListingDetail"
                }
              }
            }
          },
          "400": {
            "description": "Invalid type or locale"
          },
          "404": {
            "description": "Not found"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ListingSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "transactionType": {
            "type": "string",
            "enum": [
              "sale",
              "rent"
            ]
          },
          "city": {
            "type": "string"
          },
          "area": {
            "type": "string"
          },
          "bedrooms": {
            "type": "integer"
          },
          "bathrooms": {
            "type": "integer"
          },
          "areaSqm": {
            "type": "number"
          },
          "priceThb": {
            "type": [
              "number",
              "null"
            ],
            "description": "null when priceOnRequest is true."
          },
          "priceOnRequest": {
            "type": "boolean"
          },
          "image": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          }
        }
      },
      "ListingDetail": {
        "type": "object",
        "description": "Extends the summary with full detail; description is Markdown.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "listingCode": {
            "type": "string"
          },
          "transactionType": {
            "type": "string",
            "enum": [
              "sale",
              "rent"
            ]
          },
          "propertyType": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "area": {
            "type": "string"
          },
          "priceThb": {
            "type": [
              "number",
              "null"
            ]
          },
          "priceOnRequest": {
            "type": "boolean"
          },
          "bedrooms": {
            "type": "integer"
          },
          "bathrooms": {
            "type": "integer"
          },
          "areaSqm": {
            "type": "number"
          },
          "floor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "yearBuilt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "furnished": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "tenure": {
            "type": [
              "string",
              "null"
            ]
          },
          "availableFrom": {
            "type": [
              "string",
              "null"
            ]
          },
          "coordinates": {
            "type": "object",
            "properties": {
              "lat": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "lng": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          },
          "description": {
            "type": "string",
            "description": "Markdown."
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "image": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "gallery": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}