Anthropic Billing MCP Server

Anthropic Billing MCP Server

Enables retrieval of Anthropic billing and cost report data, with time-based filtering, grouping, and daily cost summaries.

Category
Visit Server

README

Anthropic Billing MCP Server

An MCP (Model Context Protocol) server for retrieving Anthropic billing and cost report data.

Features

  • Retrieve detailed cost reports from Anthropic's billing API
  • Support for time-based filtering and grouping
  • Daily cost summaries with USD conversion
  • Support for beta API features
  • Pagination support for large datasets
  • Type-safe with Zod validation

Installation

Option 1: Using claude mcp add (Recommended)

# Add the MCP server from GitHub
claude mcp add anthropic-billing https://github.com/your-username/anthropic-billing-mcp

# Set your API key
claude mcp env anthropic-billing ANTHROPIC_API_KEY=your_api_key_here

Option 2: Manual Installation

git clone https://github.com/your-username/anthropic-billing-mcp
cd anthropic-billing-mcp
npm install
npm run build

Setup

  1. Get your Anthropic Admin API key from https://platform.claude.com/settings/admin-keys
    • Note: Regular API keys from console.anthropic.com will not work for billing endpoints
    • You need an Admin API key with billing access permissions
  2. If using claude mcp add, set the environment variable:
    claude mcp env anthropic-billing ANTHROPIC_API_KEY=your_api_key_here
    
  3. If installing manually, set the environment variable:
    export ANTHROPIC_API_KEY=your_api_key_here
    

Usage

With claude mcp add

After installation, the server will be automatically configured and available in Claude Desktop.

Manual Configuration

Add to your MCP configuration (e.g., in Claude Desktop config):

{
  "mcpServers": {
    "anthropic-billing": {
      "command": "node",
      "args": ["/path/to/anthropic-billing-mcp/dist/index.js"],
      "env": {
        "ANTHROPIC_API_KEY": "your_api_key_here"
      }
    }
  }
}

Available Tools

get_cost_report

Retrieve raw cost report data from Anthropic's API.

Parameters:

  • starting_at (required): RFC 3339 timestamp for start of time range
  • ending_at (optional): RFC 3339 timestamp for end of time range
  • bucket_width (optional): Time granularity ("1d" only)
  • group_by (optional): Array of grouping options ["workspace_id", "description"]
  • limit (optional): Maximum number of time buckets to return
  • page (optional): Page token for pagination
  • beta_headers (optional): Array of beta feature headers

Example:

{
  "starting_at": "2024-01-01T00:00:00Z",
  "ending_at": "2024-01-31T23:59:59Z",
  "group_by": ["description"],
  "beta_headers": ["fast-mode-2026-02-01"]
}

get_daily_costs_summary

Get a formatted summary of daily costs with USD conversion.

Parameters:

  • start_date (required): Start date in YYYY-MM-DD format
  • end_date (optional): End date in YYYY-MM-DD format (defaults to today)
  • group_by_workspace (optional): Whether to group by workspace (default: false)
  • group_by_description (optional): Whether to group by description (default: false)
  • beta_headers (optional): Array of beta feature headers

Example:

{
  "start_date": "2024-01-01",
  "end_date": "2024-01-31",
  "group_by_description": true
}

Demo: Real-World Usage for Budget Management

This MCP server enables powerful budget management and cost analysis workflows. Here's a real-world example of using it to create a comprehensive burn down analysis.

Scenario: Trading Profit vs API Costs

A trader made $1,000 profit in March 2026 and wanted to track their Anthropic API costs against this budget to ensure profitable AI-assisted trading decisions.

Live Cost Analysis (March 7, 2026)

Using the MCP server's get_cost_report tool, we retrieved actual spending data:

๐Ÿ“Š Executive Summary
- Trading Profit This Month: $1,000.00
- Current API Costs: $91.05
- Remaining Budget: $908.95
- Days Elapsed: 7 of 31 (22.6%)
- Budget Utilization: 9.1%

