billing_get_org_usage
Retrieve usage details for a Cloud Foundry organization by specifying the organization ID and month.
Instructions
Get usage for a Cloud Foundry organization
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | No | ||
| org_id | Yes | ||
| month | Yes |
Implementation Reference
- src/tools/billing/index.ts:31-36 (registration)Registration of the 'billing_get_org_usage' tool via server.tool(). Defines the handler inline with the schema for account_id, org_id, and month parameters. Constructs the API URL using the BILLING base endpoint.
server.tool("billing_get_org_usage", "Get usage for a Cloud Foundry organization", { account_id: z.string().optional(), org_id: z.string(), month: z.string(), }, async (p) => safeTool(async () => { const acctId = p.account_id || await client.getAuth().getAccountId(); return client.get(`${base}/accounts/${acctId}/organizations/${p.org_id}/usage/${p.month}`); })); - src/tools/billing/index.ts:33-36 (handler)The handler function for billing_get_org_usage. Resolves the account ID (from optional param or auth manager), then calls client.get() on the billing API path: /accounts/{acctId}/organizations/{org_id}/usage/{month}. Calls safeTool to wrap the async operation with error handling.
}, async (p) => safeTool(async () => { const acctId = p.account_id || await client.getAuth().getAccountId(); return client.get(`${base}/accounts/${acctId}/organizations/${p.org_id}/usage/${p.month}`); })); - src/tools/billing/index.ts:32-32 (schema)Input schema for billing_get_org_usage defining three parameters: account_id (optional string), org_id (required string), and month (required string, format YYYY-MM).
account_id: z.string().optional(), org_id: z.string(), month: z.string(), - src/lib/utils.ts:70-71 (helper)The safeTool utility wraps async handler functions to catch errors and return proper MCP success/error content blocks.
export async function safeTool<T>(fn: () => Promise<T>): Promise<ReturnType<typeof successContent> | ReturnType<typeof errorContent>> { try { - src/config.ts:71-71 (helper)The BILLING endpoint constant: 'https://billing.cloud.ibm.com/v4' which is used as the base URL for the billing_get_org_usage API call.
BILLING: "https://billing.cloud.ibm.com/v4",