# Basic SQLite MCP server
# =======================
# A container-mode MCPServer, using only fields the operator honours.
#
# The operator is the deploy-time admission plane: it turns this CR into a
# workload and enforces the declared capabilities. Runtime behaviour Hangar
# owns -- idle stop, circuit breaking, tool allow-lists -- is NOT set here. See
# the note at the bottom.

apiVersion: mcp-hangar.io/v1alpha2
kind: MCPServer
metadata:
  name: sqlite-tools
  namespace: mcp-servers
  labels:
    app.kubernetes.io/name: sqlite-tools
    mcp-hangar.io/category: database
spec:
  mode: container
  image: ghcr.io/modelcontextprotocol/mcp-sqlite:latest

  replicas: 1

  # Allow up to 60 seconds for startup.
  startupTimeout: "60s"

  resources:
    requests:
      memory: "128Mi"
      cpu: "100m"
    limits:
      memory: "512Mi"
      cpu: "500m"

  env:
    - name: SQLITE_DB_PATH
      value: /data/database.db

  volumes:
    - name: data
      mountPath: /data
      persistentVolumeClaim:
        claimName: sqlite-data

  securityContext:
    runAsNonRoot: true
    runAsUser: 65534
    readOnlyRootFilesystem: true
    allowPrivilegeEscalation: false
    capabilities:
      drop:
        - ALL

  # What this server is allowed to reach. The operator generates a
  # NetworkPolicy from `network` and reports violations per `enforcementMode`.
  capabilities:
    network:
      # A SQLite server needs no external network access at all.
      egress: []
      dnsAllowed: false
      loopbackAllowed: false
    tools:
      maxCount: 10
      schemaDriftAlert: true
    enforcementMode: alert

---
# PVC for SQLite data
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: sqlite-data
  namespace: mcp-servers
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

# ---------------------------------------------------------------------------
# Not fields on this CR, deliberately
# ---------------------------------------------------------------------------
# This example used to set `idleTTL`, `healthCheck`, and `capabilities`
# subtrees for filesystem, environment and resources. The operator never read
# any of them -- they were removed from the CRD in the honesty pass
# (mcp-hangar/mcp-hangar-operator#112), and the examples kept teaching them.
#
# Where those behaviours actually live:
#
#   * idle stop      -> Hangar's own config: `idle_ttl_s` per server in
#                       `config.yaml`, or the REST API. Servers discovered from
#                       a cluster get the create default of 300s.
#   * health checks  -> Hangar polls its servers; interval and thresholds are
#                       Hangar configuration, not CR fields.
#   * tool allow-lists, circuit breaking, load balancing -> Hangar, same place.
#
# Do not "fix" this by having the operator push those to Hangar's REST API.
# That is a deliberate split, not an omission.
