~5 min setup

Connect StackSpend to Claude Code (MCP)

Use your cloud and AI cost data in Claude Code. Ask questions in natural language—line items, rollups, and anomalies.

Prerequisites

  • StackSpend account with at least one provider connected
  • Business plan (API access)
  • Claude Code or another MCP-compatible client

Step 1: Create an API key

In StackSpend, go to Dashboard → Settings → API Keys. Create a new key with scopes line_items:read, rollups:read, and anomalies:read.

Store the key securely. It is shown only once.

Step 2: Add MCP server config

Add the StackSpend MCP server to your Claude Code MCP settings. The package is published on npm—no local install needed. Example config (replace sk_xxxx with your API key):

{
  "mcpServers": {
    "stackspend": {
      "command": "npx",
      "args": ["-y", "@stackspend/mcp-server"],
      "env": {
        "STACKSPEND_API_KEY": "sk_xxxx"
      }
    }
  }
}

Download a template: mcp-config.json

View on npm

Step 3: Restart and query

Restart Claude Code so it picks up the MCP server. Then ask questions like:

  • "What were my cloud costs last week?"
  • "Show AWS spend by service for the past 30 days"
  • "Any cost anomalies in the last 7 days?"
  • "Break down OpenAI costs by day for this month"

Available tools

  • get_line_items — Cost line items by date range. Filter by provider, service, or category.
  • get_daily_rollups — Pre-aggregated daily costs grouped by provider, service, or category.
  • get_anomalies — Anomaly alerts for unexpected cost spikes.

Troubleshooting

  • STACKSPEND_API_KEY is required — Set the env var in your MCP config.
  • 401 Unauthorized — API key invalid or revoked. Create a new key.
  • Business plan required — API access is part of the Business plan.

Start tracking costs — connect providers in minutes.

Sign up
Connect StackSpend to Claude Code (MCP) — User Guide