name: openapi-specs-as-tools

stores:
  cache:
    type: memory

#region spec
catalogs:
  spec_catalog:
    type: inline
    options:
      subjects:
        billing_openapi:
          schema: |
            openapi: 3.0.3
            info:
              title: Billing API
              version: "1.0.0"
            servers:
              - url: http://placeholder
            paths:
              /anything/billing/{id}:
                get:
                  operationId: getPaymentStatus
                  parameters:
                    - name: id
                      in: path
                      required: true
                      schema:
                        type: string
                  responses:
                    '200':
                      description: OK
#endregion spec

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

  north_mcp_proxy:
    type: mcp
    kind: proxy
    options:
      cache:
        store: cache
        ttl: PT5M
    routes:
      - exit: billing_openapi_client
        when:
          - toolkit: billing

  #region client
  billing_openapi_client:
    type: mcp-openapi
    kind: client
    options:
      specs:
        billing:
          server: http://api:80
          catalog:
            spec_catalog:
              subject: billing_openapi
              version: latest
    routes:
      - when:
          - tool: get_payment_status
        with:
          spec: billing
          operation: getPaymentStatus
  #endregion client
