{
  "openapi": "3.1.0",
  "info": {
    "title": "Flowcenter Public Service Description",
    "version": "1.0.0",
    "description": "Canonical machine-readable entry points for Flowcenter agents. The complete typed API contract is available at /openapi.json."
  },
  "servers": [{ "url": "https://flowcenter.vn" }],
  "externalDocs": {
    "description": "Complete Flowcenter OpenAPI contract",
    "url": "https://flowcenter.vn/openapi.json"
  },
  "paths": {
    "/agents.json": {
      "get": {
        "operationId": "getAgentInstructions",
        "summary": "Agent instructions",
        "responses": {
          "200": {
            "description": "Agent instructions and discovery URLs.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AgentInstructions" } } }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApiSpec",
        "summary": "Complete API contract",
        "responses": {
          "200": {
            "description": "Complete Flowcenter OpenAPI 3.1 document.",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "handleMcpJsonRpc",
        "summary": "Streamable HTTP MCP endpoint",
        "description": "Public read-only MCP discovery tools. Initialize a session before calling tools/list or tools/call.",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/McpRequest" } } }
        },
        "responses": {
          "200": {
            "description": "MCP JSON-RPC response.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/McpResponse" } } }
          },
          "400": {
            "description": "MCP request error.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AgentInstructions": {
        "type": "object",
        "required": ["name", "homepage", "whenToUse", "developerPortal"],
        "properties": {
          "name": { "type": "string" },
          "homepage": { "type": "string", "format": "uri" },
          "whenToUse": { "type": "array", "items": { "type": "string" } },
          "developerPortal": { "type": "string", "format": "uri" }
        }
      },
      "McpRequest": {
        "type": "object",
        "required": ["jsonrpc", "method"],
        "properties": { "jsonrpc": { "type": "string", "const": "2.0" }, "id": {}, "method": { "type": "string" }, "params": { "type": "object" } }
      },
      "McpResponse": {
        "type": "object",
        "required": ["jsonrpc"],
        "properties": { "jsonrpc": { "type": "string", "const": "2.0" }, "id": {}, "result": { "type": "object" }, "error": { "type": "object" } }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["ok", "error"],
        "properties": { "ok": { "type": "boolean", "const": false }, "error": { "type": "object" } }
      }
    }
  }
}
