{
  "markdown": "# Infracost MCP Server\n\n![Down At The Bottom Of The Mole Hole banner](.assets/org-banner.png)\n\n<!-- mcp-name: io.github.downatthebottomofthemolehole/infracost -->\n\n[![CI/Publish](https://github.com/DownAtTheBottomOfTheMoleHole/infracost-mcp/actions/workflows/publish-mcp.yml/badge.svg)](https://github.com/DownAtTheBottomOfTheMoleHole/infracost-mcp/actions/workflows/publish-mcp.yml)\n[![Coverage](https://codecov.io/github/DownAtTheBottomOfTheMoleHole/infracost-mcp/graph/badge.svg?branch=main)](https://codecov.io/github/DownAtTheBottomOfTheMoleHole/infracost-mcp)\n[![npm](https://img.shields.io/npm/v/@downatthebottomofthemolehole/infracost-mcp-server.svg)](https://www.npmjs.com/package/@downatthebottomofthemolehole/infracost-mcp-server)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)\n[![Node Version](https://img.shields.io/badge/node-%3E%3D24.14.0-brightgreen)](https://nodejs.org/)\n\n> **Note:** This is a community-maintained MCP server. It is not an official Model Context Protocol server from Infracost.\n\nA Model Context Protocol (MCP) server for running the [Infracost CLI](https://www.infracost.io/) to estimate, compare, and publish infrastructure cost changes from Terraform and other Infrastructure as Code projects.\n\n## Overview\n\nThis server provides eight MCP tools across estimation, reporting, collaboration, and operations workflows:\n\n- `infracost_breakdown` to generate baseline cost estimates.\n- `infracost_diff` to compare planned cost changes.\n- `infracost_output` to render existing Infracost JSON in different formats.\n- `infracost_comment` to post PR comments on supported SCM platforms.\n- `infracost_upload` to upload reports to Infracost Cloud.\n- `infracost_configure` to get or set CLI configuration.\n- `infracost_auth` to run authentication flow.\n- `infracost_generate_usage` to generate usage files with sensible defaults.\n\n### Platform Compatibility\n\nThis MCP server is platform-agnostic and works in local and CI environments:\n\n- Local development\n- GitHub Actions\n- GitLab CI/CD\n- Azure DevOps\n- CircleCI, Jenkins, and Bitbucket Pipelines\n- AI Agents and Copilot workflows\n\nThe primary requirements are Node.js and the Infracost CLI binary.\n\n### Tool Matrix\n\n| Tool | Category | Typical outcome |\n| --- | --- | --- |\n| `infracost_breakdown` | Estimation | Monthly cost baseline for current IaC |\n| `infracost_diff` | Comparison | Cost delta from a planned change |\n| `infracost_output` | Reporting | Rendered table/JSON/HTML/comment output |\n| `infracost_comment` | Collaboration | PR comment with estimated impact |\n| `infracost_upload` | Cloud Sync | Cost report visible in Infracost Cloud |\n| `infracost_configure` | Configuration | Persisted CLI config update/read |\n| `infracost_auth` | Authentication | Login flow for Infracost Cloud |\n| `infracost_generate_usage` | Utilities | Pre-filled usage file template with defaults |\n\n## Tools\n\n### `infracost_breakdown`\n\nRuns `infracost breakdown`.\n\nInputs:\n\n- `workingDirectory` (string, optional): Command working directory.\n- `path` (string, optional): Path to Terraform/IaC directory or plan JSON.\n- `configFile` (string, optional): Path to Infracost config file.\n- `usageFile` (string, optional): Path to usage file.\n- `format` (string, optional): Output format. Default: `table`.\n- `fields` (string[], optional): Fields to include in output.\n- `showSkus` (boolean, optional): Include SKU details.\n- `syncUsageFile` (boolean, optional): Sync usage file with detected resources.\n- `compareTo` (string, optional): Baseline Infracost JSON path.\n- `terraformWorkspace` (string, optional): Terraform workspace.\n- `terraformPlanFlags` (string, optional): Flags for `terraform plan`.\n- `timeoutSeconds` (number, optional): Timeout in seconds.\n- `extraArgs` (string[], optional): Additional CLI arguments.\n\n### `infracost_diff`\n\nRuns `infracost diff`.\n\nInputs:\n\n- `workingDirectory` (string, optional): Command working directory.\n- `path` (string, optional): Path to Terraform/IaC directory or plan JSON.\n- `configFile` (string, optional): Path to Infracost config file.\n- `usageFile` (string, optional): Path to usage file.\n- `format` (string, optional): Output format. Default: `table`.\n- `compareTo` (string, optional): Baseline Infracost JSON path.\n- `showSkus` (boolean, optional): Include SKU details.\n- `syncUsageFile` (boolean, optional): Sync usage file with detected resources.\n- `terraformWorkspace` (string, optional): Terraform workspace.\n- `terraformPlanFlags` (string, optional): Flags for `terraform plan`.\n- `timeoutSeconds` (number, optional): Timeout in seconds.\n- `extraArgs` (string[], optional): Additional CLI arguments.\n\n### `infracost_output`\n\nRuns `infracost output`.\n\nInputs:\n\n- `workingDirectory` (string, optional): Command working directory.\n- `path` (string, optional): Infracost JSON file path. Auto-detected when omitted.\n- `format` (string, optional): Output format. Default: `table`.\n- `fields` (string[], optional): Fields to include in output.\n- `showSkus` (boolean, optional): Include SKU details.\n- `timeoutSeconds` (number, optional): Timeout in seconds.\n- `extraArgs` (string[], optional): Additional CLI arguments.\n\n### `infracost_comment`\n\nRuns `infracost comment`.\n\nInputs:\n\n- `workingDirectory` (string, optional): Command working directory.\n- `platform` (string, optional): Platform (`github`, `gitlab`, `azure-repos`, `bitbucket`). Default: `github`.\n- `path` (string, optional): Infracost JSON file path. Auto-detected when omitted.\n- `repo` (string, optional): Repository (`owner/repo`).\n- `pullRequest` (string, optional): Pull request number.\n- `commit` (string, optional): Commit SHA.\n- `token` (string, optional): Platform token.\n- `tag` (string, optional): Comment tag.\n- `behavior` (string, optional): Comment update behavior.\n- `dryRun` (boolean, optional): Generate without posting.\n- `timeoutSeconds` (number, optional): Timeout in seconds.\n- `extraArgs` (string[], optional): Additional CLI arguments.\n\n### `infracost_upload`\n\nRuns `infracost upload`.\n\nInputs:\n\n- `workingDirectory` (string, optional): Command working directory.\n- `path` (string, optional): Infracost JSON file path. Auto-detected when omitted.\n- `timeoutSeconds` (number, optional): Timeout in seconds.\n- `extraArgs` (string[], optional): Additional CLI arguments.\n\n### `infracost_configure`\n\nRuns `infracost configure`.\n\nInputs:\n\n- `workingDirectory` (string, optional): Command working directory.\n- `set` (string, optional): Set configuration value.\n- `get` (string, optional): Read configuration value.\n- `timeoutSeconds` (number, optional): Timeout in seconds.\n- `extraArgs` (string[], optional): Additional CLI arguments.\n\n### `infracost_auth`\n\nRuns `infracost auth login`.\n\nInputs:\n\n- `workingDirectory` (string, optional): Command working directory.\n- `timeoutSeconds` (number, optional): Timeout in seconds.\n- `extraArgs` (string[], optional): Additional CLI arguments.\n\n### `infracost_generate_usage`\n\nGenerates an Infracost usage file with sensible defaults for specified resource types. This is a utility tool that complements `infracost_configure` by providing pre-filled templates you can customize for your workloads. Returns both raw JSON and formatted guidance.\n\nInputs:\n\n- `resourceTypes` (string[], required): Resource types to include (e.g., `[\"aws_lambda_function\", \"aws_s3_bucket\"]`).\n- `outputFilePath` (string, optional): Path where usage file should be saved (for guidance only).\n- `includeGuidance` (boolean, optional): Include formatted guidance. Default: `true`.\n- `onlyJson` (boolean, optional): Return only raw JSON (no guidance). Default: `false`.\n\nSupported resource types: `aws_lambda_function`, `aws_instance`, `aws_db_instance`, `aws_s3_bucket`, `aws_dynamodb_table`, `aws_ebs_volume`, `aws_cloudfront_distribution`, `aws_lb`, `aws_nat_gateway`, `google_compute_instance`, `google_storage_bucket`, `azurerm_windows_virtual_machine`, `azurerm_linux_virtual_machine`, `azurerm_storage_account`, `azurerm_mssql_database`.\n\n## Prompt Cookbook\n\nUse these minimal prompts in Copilot Chat with `@infracost`.\nCLI tools default to the current workspace root when no path is given.\nIf you add a file or folder as Copilot context (`#file` or `#folder`), reference it in your prompt and the tool will target that path.\nThe server auto-detects common report files (`infracost-diff.json`, `infracost-base.json`, `infracost.json`), so you usually do not need to pass `path` for `infracost_output`, `infracost_comment`, or `infracost_upload`.\n\n### Quick prompts\n\n```text\n@infracost run infracost_breakdown\n@infracost run infracost_diff\n@infracost run infracost_output\n@infracost run infracost_comment with dryRun true\n@infracost run infracost_upload\n```\n\n### Run breakdown (`infracost_breakdown`)\n\n```text\n@infracost run infracost_breakdown\n```\n\nExpected output: Baseline cost estimate with command output, exit code, stdout, and stderr.\n\n### Run diff (`infracost_diff`)\n\n```text\n@infracost run infracost_diff\n```\n\nExpected output: Cost delta from the planned change compared to current baseline.\n\n### Render output (`infracost_output`)\n\n```text\n@infracost run infracost_output with format html\n```\n\nExpected output: Formatted output from existing Infracost JSON (auto-detected when possible).\n\n### Post PR comment (`infracost_comment`)\n\n```text\n@infracost run infracost_comment with repo owner/repo and pullRequest 123 and dryRun true\n```\n\nExpected output: Generated comment payload, or posted comment when not in dry-run mode. Platform defaults to `github`.\n\n### Upload report (`infracost_upload`)\n\n```text\n@infracost run infracost_upload\n```\n\nExpected output: Upload confirmation for Infracost Cloud ingestion.\n\n### Configure CLI (`infracost_configure`)\n\n```text\n@infracost run infracost_configure with:\n- set: currency=USD\n```\n\nExpected output: Configuration update confirmation from the CLI.\n\n### Authenticate (`infracost_auth`)\n\n```text\n@infracost run infracost_auth\n```\n\nExpected output: Authentication flow prompt or login success details.\n\n### Generate usage file (`infracost_generate_usage`)\n\n```text\n@infracost run infracost_generate_usage with:\n- resourceTypes: [\"aws_lambda_function\", \"aws_s3_bucket\", \"aws_dynamodb_table\"]\n- outputFilePath: ./infracost-usage.json\n- includeGuidance: true\n```\n\nExpected output: Pre-filled usage file JSON with sensible defaults, plus guidance on customization and usage. Use `onlyJson: true` to return only the JSON for programmatic handling.\n\n## Dependencies\n\n### System Dependencies\n\n- Node.js `>=24.14.0`\n- npm (bundled with Node.js)\n- Infracost CLI installed and available in `PATH` (or via `INFRACOST_BINARY_PATH`)\n\n### npm Dependencies\n\nRuntime:\n\n- `@modelcontextprotocol/sdk` (MCP server SDK)\n\nDevelopment:\n\n- `typescript` (build/compile)\n- `tsx` (development runner)\n- `vitest` (unit test runner)\n- `@types/node` (Node.js typings)\n\n### Environment Variables\n\n- `INFRACOST_API_KEY`: Infracost API key for cloud-backed features.\n- `INFRACOST_BINARY_PATH`: Override path to Infracost binary.\n\n## Installation\n\n```bash\nnpm install\nnpm run build\n```\n\n## Configuration\n\n### Usage with VS Code Copilot Chat\n\nThis workspace is preconfigured in `.vscode/mcp.json`:\n\n```json\n{\n  \"servers\": {\n    \"infracost\": {\n      \"type\": \"stdio\",\n      \"command\": \"node\",\n      \"args\": [\"./dist/index.js\"]\n    }\n  }\n}\n```\n\nReload VS Code (`Cmd+Shift+P` -> `Developer: Reload Window`) after changing MCP configuration.\n\nThen query the server from Copilot Chat with `@infracost`, for example:\n\n```text\n@infracost run infracost_breakdown\n@infracost run infracost_diff\n```\n\n### Usage with Other MCP Clients\n\nUse stdio transport with the built entrypoint:\n\n```json\n{\n  \"name\": \"infracost-mcp-server\",\n  \"type\": \"stdio\",\n  \"command\": \"node\",\n  \"args\": [\"/absolute/path/to/infracost-mcp/dist/index.js\"]\n}\n```\n\nBuild first with `npm run build`, then start your MCP client.\n\n## Running\n\n```bash\nnpm start\n```\n\nDevelopment mode:\n\n```bash\nnpm run dev\n```\n\nBuilt mode:\n\n```bash\nnpm run start\n```\n\n## Debugging\n\nUse `.vscode/launch.json`:\n\n- `Debug MCP Server` (runs `npm run dev`)\n- `Debug MCP Server (Built)` (runs `dist/index.js` after build)\n\nSet breakpoints in `src/index.ts`, then press `F5`.\n\n## Testing\n\nSee [docs/TESTING.md](./docs/TESTING.md) for Copilot Chat scenarios, manual JSON-RPC checks, and troubleshooting guidance.\n\nQuick validation prompt in Copilot Chat:\n\n```text\n@infracost run infracost_breakdown\n```\n\n## Interactive VS Code Workflows\n\n### 1. PR Cost Impact Review\n\n1. Generate a baseline:\n\n```text\n@infracost run infracost_breakdown with:\n- path: .\n- format: json\n```\n\n1. Generate a diff:\n\n```text\n@infracost run infracost_diff with:\n- path: .\n- format: diff\n```\n\n1. Draft a PR comment:\n\n```text\n@infracost run infracost_comment with:\n- platform: github\n- path: infracost-diff.json\n- repo: owner/repo\n- pullRequest: 123\n- dryRun: true\n```\n\n### 2. Reporting Pipeline Setup\n\n1. Render a report for humans:\n\n```text\n@infracost run infracost_output with:\n- path: infracost-diff.json\n- format: html\n```\n\n1. Upload for centralized tracking:\n\n```text\n@infracost run infracost_upload with:\n- path: infracost-diff.json\n```\n\n### 3. Environment Bootstrap\n\n1. Configure defaults:\n\n```text\n@infracost run infracost_configure with:\n- set: currency=USD\n```\n\n1. Authenticate:\n\n```text\n@infracost run infracost_auth\n```\n\n### Best Practices\n\n- Keep `workingDirectory` explicit when running inside monorepos.\n- Use `--format json` for machine processing and `--format table` for human triage.\n- Keep `timeoutSeconds` high enough for large Terraform plans.\n- Prefer `infracost_comment` with `dryRun=true` before posting to production PR threads.\n- Use `infracost_upload` for historical visibility in Infracost Cloud.\n\n## Additional Use Cases\n\n- Pre-merge cost gates in pull requests.\n- Scheduled baseline cost snapshots in CI.\n- Cost delta reporting for release trains.\n- Team-level FinOps dashboards based on uploaded reports.\n\n## Related Projects\n\n### Infracost Resources\n\n- [Infracost website](https://www.infracost.io/)\n- [Infracost documentation](https://www.infracost.io/docs/)\n- [Infracost CLI repository](https://github.com/infracost/infracost)\n\n### Model Context Protocol\n\n- [MCP official documentation](https://modelcontextprotocol.io/)\n- [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)\n- [MCP servers registry](https://github.com/mcp)\n\n## Community and Contributing\n\n- [Contributing Guide](./CONTRIBUTING.md)\n- [Code of Conduct](./CODE_OF_CONDUCT.md)\n- [Security Policy](./SECURITY.md)\n- [Testing Guide](./docs/TESTING.md)\n- [Maintainer Guide](./docs/MAINTAINERS.md)\n\n## Attribution and License\n\nMaintained by Carl Dawson under the [Down At The Bottom Of The Mole Hole](https://github.com/downatthebottomofthemolehole) organization.\n\n## Development\n\n```bash\nnpm run lint\nnpm test\nnpm run build\n```\n\n## License\n\nLicensed under the MIT License.\n",
  "bytes": 14867,
  "sha": "33ae661acc141c047e1d9353438b66d6dd075790d8d885825a3d4fe0a54d16f5",
  "repo_slug": "downatthebottomofthemolehole/infracost-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_downatthebottomofthemolehole_i_9ff7dfa2/readme"
}