Skip to main content
Glama
cortezcristian

Kubecost MCP Server

get_cost_allocation

Retrieve detailed cost allocation data from Kubecost to analyze and distribute cloud infrastructure expenses across teams, projects, or resources based on time windows and filtering criteria.

Instructions

Get cost allocation data from Kubecost

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accumulateNo
aggregateNo
filtersNo
windowYes

Implementation Reference

  • src/index.ts:174-197 (registration)
    Registers the MCP tool 'get_cost_allocation' including input schema, description, and the handler function that invokes the Kubecost client.
    this.tool( 'get_cost_allocation', 'Get cost allocation data from Kubecost', { window: z.string(), aggregate: z.string().optional(), accumulate: z.boolean().optional(), filters: z.record(z.string()).optional(), }, async (params) => { try { const result = await this.kubecostClient.getCostAllocation(params); return { isError: false, content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { isError: true, content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }] }; } } );
  • The handler function for the 'get_cost_allocation' tool that calls the Kubecost client and formats the response.
    async (params) => { try { const result = await this.kubecostClient.getCostAllocation(params); return { isError: false, content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { isError: true, content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }] }; } }
  • Input schema for the 'get_cost_allocation' tool defined using Zod for validation.
    { window: z.string(), aggregate: z.string().optional(), accumulate: z.boolean().optional(), filters: z.record(z.string()).optional(), },
  • Core helper method in KubecostClient that performs the actual API call to retrieve cost allocation data from the Kubecost server.
    async getCostAllocation(params: { window: string; aggregate?: string; accumulate?: boolean; filters?: Record<string, string>; }): Promise<CostAllocationResponse> { const response = await this.client.get('/model/allocation', { params }); return response.data; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cortezcristian/kubecost-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server