{
  "openapi": "3.1.0",
  "info": {
    "title": "BH Solutions Agentic Web API",
    "version": "1.0.0",
    "description": "API de descoberta, consulta em linguagem natural (NLWeb) e ferramentas MCP da BH Solutions para agentes de IA e conectores OpenAI.",
    "contact": {
      "name": "BH Solutions",
      "url": "https://bhsolutions.com.br/",
      "email": "contato@bhsolutions.com.br"
    }
  },
  "servers": [
    {
      "url": "https://bhsolutions.com.br",
      "description": "Produção (Cloudflare Pages)"
    }
  ],
  "paths": {
    "/ask": {
      "get": {
        "operationId": "askBhSolutions",
        "summary": "Consulta em linguagem natural (NLWeb)",
        "description": "Responde perguntas sobre serviços, metodologia, prazos, PoCs, segurança e casos de uso da BH Solutions.",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "description": "Pergunta do usuário ou agente em português.",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 300
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resposta estruturada e fundamentada no conteúdo oficial do site.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "matched": {
                      "type": "boolean"
                    },
                    "answer": {
                      "type": "string"
                    },
                    "recommendedAction": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "text": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        }
                      }
                    },
                    "sources": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "callMcpServer",
        "summary": "Endpoint Remote MCP Server (JSON-RPC 2.0)",
        "description": "Servidor MCP remoto compatível com Streamable HTTP (initialize, tools/list, tools/call).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "jsonrpc",
                  "method"
                ],
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "enum": [
                      "2.0"
                    ]
                  },
                  "id": {
                    "type": [
                      "string",
                      "number",
                      "null"
                    ]
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "initialize",
                      "ping",
                      "tools/list",
                      "tools/call"
                    ]
                  },
                  "params": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resposta JSON-RPC 2.0 do servidor MCP.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/agent-card.json": {
      "get": {
        "operationId": "getAgentCard",
        "summary": "Manifesto A2A (Agent Card)",
        "description": "Retorna identidade, capacidades e habilidades no padrão Agent-to-Agent (A2A).",
        "responses": {
          "200": {
            "description": "Agent Card JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/lead": {
      "post": {
        "operationId": "submitLead",
        "summary": "Envio direto de lead via Cloudflare Email Service",
        "description": "Recebe nome, e-mail e contexto opcional do lead e envia notificação estruturada para a equipe da BH Solutions.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "nome",
                  "email"
                ],
                "properties": {
                  "nome": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 100
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 254
                  },
                  "empresa": {
                    "type": "string",
                    "maxLength": 150
                  },
                  "whatsapp": {
                    "type": "string",
                    "maxLength": 30
                  },
                  "interesse": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "desafio": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "origem": {
                    "type": "string",
                    "enum": [
                      "formulario",
                      "simulador",
                      "lia",
                      "webmcp"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lead recebido e encaminhado por e-mail.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "leadId": {
                      "type": "string"
                    },
                    "messageId": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro de validação nos dados enviados."
          },
          "429": {
            "description": "Limite de requisições excedido."
          }
        }
      }
    }
  }
}