home / mcp / cost management mcp server

Cost Management MCP Server

Provides unified cost tracking and analysis across AWS, OpenAI, and Anthropic through an MCP server.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "knishioka-cost-management-mcp": {
      "command": "node",
      "args": [
        "/absolute/path/to/cost-management-mcp/dist/index.js"
      ],
      "env": {
        "CACHE_TTL": "3600",
        "LOG_LEVEL": "info",
        "AWS_REGION": "us-east-1",
        "OPENAI_API_KEY": "YOUR_OPENAI_API_KEY",
        "ANTHROPIC_API_KEY": "YOUR_ANTHROPIC_API_KEY",
        "AWS_ACCESS_KEY_ID": "YOUR_AWS_ACCESS_KEY",
        "AWS_SECRET_ACCESS_KEY": "YOUR_AWS_SECRET_KEY"
      }
    }
  }
}

Cost Management MCP is a server that unifies cost data from multiple providers and API services, enabling you to query and analyze spend across AWS, OpenAI, and Anthropic from a single interface. It supports flexible time ranges, caching to reduce API calls, and straightforward integration with Claude Desktop and Claude Code.

How to use

You interact with the Cost Management MCP through your MCP client (such as Claude Desktop or Claude Code) after configuring a local or remote MCP server. Start by running the server locally, then connect your MCP client to it to ask questions like “What are my AWS costs for this month?” or “Show me OpenAI usage trends for the last 7 days.” Once connected, you can list configured providers, fetch cost breakdowns by provider or service, and explore cost trends and breakdowns across providers.

To integrate with Claude Desktop, build the project first, then add the MCP server as a runtime option in Claude Desktop’s configuration. The server is started with a Node command and points to the compiled entry at dist/index.js. You can provide credentials via environment variables (for example, AWS keys and API keys for providers) and optionally enable caching for performance.

To integrate with Claude Code, you have two approaches. You can create a project-specific MCP configuration file that lists the server and its environment variables, or configure a global setting in the editor so Claude Code can launch the MCP server when you open your project. In both cases, the MCP server runs as a local process started via Node and the path to the built entry is provided in the configuration.

How to install

Prerequisites: you need Node.js 18 or higher and npm or yarn, plus active accounts with the cloud providers you want to monitor.

1. Clone the project.

git clone https://github.com/knishioka/cost-management-mcp.git
cd cost-management-mcp

2. Install dependencies.

npm install

3. Copy the environment template and adjust credentials.

cp .env.example .env

4. Build the project.

npm run build

5. Start the development server for local testing.

# Development mode (with hot reload)
npm run dev

# Production mode
npm start

Configuration and usage notes

Configure the MCP server in your client to point to the built entry and provide credentials for the providers you use. For Claude Desktop, you specify the absolute path to the built file (dist/index.js) and environment variables such as AWS keys and API keys.

For Claude Code, you can place a project-specific configuration (for example, a .mcp.json file) or configure VS Code settings to load the server. The configuration includes the command to run (node) and the path to the built entry, followed by environment variables like AWS and API keys.

Environment variables and cache

The server supports a range of environment variables to configure credentials and behavior. Common variables include AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, OPENAI_API_KEY, ANTHROPIC_API_KEY, CACHE_TTL, CACHE_TYPE, REDIS_URL, LOG_LEVEL, and MCP_SERVER_PORT.

Caching helps reduce API calls and costs. By default, memory caching is used, but you can switch to Redis caching by setting CACHE_TYPE=redis and providing REDIS_URL. If caching is not configured, the server will function without caching.

From Claude Desktop and Claude Code to live usage

Claude Desktop users configure the MCP server to point to the local Node process running dist/index.js, with credentials supplied via environment variables. After restarting Claude Desktop, you can issue natural language questions about your costs.

Claude Code users add an MCP server entry that launches node with the path to dist/index.js and passes the same kinds of credentials via environment variables. You can also opt for a project-wide JSON file or a VS Code setting to keep the configuration readily available as you work.

Examples of common questions you can ask

What are my AWS costs for this month?

Show me OpenAI costs for the last 30 days

Break down my cloud expenses by service

Which providers are currently configured?

Available tools

cost_get

Get detailed cost breakdowns for any date range, filter by provider, choose granularity, and view service-level breakdowns.

provider_list

Check which providers are configured and validate credentials, with a health check across all integrations.

provider_balance

Check remaining credits or prepaid balances (availability may vary by provider).

openai_costs

Get OpenAI usage, including model breakdowns, token usage, and cost optimization guidance.

anthropic_costs

Get Anthropic usage and costs, model breakdowns, and token-level details with prompt caching.

aws_costs

Analyze AWS costs with service-level breakdowns and optimization tips.

provider_compare

Compare costs across providers with visualizations and insights.

cost_trends

Analyze cost trends over time with configurable granularity and spike detection.

cost_breakdown

Detailed multidimensional cost breakdown by service, region, date, and tags.

cost_periods

Compare costs between different time periods with absolute and percentage changes.