{
  "$defs": {
    "AiRiskTier": {
      "description": "Risk tier (mapped to EU AI Act risk levels).",
      "oneOf": [
        {
          "const": "minimal",
          "description": "Minimal — chatbot, content suggestion.",
          "type": "string"
        },
        {
          "const": "limited",
          "description": "Limited — needs transparency disclosure.",
          "type": "string"
        },
        {
          "const": "high",
          "description": "High — autonomous action with material consequence.",
          "type": "string"
        },
        {
          "const": "unacceptable",
          "description": "Unacceptable per Art. 5 EU AI Act.",
          "type": "string"
        }
      ]
    },
    "HumanInLoopPolicy": {
      "description": "Approval / human-in-the-loop policy.",
      "oneOf": [
        {
          "const": "autonomous",
          "description": "Tool executes without human review.",
          "type": "string"
        },
        {
          "const": "always_approve",
          "description": "Tool always requires human approval before execution.",
          "type": "string"
        },
        {
          "const": "conditional_approve",
          "description": "Tool prompts when confidence is below threshold.",
          "type": "string"
        },
        {
          "const": "post_hoc_review",
          "description": "Tool runs but a human reviews afterwards.",
          "type": "string"
        }
      ]
    },
    "IsoDate": {
      "description": "ISO 8601 date (YYYY-MM-DD).",
      "format": "date",
      "type": "string"
    },
    "McpToolStatus": {
      "description": "Lifecycle.",
      "enum": [
        "alpha",
        "beta",
        "stable",
        "deprecated",
        "removed"
      ],
      "type": "string"
    },
    "PathRef": {
      "description": "Path-based cross-reference relative to .corpospec/ root.\nPattern: `^[a-z0-9_-]+(/[a-z0-9_.-]+)+$`",
      "pattern": "^[a-z0-9_-]+(/[a-z0-9_.-]+)+$",
      "type": "string"
    },
    "ToolSideEffect": {
      "description": "Side-effect class.",
      "oneOf": [
        {
          "const": "read_only",
          "description": "Pure read.",
          "type": "string"
        },
        {
          "const": "mutating_idempotent",
          "description": "Mutates local in-tenant state (idempotent).",
          "type": "string"
        },
        {
          "const": "mutating",
          "description": "Mutates state (non-idempotent).",
          "type": "string"
        },
        {
          "const": "external_call",
          "description": "Calls external service (billable / rate-limited).",
          "type": "string"
        },
        {
          "const": "billable",
          "description": "Spends money / incurs billing.",
          "type": "string"
        },
        {
          "const": "sends_communication",
          "description": "Sends external communication.",
          "type": "string"
        },
        {
          "const": "irreversible",
          "description": "Irreversible (deletions, payments, public posts).",
          "type": "string"
        }
      ]
    }
  },
  "$id": "https://corpospec.com/schemas/v0.16.0/mcp-tool.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "MCP tool record.",
  "properties": {
    "audit_logged": {
      "description": "Whether invocations are audit-logged.",
      "type": "boolean"
    },
    "created_at": {
      "$ref": "#/$defs/IsoDate"
    },
    "deprecated_on": {
      "anyOf": [
        {
          "$ref": "#/$defs/IsoDate"
        },
        {
          "type": "null"
        }
      ]
    },
    "description": {
      "type": "string"
    },
    "docs_ref": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to docs."
    },
    "governing_bdr": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to the BDR governing this tool."
    },
    "human_in_loop": {
      "$ref": "#/$defs/HumanInLoopPolicy"
    },
    "id": {
      "$ref": "#/$defs/PathRef"
    },
    "input_schema_ref": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to the JSON-schema of the inputs."
    },
    "max_runtime_seconds": {
      "description": "Maximum runtime seconds before timeout.",
      "format": "int32",
      "type": "integer"
    },
    "min_confidence": {
      "description": "Minimum confidence to auto-invoke (0.0–1.0; relevant for\nConditionalApprove).",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "name": {
      "description": "Tool name as exposed via MCP.",
      "type": "string"
    },
    "output_schema_ref": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to the JSON-schema of the outputs."
    },
    "owner": {
      "$ref": "#/$defs/PathRef"
    },
    "required_permissions": {
      "description": "Permission scopes required to invoke.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "risk_tier": {
      "$ref": "#/$defs/AiRiskTier"
    },
    "server": {
      "$ref": "#/$defs/PathRef",
      "description": "PathRef to the MCP server hosting this tool."
    },
    "side_effects": {
      "description": "Side-effect category (max severity wins for safety).",
      "items": {
        "$ref": "#/$defs/ToolSideEffect"
      },
      "type": "array"
    },
    "status": {
      "$ref": "#/$defs/McpToolStatus"
    }
  },
  "required": [
    "id",
    "server",
    "name",
    "description",
    "side_effects",
    "risk_tier",
    "status",
    "required_permissions",
    "human_in_loop",
    "audit_logged",
    "max_runtime_seconds",
    "owner",
    "created_at"
  ],
  "title": "McpTool",
  "type": "object",
  "x-corpospec-pillar": "integrations"
}