Skip to main content
Glama
code-alchemist01

MCP Cloud Services Server

get_cost_by_service

Analyze cloud spending by service across AWS, Azure, and GCP for specific date ranges to identify cost drivers and optimize expenses.

Instructions

Get cost breakdown by service

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
providerYesCloud provider
startDateYesStart date (YYYY-MM-DD)
endDateYesEnd date (YYYY-MM-DD)

Implementation Reference

  • Handler logic for 'get_cost_by_service' tool within handleCostAnalysisTool function, dispatching to AWS-specific implementation or returning unimplemented message for other providers.
    case 'get_cost_by_service': { const startDate = params.startDate as string; const endDate = params.endDate as string; if (provider === 'aws') { return await getAWSCostByService(startDate, endDate); } return { message: `Cost by service not yet implemented for ${provider}` }; }
  • Input schema and metadata definition for the 'get_cost_by_service' tool.
    { name: 'get_cost_by_service', description: 'Get cost breakdown by service', inputSchema: { type: 'object', properties: { provider: { type: 'string', enum: ['aws', 'azure', 'gcp'], description: 'Cloud provider', }, startDate: { type: 'string', description: 'Start date (YYYY-MM-DD)', }, endDate: { type: 'string', description: 'End date (YYYY-MM-DD)', }, }, required: ['provider', 'startDate', 'endDate'], }, },
  • src/server.ts:72-73 (registration)
    Top-level registration and dispatch for cost analysis tools, including 'get_cost_by_service', in the MCP server tool call handler.
    } else if (costAnalysisTools.some((t) => t.name === name)) { result = await handleCostAnalysisTool(name, args || {});
  • src/server.ts:19-27 (registration)
    Aggregation of all tools including costAnalysisTools (containing 'get_cost_by_service') into allTools list provided to MCP clients.
    const allTools = [ ...awsTools, ...azureTools, ...gcpTools, ...resourceManagementTools, ...costAnalysisTools, ...monitoringTools, ...securityTools, ];
  • AWS-specific helper function that retrieves cost breakdown by service using analyzeAWSCosts and returns parsed data.
    async function getAWSCostByService(startDate: string, endDate: string): Promise<unknown> { try { const analysis = await analyzeAWSCosts(startDate, endDate, 'monthly'); // Parse the formatted analysis to extract service breakdown return { breakdown: JSON.parse(analysis), message: 'Cost breakdown by service retrieved', }; } catch (error) { throw new Error(`Failed to get cost by service: ${error instanceof Error ? error.message : String(error)}`); } }

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/code-alchemist01/Cloud-mcp_server'

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