~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 2B: Hosted MCP OAuth (Remote URL clients)

If your MCP client asks for a hosted connector URL, use StackSpend hosted MCP with OAuth:

  • Create an OAuth client in Dashboard → Settings → Developer Access
  • Hosted MCP URL: https://stackspend-api.up.railway.app/api/v1/mcp
  • Authorization metadata: /.well-known/oauth-authorization-server
  • Protected resource metadata: /.well-known/oauth-protected-resource

Download hosted config template: mcp-config-hosted-oauth.json

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.

Know where your cloud and AI spend stands — every day.

Connect providers in minutes. Get 90 days of visibility and start receiving daily cost updates before the invoice lands.

14-day free trial. No credit card required. Plans from $19/month.