๐Ÿ“ˆ Key Performance Metrics
- Daily Average Cost: $13.01 ($91.05 รท 7 days)
- Projected Monthly Cost: $403.31 (at current rate)
- Target Daily Budget: $32.26 (1000 รท 31 days)
- API ROI: 1,098% ($1000 profit vs $91.05 cost)

Budget Burn Rate Visualization

Week 1  [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–“โ–“โ–“โ–“โ–“] $91.05 (28% of weekly target)
Week 2  [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ] $91.05 (projected)
Week 3  [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ] $91.05 (projected)
Week 4  [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ] $91.05 (projected)
Week 5  [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“] $39.11 (projected)

Risk Assessment & Strategic Insights

๐ŸŸข Current Status: LOW-MODERATE Risk

  • Tracking 59% below daily budget target
  • Cost efficiency: 9.1ยข per dollar of trading profit
  • Room to scale usage 2.5x while staying in budget
  • Outstanding ROI demonstrates profitable AI integration

MCP Integration Benefits

1. Real-Time Budget Monitoring

# Get current month costs instantly
get_daily_costs_summary start_date=2026-03-01

2. Automated Burn Rate Calculations

The MCP server enables programmatic cost analysis without manual API calls:

  • Daily average spending calculations
  • Projected monthly costs based on current usage
  • Budget variance tracking
  • ROI analysis against business metrics

3. Multi-Scenario Planning

# Scenario 1: Current pace โ†’ $403.31 monthly (40.3% of budget)
# Scenario 2: 25% increase โ†’ $504.14 monthly (50.4% of budget)
# Scenario 3: 50% increase โ†’ $604.97 monthly (60.5% of budget)

4. Integration with Business Logic

The MCP server allows seamless integration with:

  • Trading algorithms that factor in API costs
  • Automated budget alerts and thresholds
  • Cost-per-decision optimization
  • Dynamic usage scaling based on profitability

Sample Budget Management Workflow

# Pseudo-code showing typical workflow
def optimize_trading_strategy():
    # Get real-time costs via MCP
    current_costs = get_daily_costs_summary()
    daily_avg = current_costs.total / days_elapsed

    # Calculate remaining budget runway
    remaining_budget = trading_profit - current_costs.total
    safe_daily_spend = remaining_budget / days_remaining

    # Adjust API usage based on cost efficiency
    if daily_avg < safe_daily_spend * 0.8:
        return "SCALE_UP"  # Opportunity to use more AI
    elif daily_avg > safe_daily_spend * 1.2:
        return "SCALE_DOWN"  # Risk of budget overrun
    else:
        return "MAINTAIN"  # Optimal pace

This real-world example demonstrates how the MCP server transforms basic billing data into actionable business intelligence, enabling data-driven decisions about AI investment and usage optimization.

๐Ÿ“‹ Full Analysis Available: See examples/trading-budget-burndown.md for the complete burn down analysis with weekly projections, risk assessments, and KPI tracking.

API Response Structure

Cost Items

Each cost item includes:

  • amount: Cost in cents as decimal string
  • currency: Currency code (always "USD")
  • description: Description of the cost item
  • model: Model name used
  • cost_type: Type of cost ("tokens", "web_search", "code_execution")
  • token_type: Token type for token costs
  • service_tier: Service tier ("standard", "batch")
  • context_window: Input context window used
  • workspace_id: Associated workspace ID
  • inference_geo: Inference geography used
  • speed: Speed tier (with beta header)

Daily Summary Format

{
  "summary": [
    {
      "date": "2024-01-01",
      "total_cost_cents": 1234,
      "total_cost_usd": "12.34",
      "items": [...]
    }
  ],
  "total_cost_cents": 50000,
  "total_cost_usd": "500.00",
  "period": {
    "start": "2024-01-01",
    "end": "2024-01-31"
  },
  "has_more": false,
  "next_page": null
}

Development

Build

npm run build

Run in Development

npm run dev

Test

npm test

Environment Variables

Error Handling

The server includes comprehensive error handling for:

  • Missing API keys
  • Invalid API responses
  • Network errors
  • Validation errors
  • API rate limits

All errors are returned with descriptive messages to help with debugging.

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured