Skip to main content
Glama

infracost_upload

Upload cost estimation data to Infracost Cloud for centralized tracking and reporting of infrastructure expenses.

Instructions

Upload Infracost JSON output to Infracost Cloud for centralized cost tracking and reporting. Requires infracost CLI to be installed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to Infracost JSON file to upload

Implementation Reference

  • Core handler function that executes the 'infracost upload --path <file>' CLI command to upload the Infracost JSON output to Infracost Cloud.
    export async function executeUpload(options: UploadOptions): Promise<CommandResult> { try { const args = ['upload', '--path', resolve(options.path)]; const { stdout, stderr } = await execFileAsync('infracost', args, { maxBuffer: 10 * 1024 * 1024, }); return { success: true, output: stdout, error: stderr || undefined, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Unknown error occurred', }; } }
  • InfracostTools.handleUpload method: checks for infracost CLI, calls executeUpload, and formats MCP response.
    async handleUpload(args: z.infer<typeof UploadSchema>) { const isInstalled = await checkInfracostInstalled(); if (!isInstalled) { throw new Error( 'Infracost CLI is not installed. Please install it from https://www.infracost.io/docs/' ); } const result = await executeUpload(args); if (!result.success) { throw new Error(result.error || 'Upload command failed'); } return { content: [ { type: 'text', text: result.output || 'Upload completed successfully', }, ], }; }
  • Zod schema for input validation of infracost_upload tool: requires 'path' to the JSON file.
    export const UploadSchema = z.object({ path: z.string().describe('Path to Infracost JSON file'), });
  • src/index.ts:176-190 (registration)
    Tool registration in ListToolsRequestHandler: defines name, description, and inputSchema for infracost_upload.
    { name: 'infracost_upload', description: 'Upload Infracost JSON output to Infracost Cloud for centralized cost tracking and reporting. Requires infracost CLI to be installed.', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to Infracost JSON file to upload', }, }, required: ['path'], }, },
  • Dispatch handler in CallToolRequestHandler: parses args with UploadSchema and delegates to tools.handleUpload.
    case 'infracost_upload': { const validatedArgs = UploadSchema.parse(args); return await tools.handleUpload(validatedArgs); }

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/phildougherty/infracost_mcp'

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