OpenCost · Capability

OpenCost API

The OpenCost API provides real-time and historical reporting of Kubernetes workload costs and underlying cloud infrastructure spend. OpenCost is an open source CNCF specification and reference implementation for Kubernetes cost monitoring and FinOps.

Run with Naftiko OpencostAPI

What You Can Do

GET
Getallocation — Query Kubernetes workload cost allocations
/allocation
GET
Getassets — Query underlying cloud infrastructure asset costs
/assets
GET
Getcloudcost — Query cloud provider billing data
/cloudCost
GET
Getcustomcosttimeseries — Custom cost timeseries data
/customCost/timeseries
GET
Getcustomcosttotal — Custom cost totals
/customCost/total

MCP Tools

getallocation

Query Kubernetes workload cost allocations

read-only idempotent
getassets

Query underlying cloud infrastructure asset costs

read-only idempotent
getcloudcost

Query cloud provider billing data

read-only idempotent
getcustomcosttimeseries

Custom cost timeseries data

read-only idempotent
getcustomcosttotal

Custom cost totals

read-only idempotent

Capability Spec

opencost-capability.yaml Raw ↑
naftiko: 1.0.0-alpha2
info:
  label: OpenCost API
  description: The OpenCost API provides real-time and historical reporting of Kubernetes workload costs and underlying cloud
    infrastructure spend. OpenCost is an open source CNCF specification and reference implementation for Kubernetes cost monitoring
    and FinOps.
  tags:
  - Opencost
  - API
  created: '2026-05-06'
  modified: '2026-05-06'
