{
  "openapi": "3.1.0",
  "info": {
    "title": "API pública de Efecto Hábito",
    "version": "1.0.0",
    "summary": "Servidor MCP de solo lectura con el contenido publicado de efectohabito.com.",
    "description": "API pública y sin autenticación. Expone el contenido de efectohabito.com a agentes de IA mediante Model Context Protocol sobre HTTP (JSON-RPC 2.0), más un endpoint de estado. No acepta datos personales, no escribe nada y no requiere credenciales.",
    "contact": { "name": "Efecto Hábito", "url": "https://efectohabito.com" },
    "license": { "name": "Contenido © Efecto Hábito. Lectura y cita permitidas; entrenamiento de modelos no autorizado (ver /robots.txt)." }
  },
  "servers": [{ "url": "https://efectohabito.com", "description": "Producción" }],
  "externalDocs": {
    "description": "Cómo usar el servidor MCP",
    "url": "https://efectohabito.com/api-docs.md"
  },
  "paths": {
    "/mcp": {
      "get": {
        "operationId": "descubrirServidorMcp",
        "summary": "Ficha del servidor MCP",
        "description": "Devuelve el nombre, la versión, el transporte y la URL de la tarjeta del servidor. Útil para descubrimiento manual.",
        "responses": {
          "200": {
            "description": "Ficha del servidor",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "serverInfo": { "type": "object" },
                    "protocolVersion": { "type": "string" },
                    "transport": { "type": "string" },
                    "endpoint": { "type": "string", "format": "uri" },
                    "serverCard": { "type": "string", "format": "uri" }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "llamarMcp",
        "summary": "Endpoint MCP (JSON-RPC 2.0, Streamable HTTP)",
        "description": "Métodos soportados: initialize, ping, tools/list, tools/call, resources/list, resources/read, prompts/list. Herramientas disponibles: resumen_efecto_habito, limites_al_citar, precios_y_planes, metodo_efecto_habito, como_empezar, buscar_en_efecto_habito.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/PeticionJsonRpc" },
              "examples": {
                "listarHerramientas": {
                  "summary": "Listar herramientas",
                  "value": { "jsonrpc": "2.0", "id": 1, "method": "tools/list" }
                },
                "buscar": {
                  "summary": "Buscar en el contenido",
                  "value": {
                    "jsonrpc": "2.0",
                    "id": 2,
                    "method": "tools/call",
                    "params": {
                      "name": "buscar_en_efecto_habito",
                      "arguments": { "consulta": "rebote después del Ozempic" }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta JSON-RPC",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/RespuestaJsonRpc" } }
            }
          },
          "202": { "description": "Notificación aceptada (mensaje sin id)" },
          "400": { "description": "JSON inválido" },
          "405": { "description": "Método HTTP no permitido" }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "estadoDelServicio",
        "summary": "Estado del servicio",
        "description": "Comprueba que el contenido fuente se puede leer. Formato inspirado en el borrador IETF health+json.",
        "responses": {
          "200": {
            "description": "Estado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "enum": ["pass", "warn", "fail"] },
                    "version": { "type": "string" },
                    "serviceId": { "type": "string" },
                    "time": { "type": "string", "format": "date-time" },
                    "checks": { "type": "object" }
                  },
                  "required": ["status", "time"]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PeticionJsonRpc": {
        "type": "object",
        "required": ["jsonrpc", "method"],
        "properties": {
          "jsonrpc": { "type": "string", "const": "2.0" },
          "id": { "oneOf": [{ "type": "string" }, { "type": "integer" }] },
          "method": { "type": "string" },
          "params": { "type": "object" }
        }
      },
      "RespuestaJsonRpc": {
        "type": "object",
        "required": ["jsonrpc"],
        "properties": {
          "jsonrpc": { "type": "string", "const": "2.0" },
          "id": { "oneOf": [{ "type": "string" }, { "type": "integer" }, { "type": "null" }] },
          "result": { "type": "object" },
          "error": {
            "type": "object",
            "properties": {
              "code": { "type": "integer" },
              "message": { "type": "string" }
            }
          }
        }
      }
    },
    "securitySchemes": {}
  },
  "security": []
}
