name: secure-agent-access

stores:
  cache:
    type: memory

catalogs:
  api_catalog:
    type: inline
    options:
      subjects:
        id_params:
          schema: |
            {
              "type": "object",
              "properties": { "id": { "type": "string" } },
              "required": [ "id" ]
            }

bindings:
  north_tcp_server:
    type: tcp
    kind: server
    options:
      host: 0.0.0.0
      port: 7114
    routes:
      - when:
          - port: 7114
        exit: north_http_server

  north_http_server:
    type: http
    kind: server
    options:
      access-control:
        policy: cross-origin
    routes:
      - when:
          - headers:
              ":path": /mcp
        exit: north_mcp_server

  north_mcp_server:
    type: mcp
    kind: server
    exit: north_mcp_proxy

  #region mcp_proxy
  north_mcp_proxy:
    type: mcp
    kind: proxy
    options:
      cache:
        store: cache
        ttl: PT5M
    routes:
      - exit: billing_http_proxy
        when:
          - toolkit: billing
      - exit: support_http_proxy
        when:
          - toolkit: support
      - exit: inventory_http_proxy
        when:
          - toolkit: inventory
  #endregion mcp_proxy

  billing_http_proxy:
    type: mcp-http
    kind: proxy
    options:
      tools:
        get_payment_status:
          description: Look up the status of a payment by identifier.
          summary: "Routed to ${result.url}"
          schemas:
            input:
              model: json
              catalog:
                api_catalog:
                  - subject: id_params
                    version: latest
    routes:
      - when:
          - tool: get_payment_status
        exit: sys:http_client
        with:
          headers:
            ":method": GET
            ":scheme": http
            ":authority": api:80
            ":path": /anything/billing/${args.id}

  support_http_proxy:
    type: mcp-http
    kind: proxy
    options:
      tools:
        get_ticket_status:
          description: Look up the status of a support ticket by identifier.
          summary: "Routed to ${result.url}"
          schemas:
            input:
              model: json
              catalog:
                api_catalog:
                  - subject: id_params
                    version: latest
    routes:
      - when:
          - tool: get_ticket_status
        exit: sys:http_client
        with:
          headers:
            ":method": GET
            ":scheme": http
            ":authority": api:80
            ":path": /anything/support/${args.id}

  inventory_http_proxy:
    type: mcp-http
    kind: proxy
    options:
      tools:
        get_stock_level:
          description: Look up the stock level of an item by identifier.
          summary: "Routed to ${result.url}"
          schemas:
            input:
              model: json
              catalog:
                api_catalog:
                  - subject: id_params
                    version: latest
    routes:
      - when:
          - tool: get_stock_level
        exit: sys:http_client
        with:
          headers:
            ":method": GET
            ":scheme": http
            ":authority": api:80
            ":path": /anything/inventory/${args.id}