capability:
  consumes:
  - type: http
    namespace: opencost
    baseUri: http://localhost:9003
    description: OpenCost API HTTP API.
    resources:
    - name: allocation
      path: /allocation
      operations:
      - name: getallocation
        method: GET
        description: Query Kubernetes workload cost allocations
        inputParameters:
        - name: window
          in: query
          type: string
          required: true
          description: Duration of time over which to query.
        - name: aggregate
          in: query
          type: string
          description: Field by which to aggregate (namespace, controller, label:app, etc.).
        - name: step
          in: query
          type: string
          description: Duration of a single allocation set.
        - name: accumulate
          in: query
          type: boolean
        - name: resolution
          in: query
          type: string
        - name: includeIdle
          in: query
          type: boolean
        - name: shareIdle
          in: query
          type: boolean
        - name: idleByNode
          in: query
          type: boolean
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
    - name: assets
      path: /assets
      operations:
      - name: getassets
        method: GET
        description: Query underlying cloud infrastructure asset costs
        inputParameters:
        - name: window
          in: query
          type: string
          required: true
        - name: aggregate
          in: query
          type: string
        - name: accumulate
          in: query
          type: boolean
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
    - name: cloudcost
      path: /cloudCost
      operations:
      - name: getcloudcost
        method: GET
        description: Query cloud provider billing data
        inputParameters:
        - name: window
          in: query
          type: string
          required: true
        - name: aggregate
          in: query
          type: string
        - name: accumulate
          in: query
          type: string
        - name: filter
          in: query
          type: string
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
    - name: customcost-timeseries
      path: /customCost/timeseries
      operations:
      - name: getcustomcosttimeseries
        method: GET
        description: Custom cost timeseries data
        inputParameters:
        - name: window
          in: query
          type: string
          required: true
        - name: aggregate
          in: query
          type: string
        - name: accumulate
          in: query
          type: string
        - name: filter
          in: query
          type: string
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
    - name: customcost-total
      path: /customCost/total
      operations:
      - name: getcustomcosttotal
        method: GET
        description: Custom cost totals
        inputParameters:
        - name: window
          in: query
          type: string
          required: true
        - name: aggregate
          in: query
          type: string
        - name: accumulate
          in: query
          type: string
        - name: filter
          in: query
          type: string
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
  exposes:
  - type: rest
    port: 8080
    namespace: opencost-rest
    description: REST adapter for OpenCost API.
    resources:
    - path: /allocation
      name: getallocation
      operations:
      - method: GET
        name: getallocation
        description: Query Kubernetes workload cost allocations
        call: opencost.getallocation
        outputParameters:
        - type: object
          mapping: $.
    - path: /assets
      name: getassets
      operations:
      - method: GET
        name: getassets
        description: Query underlying cloud infrastructure asset costs
        call: opencost.getassets
        outputParameters:
        - type: object
          mapping: $.
    - path: /cloudCost
      name: getcloudcost
      operations:
      - method: GET
        name: getcloudcost
        description: Query cloud provider billing data
        call: opencost.getcloudcost
        outputParameters:
        - type: object
          mapping: $.
    - path: /customCost/timeseries
      name: getcustomcosttimeseries
      operations:
      - method: GET
        name: getcustomcosttimeseries
        description: Custom cost timeseries data
        call: opencost.getcustomcosttimeseries
        outputParameters:
        - type: object
          mapping: $.
    - path: /customCost/total
      name: getcustomcosttotal
      operations:
      - method: GET
        name: getcustomcosttotal
        description: Custom cost totals
        call: opencost.getcustomcosttotal
        outputParameters:
        - type: object
          mapping: $.
  - type: mcp
    port: 9090
    namespace: opencost-mcp
    transport: http
    description: MCP adapter for OpenCost API for AI agent use.
    tools:
    - name: getallocation
      description: Query Kubernetes workload cost allocations
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: opencost.getallocation
      with:
        window: tools.window
        aggregate: tools.aggregate
        step: tools.step
        accumulate: tools.accumulate
        resolution: tools.resolution
        includeIdle: tools.includeIdle
        shareIdle: tools.shareIdle
        idleByNode: tools.idleByNode
      inputParameters:
      - name: window
        type: string
        description: Duration of time over which to query.
        required: true
      - name: aggregate
        type: string
        description: Field by which to aggregate (namespace, controller, label:app, etc.).
      - name: step
        type: string
        description: Duration of a single allocation set.
      - name: accumulate
        type: boolean
        description: accumulate
      - name: resolution
        type: string
        description: resolution
      - name: includeIdle
        type: boolean
        description: includeIdle
      - name: shareIdle
        type: boolean
        description: shareIdle
      - name: idleByNode
        type: boolean
        description: idleByNode
      outputParameters:
      - type: object
        mapping: $.
    - name: getassets
      description: Query underlying cloud infrastructure asset costs
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: opencost.getassets
      with:
        window: tools.window
        aggregate: tools.aggregate
        accumulate: tools.accumulate
      inputParameters:
      - name: window
        type: string
        description: window
        required: true
      - name: aggregate
        type: string
        description: aggregate
      - name: accumulate
        type: boolean
        description: accumulate
      outputParameters:
      - type: object
        mapping: $.
    - name: getcloudcost
      description: Query cloud provider billing data
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: opencost.getcloudcost
      with:
        window: tools.window
        aggregate: tools.aggregate
        accumulate: tools.accumulate
        filter: tools.filter
      inputParameters:
      - name: window
        type: string
        description: window
        required: true
      - name: aggregate
        type: string
        description: aggregate
      - name: accumulate
        type: string
        description: accumulate
      - name: filter
        type: string
        description: filter
      outputParameters:
      - type: object
        mapping: $.
    - name: getcustomcosttimeseries
      description: Custom cost timeseries data
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: opencost.getcustomcosttimeseries
      with:
        window: tools.window
        aggregate: tools.aggregate
        accumulate: tools.accumulate
        filter: tools.filter
      inputParameters:
      - name: window
        type: string
        description: window
        required: true
      - name: aggregate
        type: string
        description: aggregate
      - name: accumulate
        type: string
        description: accumulate
      - name: filter
        type: string
        description: filter
      outputParameters:
      - type: object
        mapping: $.
    - name: getcustomcosttotal
      description: Custom cost totals
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: opencost.getcustomcosttotal
      with:
        window: tools.window
        aggregate: tools.aggregate
        accumulate: tools.accumulate
        filter: tools.filter
      inputParameters:
      - name: window
        type: string
        description: window
        required: true
      - name: aggregate
        type: string
        description: aggregate
      - name: accumulate
        type: string
        description: accumulate
      - name: filter
        type: string
        description: filter
      outputParameters:
      - type: object
        mapping: $.