infracost_upload
Upload cost estimation data from Infracost CLI 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/tools.ts:358-380 (handler)Main handler for infracost_upload tool: checks CLI installation, executes upload via helper, returns 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/cli.ts:157-176 (helper)Executes the core logic: runs `infracost upload --path <path>` CLI command and captures output/error.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:48-50 (schema)Zod schema defining input: path to Infracost JSON file.export const UploadSchema = z.object({ path: z.string().describe('Path to Infracost JSON file'), });
- src/index.ts:719-722 (registration)Dispatch in CallToolRequest handler: parses args and calls tools.handleUpload.case 'infracost_upload': { const validatedArgs = UploadSchema.parse(args); return await tools.handleUpload(validatedArgs); }
- src/index.ts:176-190 (registration)Tool specification returned by ListTools: name, description, input schema.{ 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'], }, },