{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "SAP MCP Configuration",
  "description": "Profile-managed configuration schema for SAP MCP Server.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "_comment": {
      "type": "string"
    },
    "_docs": {
      "type": "string"
    },
    "_version": {
      "type": "string"
    },
    "mode": {
      "type": "string",
      "enum": ["readonly", "local-dev-keypair", "external-signer", "delegated-session", "hosted-api"],
      "default": "readonly",
      "description": "Server operating mode."
    },
    "rpcUrl": {
      "type": "string",
      "format": "uri",
      "default": "https://api.mainnet-beta.solana.com",
      "description": "Primary Solana RPC endpoint."
    },
    "rpcUrlDevnet": {
      "type": "string",
      "format": "uri"
    },
    "rpcUrlTestnet": {
      "type": "string",
      "format": "uri"
    },
    "programId": {
      "type": "string",
      "default": "SAPpUhsWLJG1FfkGRcXagEDMrMsWGjbky7AyhGpFETZ",
      "description": "SAP Protocol program ID."
    },
    "commitment": {
      "type": "string",
      "enum": ["processed", "confirmed", "finalized"],
      "default": "confirmed"
    },
    "agentPubkey": {
      "type": "string",
      "description": "Public key associated with the SAP MCP profile signer."
    },
    "maxRetries": {
      "type": "integer",
      "minimum": 1,
      "default": 3
    },
    "retryDelayMs": {
      "type": "integer",
      "minimum": 1,
      "default": 1000
    },
    "walletPath": {
      "type": "string",
      "description": "Dedicated profile wallet path. Do not point this at the Solana CLI keypair unless explicitly intended."
    },
    "walletEncrypted": {
      "type": "boolean",
      "default": false
    },
    "walletPassphraseEnv": {
      "type": "string"
    },
    "externalSignerUrl": {
      "type": "string",
      "format": "uri"
    },
    "externalSignerTimeoutMs": {
      "type": "integer",
      "minimum": 1,
      "default": 30000
    },
    "enableHttp": {
      "type": "boolean",
      "default": false
    },
    "httpPort": {
      "type": "integer",
      "minimum": 1,
      "maximum": 65535,
      "default": 8787
    },
    "httpHost": {
      "type": "string",
      "default": "127.0.0.1"
    },
    "httpCorsOrigins": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "maxTxValueSol": {
      "type": "number",
      "minimum": 0,
      "default": 10
    },
    "requireApprovalAboveSol": {
      "type": "number",
      "minimum": 0,
      "default": 1
    },
    "dailyLimitSol": {
      "type": "number",
      "minimum": 0,
      "default": 100
    },
    "allowedTools": {
      "oneOf": [
        {
          "const": "all"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      ],
      "default": "all"
    },
    "logLevel": {
      "type": "string",
      "enum": ["debug", "info", "warn", "error"],
      "default": "info"
    },
    "logFormat": {
      "type": "string",
      "enum": ["json", "pretty"],
      "default": "pretty"
    },
    "logFile": {
      "type": "string"
    },
    "enableMetrics": {
      "type": "boolean",
      "default": false
    },
    "metricsPort": {
      "type": "integer",
      "minimum": 1,
      "maximum": 65535,
      "default": 9090
    },
    "enableCache": {
      "type": "boolean",
      "default": true
    },
    "cacheTtlSeconds": {
      "type": "integer",
      "minimum": 1,
      "default": 300
    },
    "enableRateLimit": {
      "type": "boolean",
      "default": true
    },
    "rateLimitPerMinute": {
      "type": "integer",
      "minimum": 1,
      "default": 60
    },
    "$security": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "requireApprovalFor": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "_comment": {
          "type": "string"
        },
        "approvalTimeout": {
          "type": "integer",
          "minimum": 1
        },
        "maxChangesPerDay": {
          "type": "integer",
          "minimum": 1
        },
        "requireMultiSig": {
          "type": "boolean"
        },
        "multiSigThreshold": {
          "type": "integer",
          "minimum": 1
        },
        "multiSigApprovers": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "$audit": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "_comment": {
          "type": "string"
        },
        "logPath": {
          "type": "string"
        },
        "retentionDays": {
          "type": "integer",
          "minimum": 1
        },
        "submitToOracle": {
          "type": "boolean"
        },
        "oracleEndpoint": {
          "type": "string"
        }
      }
    },
    "bento": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "apiKey": {
          "type": "string"
        },
        "agentId": {
          "type": "string"
        },
        "endpoint": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "policy": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "type": "string",
          "enum": ["local-only", "bento-only", "hybrid"]
        },
        "failOpen": {
          "type": "boolean"
        },
        "logging": {
          "type": "boolean"
        }
      }
    },
    "monetization": {
      "type": "object",
      "additionalProperties": false,
      "description": "Optional hosted HTTP monetization through x402 with pay.sh checkout metadata.",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": false
        },
        "provider": {
          "type": "string",
          "enum": ["x402", "pay-sh"],
          "default": "x402"
        },
        "payTo": {
          "type": "string",
          "description": "Solana payment recipient for x402 settlement."
        },
        "network": {
          "type": "string",
          "description": "Optional CAIP-2 Solana network override, e.g. solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp."
        },
        "facilitatorUrl": {
          "type": "string",
          "format": "uri",
          "description": "Required when monetization is enabled. Use the OOBE hosted facilitator or a self-hosted sap-mcp-facilitator URL."
        },
        "facilitatorAuthToken": {
          "type": "string"
        },
        "maxTimeoutSeconds": {
          "type": "integer",
          "minimum": 1,
          "default": 120
        },
        "payShCheckoutUrl": {
          "type": "string",
          "format": "uri",
          "description": "Optional pay.sh checkout URL included in 402 response bodies."
        },
        "strictTools": {
          "type": "boolean",
          "default": false,
          "description": "When true, hosted monetization charges every non-essential tool call. MCP handshake/discovery, base profile, skills bootstrap, and local payment bridge helper tools remain free."
        },
        "prices": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "readPremiumUsd": {
              "type": "number",
              "exclusiveMinimum": 0,
              "default": 0.001
            },
            "builderUsd": {
              "type": "number",
              "exclusiveMinimum": 0,
              "default": 0.008
            },
            "valueFixedUsd": {
              "type": "number",
              "minimum": 0,
              "default": 0.09
            },
            "heavyValueUsd": {
              "type": "number",
              "minimum": 0,
              "default": 0.15
            },
            "valueBps": {
              "type": "number",
              "minimum": 0,
              "default": 0
            },
            "minUsd": {
              "type": "number",
              "minimum": 0,
              "default": 0.001
            },
            "maxUsd": {
              "type": "number",
              "exclusiveMinimum": 0,
              "default": 100
            }
          }
        }
      }
    },
    "$meta": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "version": {
          "type": "string"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "lastHash": {
          "type": "string"
        }
      }
    }
  },
  "required": ["mode", "rpcUrl", "programId", "commitment"]
}
