{
  "openapi": "3.1.0",
  "info": {
    "title": "Eratai.lt Agent API",
    "description": "Read-only catalog and store operations for browser and agent clients. Compatible with OpenAPI tool calling. All operations are safe (readOnly) and non-destructive. MCP equivalent: https://eratai.lt/mcp",
    "version": "1.0.0",
    "contact": {
      "name": "Eratai.lt",
      "email": "info@eratai.lt",
      "url": "https://eratai.lt/"
    },
    "license": {
      "name": "Store data — public read",
      "url": "https://eratai.lt/content/3-privatumo-politika"
    }
  },
  "servers": [
    {
      "url": "https://eratai.lt",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "store",
      "description": "Shop identity and contact"
    },
    {
      "name": "catalog",
      "description": "Categories and products"
    },
    {
      "name": "discovery",
      "description": "Tool catalog and API index"
    }
  ],
  "paths": {
    "/agent-api/": {
      "get": {
        "operationId": "getApiIndex",
        "summary": "API index",
        "description": "Lists available read operations and links to OpenAPI/MCP.",
        "tags": ["discovery"],
        "x-readOnly": true,
        "x-destructive": false,
        "responses": {
          "200": {
            "description": "Index payload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "name": { "type": "string" },
                    "operations": { "type": "array", "items": { "type": "object" } }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/agent-api/tools": {
      "get": {
        "operationId": "listTools",
        "summary": "List agent tools",
        "description": "MCP-compatible tool definitions with annotations (readOnlyHint, destructiveHint).",
        "tags": ["discovery"],
        "x-readOnly": true,
        "x-destructive": false,
        "responses": {
          "200": {
            "description": "Tool list",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ToolsResponse" }
              }
            }
          }
        }
      }
    },
    "/agent-api/store": {
      "get": {
        "operationId": "getStoreInfo",
        "summary": "Get store info",
        "description": "Phone, email, Kaunas/Šiauliai addresses and opening hours. Maps to MCP tool get_store_info.",
        "tags": ["store"],
        "x-readOnly": true,
        "x-destructive": false,
        "x-mcp-tool": "get_store_info",
        "responses": {
          "200": {
            "description": "Store info",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/StoreInfo" }
              }
            }
          }
        }
      }
    },
    "/agent-api/categories": {
      "get": {
        "operationId": "listCategories",
        "summary": "List categories",
        "description": "Active public categories. Maps to MCP tool list_categories.",
        "tags": ["catalog"],
        "x-readOnly": true,
        "x-destructive": false,
        "x-mcp-tool": "list_categories",
        "parameters": [
          {
            "name": "parent_id",
            "in": "query",
            "required": false,
            "schema": { "type": "integer" },
            "description": "Parent category id (default Home children)"
          }
        ],
        "responses": {
          "200": {
            "description": "Category list",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CategoriesResponse" }
              }
            }
          },
          "400": {
            "description": "Invalid arguments",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/agent-api/products/search": {
      "get": {
        "operationId": "searchProducts",
        "summary": "Search products",
        "description": "Search active products by keyword. Maps to MCP tool search_products.",
        "tags": ["catalog"],
        "x-readOnly": true,
        "x-destructive": false,
        "x-mcp-tool": "search_products",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "schema": { "type": "string", "minLength": 1 },
            "description": "Search keywords"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": { "type": "integer", "minimum": 1, "maximum": 20, "default": 8 }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SearchResponse" }
              }
            }
          },
          "400": {
            "description": "Missing or invalid query",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/agent-api/products/{id}": {
      "get": {
        "operationId": "getProductById",
        "summary": "Get product by id",
        "description": "Single product by PrestaShop id. Maps to MCP tool get_product.",
        "tags": ["catalog"],
        "x-readOnly": true,
        "x-destructive": false,
        "x-mcp-tool": "get_product",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": { "type": "integer" }
          }
        ],
        "responses": {
          "200": {
            "description": "Product",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ProductResponse" }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/agent-api/products/by-reference/{reference}": {
      "get": {
        "operationId": "getProductByReference",
        "summary": "Get product by SKU",
        "description": "Single product by reference/SKU. Maps to MCP tool get_product.",
        "tags": ["catalog"],
        "x-readOnly": true,
        "x-destructive": false,
        "x-mcp-tool": "get_product",
        "parameters": [
          {
            "name": "reference",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Product",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ProductResponse" }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorBody": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "missing_argument",
              "invalid_argument",
              "not_found",
              "unknown_tool",
              "method_not_allowed",
              "parse_error",
              "bootstrap_failed",
              "batch_not_supported",
              "invalid_request"
            ]
          },
          "message": { "type": "string" },
          "hint": { "type": "string" },
          "retryable": { "type": "boolean" },
          "details": { "type": "object", "additionalProperties": true }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["ok", "error"],
        "properties": {
          "ok": { "type": "boolean", "const": false },
          "error": { "$ref": "#/components/schemas/ErrorBody" }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "name": { "type": "string" },
          "reference": { "type": "string" },
          "manufacturer": { "type": ["string", "null"] },
          "price": { "type": "number" },
          "currency": { "type": "string", "example": "EUR" },
          "quantity": { "type": "integer" },
          "availability": { "type": "string" },
          "in_stock": { "type": "boolean" },
          "url": { "type": "string", "format": "uri" }
        }
      },
      "ProductResponse": {
        "allOf": [
          {
            "type": "object",
            "properties": { "ok": { "type": "boolean", "const": true } }
          },
          { "$ref": "#/components/schemas/Product" }
        ]
      },
      "SearchResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean" },
          "query": { "type": "string" },
          "count": { "type": "integer" },
          "products": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/Product" }
          }
        }
      },
      "CategoriesResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean" },
          "parent_id": { "type": "integer" },
          "count": { "type": "integer" },
          "categories": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": { "type": "integer" },
                "name": { "type": "string" },
                "url": { "type": "string", "format": "uri" }
              }
            }
          }
        }
      },
      "StoreInfo": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean" },
          "name": { "type": "string" },
          "legal_name": { "type": "string" },
          "company_code": { "type": "string" },
          "vat_code": { "type": "string" },
          "url": { "type": "string" },
          "phone": { "type": "string" },
          "email": { "type": "string" },
          "locations": { "type": "array", "items": { "type": "object" } },
          "contact_page": { "type": "string" },
          "about_page": { "type": "string" }
        }
      },
      "ToolsResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean" },
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": { "type": "string" },
                "title": { "type": "string" },
                "description": { "type": "string" },
                "annotations": {
                  "type": "object",
                  "properties": {
                    "title": { "type": "string" },
                    "readOnlyHint": { "type": "boolean" },
                    "destructiveHint": { "type": "boolean" },
                    "idempotentHint": { "type": "boolean" },
                    "openWorldHint": { "type": "boolean" }
                  }
                },
                "inputSchema": { "type": "object" }
              }
            }
          }
        }
      }
    }
  },
  "x-mcp": {
    "endpoint": "https://eratai.lt/mcp",
    "protocolVersion": "2025-03-26",
    "allToolsReadOnly": true,
    "allToolsDestructive": false
  },
  "x-webmcp": {
    "script": "https://eratai.lt/themes/hummingbird/assets/js/webmcp.js",
    "apiBase": "https://eratai.lt/agent-api"
  }
}
