{
  "openapi": "3.1.0",
  "info": {
    "title": "KusiAI GEO & Agentic Web API",
    "description": "API oficial de KusiAI para auditorias forenses de Generative Engine Optimization (GEO), diagnostico KusiReadiness de 4 puertas, medicion de Citation Share, tareas asincronas e integracion con agentes autonomos de IA y servidores MCP. Politica de Limites de Tasa (Rate Limits): Nivel publico / Agent Discovery: 60 peticiones/minuto (cabeceras estandar RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset y 429 Retry-After). Nivel Enterprise: 600 peticiones/minuto.",
    "version": "1.0.0",
    "contact": {
      "name": "KusiAI Engineering Support",
      "email": "hola@kusiai.es",
      "url": "https://kusiai.es/developers"
    },
    "x-versioning": {
      "strategy": "uri-path",
      "current_version": "v1",
      "supported_versions": [
        "v1"
      ],
      "default_version": "v1"
    },
    "x-deprecation-policy": {
      "notice_period_days": 90,
      "headers": [
        "Sunset",
        "Deprecation",
        "Link"
      ],
      "rfc": "RFC 8594 / RFC 9745"
    }
  },
  "servers": [
    {
      "url": "https://kusiai.es",
      "description": "Servidor de Producción Principal (Oficial Apex)"
    }
  ],
  "paths": {
    "/auth/token": {
      "post": {
        "summary": "Obtener Token de Acceso Bearer (OAuth2 / Token Exchange)",
        "description": "Genera o refresca un token de acceso JWT Bearer para llamadas a endpoints protegidos (/api/v1/audit, /api/v1/citation-share, /api/v1/jobs/{job_id}). Admite autenticación por client_credentials o api_key de forma inmediata.",
        "operationId": "getAuthToken",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenRequest"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token emitido con exito",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenResponse"
                }
              }
            }
          },
          "400": {
            "description": "Parametros de autenticacion invalidos",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Credenciales no validas",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/auth/register": {
      "post": {
        "summary": "Registro Autonomo de Agentes de IA (Auth.md Protocol)",
        "description": "Registro autónomo e instantáneo de agentes de IA sin aprobación manual previa (Open Dynamic Agent Registration). El agente envía su nombre e identidad y recibe de inmediato un client_id y api_key Bearer activos para operar.",
        "operationId": "registerAutonomousAgent",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentRegistrationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Agente registrado con exito",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentRegistrationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Datos de registro invalidos",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audit": {
      "post": {
        "summary": "Ejecutar Auditoría Forense KusiGEO (Síncrona)",
        "description": "Analiza la visibilidad, bloqueos WAF y presencia de una URL en los principales modelos de lenguaje (ChatGPT, Gemini, Perplexity, Claude, DeepSeek, Qwen). Admite Idempotency-Key para prevenir duplicados.",
        "operationId": "runGeoAudit",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuditRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Informe forense generado con éxito",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Petición inválida o parámetros incorrectos",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "No autorizado",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Límite de tasa excedido",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos que el cliente debe esperar antes de reintentar"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/api/v1/audit/async": {
      "post": {
        "summary": "Iniciar Auditoría Forense Asíncrona (Async Job)",
        "description": "Inicia una tarea de auditoría en segundo plano para análisis exhaustivos de más de 50 prompts. Devuelve un job_id y URL de sondeo con estado 202 Accepted.",
        "operationId": "startAsyncGeoAudit",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuditRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Tarea de auditoría aceptada y en procesamiento",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri"
                },
                "description": "URL para consultar el estado del trabajo"
              },
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "example": 5
                },
                "description": "Segundos recomendados antes del primer sondeo"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AsyncJobResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error en los datos de la petición",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/api/v1/jobs/{job_id}": {
      "get": {
        "summary": "Consultar Estado de Tarea Asíncrona",
        "description": "Recupera el progreso o resultado final de un trabajo de auditoria previamente lanzado. Requiere el mismo token Bearer utilizado al iniciar la tarea.",
        "operationId": "getJobStatus",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "description": "Identificador único de la tarea",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estado actual de la tarea",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobStatusResponse"
                }
              }
            }
          },
          "404": {
            "description": "Trabajo no encontrado",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/api/v1/citation-share": {
      "get": {
        "summary": "Consultar Citation Share de una Marca",
        "description": "Calcula el ratio entre apariciones ganadas y total de prompts evaluados en la categoría comercial.",
        "operationId": "getCitationShare",
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "description": "Dominio o nombre de la marca a evaluar",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/PaginationLimit"
          },
          {
            "$ref": "#/components/parameters/PaginationOffset"
          }
        ],
        "responses": {
          "200": {
            "description": "Métricas de cuota de citación",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CitationShareResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/api/v1/search": {
      "get": {
        "summary": "Búsqueda Semántica Vectorial con Paginación",
        "description": "Recupera fragmentos de investigación y conocimiento sobre GEO y Agent Readiness indexados en el grafo semántico de KusiAI. Endpoint público de acceso abierto, no requiere credenciales.",
        "operationId": "searchKnowledgeBase",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "description": "Texto o concepto técnico a buscar",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/PaginationLimit"
          },
          {
            "$ref": "#/components/parameters/PaginationOffset"
          },
          {
            "$ref": "#/components/parameters/PaginationCursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Resultados de búsqueda semántica paginados",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimit-Limit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimit-Remaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/audit": {
      "post": {
        "summary": "Alias Apex de Auditoría (Requiere BearerAuth)",
        "operationId": "runGeoAuditApex",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuditRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Informe forense generado con éxito",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/api/citation-share": {
      "get": {
        "summary": "Alias Apex de Citation Share (Requiere BearerAuth)",
        "operationId": "getCitationShareApex",
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Métricas de cuota de citación",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CitationShareResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/api/search": {
      "get": {
        "summary": "Alias Apex de Búsqueda (v1)",
        "operationId": "searchKnowledgeBaseApex",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resultados de búsqueda",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          }
        },
        "security": [],
        "description": "Alias apex público de búsqueda semántica en la base de conocimiento abierta. No requiere credenciales."
      }
    }
  },
  "components": {
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "format": "uuid",
          "example": "e4eaaaf2-d142-11e1-b3e4-080027620cdd"
        },
        "description": "Identificador único UUID v4 para garantizar la idempotencia en reintentos automáticos de agentes."
      },
      "PaginationLimit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "default": 20,
          "minimum": 1,
          "maximum": 100
        },
        "description": "Número máximo de resultados por página."
      },
      "PaginationOffset": {
        "name": "offset",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "default": 0,
          "minimum": 0
        },
        "description": "Índice inicial del desplazamiento para paginación."
      },
      "PaginationCursor": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string"
        },
        "description": "Token opaco para paginación de cursor continua."
      }
    },
    "headers": {
      "RateLimit-Limit": {
        "schema": {
          "type": "integer",
          "example": 60
        },
        "description": "Número máximo de peticiones permitidas en la ventana de tiempo de 60 segundos (60 req/min en capa pública / Agent Discovery, 600 req/min en Enterprise)."
      },
      "RateLimit-Remaining": {
        "schema": {
          "type": "integer",
          "example": 118
        },
        "description": "Número de peticiones restantes en la ventana actual"
      },
      "RateLimit-Reset": {
        "schema": {
          "type": "integer",
          "example": 42
        },
        "description": "Segundos hasta que la cuota se reinicie"
      }
    },
    "schemas": {
      "AuditRequest": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "URL completa del sitio web a auditar",
            "example": "https://empresa.com"
          },
          "market": {
            "type": "string",
            "default": "ES",
            "description": "Código de país de dos letras para el contexto de búsqueda (ej. ES, MX, US)"
          }
        }
      },
      "AuditResponse": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string"
          },
          "global_score": {
            "type": "number",
            "minimum": 0.0,
            "maximum": 100.0,
            "description": "Puntuacion global de preparacion agentica y visibilidad GEO (escala porcentual de 0.0 a 100.0 puntos, donde >= 80.0 certifica Nivel 5 Agent-Native).",
            "example": 88.5
          },
          "recognition_share": {
            "type": "number",
            "minimum": 0.0,
            "maximum": 100.0,
            "description": "Porcentaje de citacion cuando el usuario consulta especificamente por el nombre de la empresa (escala porcentual de 0.0% a 100.0%).",
            "example": 100.0
          },
          "discovery_share": {
            "type": "number",
            "minimum": 0.0,
            "maximum": 100.0,
            "description": "Porcentaje de recomendacion cuando el usuario formula preguntas comerciales de categoria sin nombrar a la empresa (escala porcentual de 0.0% a 100.0%).",
            "example": 75.0
          },
          "citation_gap": {
            "type": "number",
            "minimum": 0.0,
            "maximum": 100.0,
            "description": "Diferencia porcentual de visibilidad frente al competidor lider en la misma categoria comercial (escala de 0.0% a 100.0%).",
            "example": 25.0
          },
          "waf_block_detected": {
            "type": "boolean",
            "description": "Indica si los rastreadores oficiales de IA (GPTBot, ClaudeBot, PerplexityBot) reciben errores HTTP 403 o desafios WAF al intentar acceder.",
            "example": false
          }
        },
        "example": {
          "domain": "empresa.com",
          "global_score": 88.5,
          "recognition_share": 100.0,
          "discovery_share": 75.0,
          "citation_gap": 25.0,
          "waf_block_detected": false
        }
      },
      "AsyncJobResponse": {
        "type": "object",
        "required": [
          "job_id",
          "status",
          "poll_url"
        ],
        "properties": {
          "job_id": {
            "type": "string",
            "example": "job_geo_8f7b3a9c"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "completed",
              "failed"
            ],
            "example": "processing"
          },
          "poll_url": {
            "type": "string",
            "format": "uri",
            "example": "https://kusiai.es/api/v1/jobs/job_geo_8f7b3a9c"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-08-29T12:00:00Z"
          }
        }
      },
      "JobStatusResponse": {
        "type": "object",
        "required": [
          "job_id",
          "status"
        ],
        "properties": {
          "job_id": {
            "type": "string",
            "example": "job_geo_8f7b3a9c"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "completed",
              "failed"
            ],
            "example": "completed"
          },
          "progress_percent": {
            "type": "integer",
            "example": 100
          },
          "result": {
            "$ref": "#/components/schemas/AuditResponse"
          }
        }
      },
      "CitationShareResponse": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string"
          },
          "citation_share_percent": {
            "type": "number",
            "minimum": 0.0,
            "maximum": 100.0,
            "description": "Cuota neta de citacion ganada en motores generativos frente al total de consultas comerciales (escala de 0.0% a 100.0%).",
            "example": 82.4
          },
          "sample_size": {
            "type": "integer",
            "minimum": 1,
            "description": "Numero total de consultas comerciales e interacciones evaluadas en la muestra estadistica.",
            "example": 50
          },
          "pagination": {
            "$ref": "#/components/schemas/PaginationMetadata"
          }
        },
        "example": {
          "domain": "empresa.com",
          "citation_share_percent": 82.4,
          "sample_size": 50,
          "pagination": {
            "total_items": 50,
            "limit": 20,
            "offset": 0,
            "has_more": false,
            "next_cursor": null
          }
        }
      },
      "SearchResponse": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "snippet": {
                  "type": "string"
                }
              }
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/PaginationMetadata"
          }
        },
        "example": {
          "query": "citation share formula",
          "results": [
            {
              "title": "GEO Framework: Princeton KDD Citation Share",
              "url": "https://kusiai.es/research",
              "snippet": "El Citation Share mide la probabilidad condicional P(Marca | Consulta Comercial) a traves de 6 LLMs frontera."
            }
          ],
          "pagination": {
            "total_items": 1,
            "limit": 20,
            "offset": 0,
            "has_more": false,
            "next_cursor": null
          }
        }
      },
      "PaginationMetadata": {
        "type": "object",
        "properties": {
          "total_items": {
            "type": "integer",
            "example": 103
          },
          "limit": {
            "type": "integer",
            "example": 20
          },
          "offset": {
            "type": "integer",
            "example": 0
          },
          "has_more": {
            "type": "boolean",
            "example": true
          },
          "next_cursor": {
            "type": "string",
            "example": "eyJvZmZzZXQiOjIwfQ=="
          }
        }
      },
      "ProblemDetails": {
        "type": "object",
        "description": "Detalles de problema conformes a RFC 9457",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "description": "URI que identifica el tipo de problema",
            "example": "https://kusiai.es/errors/not-found"
          },
          "title": {
            "type": "string",
            "description": "Resumen corto y legible del error",
            "example": "Endpoint Not Found"
          },
          "status": {
            "type": "integer",
            "description": "Código de estado HTTP",
            "example": 404
          },
          "detail": {
            "type": "string",
            "description": "Explicación legible del fallo",
            "example": "The requested API endpoint does not exist on this server."
          },
          "instance": {
            "type": "string",
            "format": "uri-reference",
            "description": "URI del recurso específico donde ocurrió el error"
          },
          "code": {
            "type": "string",
            "description": "Código de máquina específico de la aplicación",
            "example": "api_route_not_found"
          },
          "resolution_hint": {
            "type": "string",
            "description": "Instrucciones automáticas para agentes",
            "example": "Consult the OpenAPI specification at https://kusiai.es/openapi.json for valid endpoints."
          }
        }
      },
      "TokenRequest": {
        "type": "object",
        "required": [
          "grant_type"
        ],
        "properties": {
          "grant_type": {
            "type": "string",
            "enum": [
              "client_credentials",
              "urn:ietf:params:oauth:grant-type:token-exchange",
              "api_key"
            ],
            "example": "client_credentials",
            "description": "Metodo de concesion OAuth2 o intercambio de credenciales"
          },
          "client_id": {
            "type": "string",
            "example": "agent_kusiai_live",
            "description": "Identificador publico del cliente o agente"
          },
          "client_secret": {
            "type": "string",
            "example": "kusi_sec_bearer_token",
            "description": "Clave secreta de autenticacion del cliente"
          },
          "scope": {
            "type": "string",
            "example": "read audit geo",
            "description": "Ambitos solicitados separados por espacio"
          }
        }
      },
      "TokenResponse": {
        "type": "object",
        "required": [
          "access_token",
          "token_type",
          "expires_in"
        ],
        "properties": {
          "access_token": {
            "type": "string",
            "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
            "description": "Token JWT de acceso Bearer para incluir en la cabecera Authorization"
          },
          "token_type": {
            "type": "string",
            "example": "Bearer",
            "description": "Tipo de token emitido (siempre Bearer)"
          },
          "expires_in": {
            "type": "integer",
            "example": 3600,
            "description": "Tiempo de validez del token en segundos (1 hora)"
          },
          "scope": {
            "type": "string",
            "example": "read audit geo",
            "description": "Ambitos concedidos al agente"
          }
        },
        "example": {
          "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.example",
          "token_type": "Bearer",
          "expires_in": 3600,
          "scope": "read audit geo"
        }
      },
      "AgentRegistrationRequest": {
        "type": "object",
        "required": [
          "agent_name"
        ],
        "properties": {
          "agent_name": {
            "type": "string",
            "example": "ClaudeCode/1.0",
            "description": "Nombre e identificador de version del agente de software"
          },
          "identity_type": {
            "type": "string",
            "enum": [
              "email",
              "identity_assertion",
              "anonymous"
            ],
            "default": "email",
            "description": "Mecanismo de validacion de identidad agéntica"
          },
          "identity": {
            "type": "string",
            "example": "agent@anthropic.com",
            "description": "Correo electronico, URI o DID del operador del agente"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "read",
              "data",
              "llms"
            ],
            "description": "Lista de permisos y accesos requeridos"
          }
        }
      },
      "AgentRegistrationResponse": {
        "type": "object",
        "required": [
          "client_id",
          "access_token",
          "api_key",
          "token_type",
          "expires_in",
          "status"
        ],
        "properties": {
          "client_id": {
            "type": "string",
            "example": "agent_live_9a7f2c",
            "description": "Identificador unico de cliente asignado al agente"
          },
          "access_token": {
            "type": "string",
            "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
            "description": "Token JWT de acceso Bearer emitido de forma inmediata para uso instantaneo"
          },
          "api_key": {
            "type": "string",
            "example": "kusi_sec_bearer_token",
            "description": "Clave API de respaldo compatible con cabeceras Bearer"
          },
          "token_type": {
            "type": "string",
            "example": "Bearer",
            "description": "Tipo de token emitido (siempre Bearer)"
          },
          "expires_in": {
            "type": "integer",
            "example": 3600,
            "description": "Segundos de validez del token inicial"
          },
          "status": {
            "type": "string",
            "example": "active",
            "enum": [
              "active"
            ],
            "description": "Estado de provision (inmediato, sin aprobacion manual previa)"
          }
        },
        "example": {
          "client_id": "agent_live_9a7f2c",
          "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.example",
          "api_key": "kusi_sec_bearer_token",
          "token_type": "Bearer",
          "expires_in": 3600,
          "status": "active"
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Autenticación estándar mediante token Bearer obtenido en /auth/token."
      }
    }
  },
  "x-mcp": {
    "server_name": "kusiai-mcp-server",
    "version": "1.0.0",
    "protocol_version": "2024-11-05",
    "transport": "sse",
    "endpoint": "https://kusiai.es/api/mcp/sse",
    "server_card_url": "https://kusiai.es/.well-known/mcp/server-card.json",
    "description": "Servidor MCP oficial de KusiAI para inspeccion pericial de visibilidad en modelos generativos y agentes.",
    "tools": [
      {
        "name": "kusi_geo_audit",
        "description": "Audita Citation Share, preparación agéntica y bloqueos WAF 403 en una URL objetivo.",
        "parameters": {
          "type": "object",
          "properties": {
            "url": {
              "type": "string",
              "format": "uri",
              "description": "Target website URL to audit"
            },
            "market": {
              "type": "string",
              "default": "ES",
              "description": "Two-letter country code for regional search context (e.g. ES, MX, US)"
            }
          },
          "required": [
            "url"
          ]
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "global_score": {
              "type": "number",
              "minimum": 0.0,
              "maximum": 100.0
            },
            "waf_block_detected": {
              "type": "boolean"
            },
            "verdict": {
              "type": "string"
            }
          },
          "example": {
            "global_score": 88.5,
            "waf_block_detected": false,
            "verdict": "Agent-Ready Nivel 5"
          }
        }
      },
      {
        "name": "search_geo_knowledge",
        "description": "Busca en la base de datos de investigación y grafos de conocimiento de KusiAI sobre GEO y Agent Readiness.",
        "parameters": {
          "type": "object",
          "properties": {
            "query": {
              "type": "string",
              "description": "Concept or optimization topic to search"
            }
          },
          "required": [
            "query"
          ]
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "matches": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "example": {
            "matches": [
              "KusiAI GEO Framework Princeton Benchmark",
              "SafeGEO WAF Allowlist Protocol"
            ]
          }
        }
      }
    ],
    "authentication": {
      "type": "bearer",
      "required": true,
      "token_endpoint": "https://kusiai.es/auth/token",
      "register_endpoint": "https://kusiai.es/auth/register",
      "header": "Authorization",
      "format": "Bearer <TOKEN>",
      "query_param": "token",
      "description": "Requiere token Bearer obtenido en /auth/token o /auth/register, enviado en la cabecera 'Authorization: Bearer <token>' o como parametro '?token=<token>' en la conexion SSE."
    }
  }
}