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
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to Infracost JSON file to upload |
Implementation Reference
- src/cli.ts:157-176 (handler)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', }; } }
- src/tools.ts:358-380 (handler)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', }, ], }; }
- src/tools.ts:48-50 (schema)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'], }, },
- src/index.ts:719-722 (handler)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); }