Skip to main content
Glama
knishioka

Cost Management MCP

by knishioka

Cost Management MCP

CI Security Scan Release License: MIT Node.js Version TypeScript codecov

A Model Context Protocol (MCP) server for unified cost management across cloud providers and API services.

English | ๆ—ฅๆœฌ่ชž

๐Ÿš€ Quick Examples

Once integrated with Claude Desktop, you can ask:

๐Ÿ“Š "What are my AWS costs for December 2024?"
๐Ÿ“ˆ "Show me OpenAI API usage trends for the last 30 days"
๐Ÿค– "What are my Anthropic API costs this month?"
๐Ÿ” "Break down my cloud expenses by service"
๐Ÿ“‹ "Which providers are currently configured?"
๐Ÿ’ฐ "How much have I spent across all services this month?"

Features

  • ๐Ÿ” Unified cost tracking across AWS, OpenAI, and Anthropic

  • ๐Ÿ’พ Intelligent caching to minimize API costs

  • ๐Ÿ“Š Flexible date ranges and granularity options

  • ๐Ÿ” Secure credential management via environment variables

  • ๐Ÿš€ Easy integration with Claude Desktop and other MCP clients

  • โšก Written in TypeScript with full type safety

  • ๐Ÿงช Comprehensive test coverage

  • ๐Ÿ”„ Automatic retry logic with exponential backoff

  • ๐Ÿ›ก๏ธ Security scanning with CodeQL and Trufflehog

  • ๐Ÿ“ฆ Automated dependency updates with Dependabot

๐Ÿ› ๏ธ MCP Tools

This server provides three powerful tools for cost management:

๐Ÿ“Š cost_get

Get detailed cost breakdowns

  • Check costs for any date range

  • Filter by specific provider (AWS, OpenAI, Anthropic)

  • View daily, monthly, or total costs

  • See service-level breakdowns

Example questions in Claude:

  • "What are my AWS costs for this month?"

  • "Show me daily OpenAI usage for the last week"

  • "Break down my cloud costs by service"

๐Ÿ“‹ provider_list

Check provider status

  • See which providers are configured

  • Verify API credentials are valid

  • Quick health check for all integrations

Example usage:

  • "List all my cloud providers"

  • "Which cost tracking services are active?"

๐Ÿ’ฐ provider_balance

Check remaining credits (Coming soon)

  • View prepaid balances

  • Monitor API credit usage

  • Get alerts before credits expire

๐Ÿ“Š openai_costs

Get detailed OpenAI usage

  • Model-by-model breakdown (GPT-4, GPT-3.5, etc.)

  • Token usage statistics

  • Cost optimization recommendations

Example usage:

  • "Show my OpenAI costs grouped by model"

  • "How many tokens did I use with GPT-4 this week?"

๐Ÿค– anthropic_costs

Get detailed Anthropic usage

  • Model-by-model breakdown (Claude 3.5 Sonnet, Haiku, etc.)

  • Token usage statistics with prompt caching details

  • Cost optimization recommendations

  • Support for both cost report and usage report APIs

Example usage:

  • "Show my Anthropic costs grouped by model"

  • "How much did I spend on Claude 3.5 Sonnet this month?"

  • "What are my Anthropic costs with token-level details?"

โ˜๏ธ aws_costs

AWS cost analysis with insights

  • Service-level breakdown (EC2, S3, RDS, etc.)

  • Filter by specific AWS service

  • Automatic cost optimization tips

  • High spend warnings

Example usage:

  • "What are my EC2 costs this month?"

  • "Show AWS costs grouped by service"

  • "Give me AWS cost optimization tips"

๐Ÿ“ˆ provider_compare

Compare costs across providers

  • Side-by-side cost comparison

  • ASCII chart visualization

  • Vendor lock-in warnings

  • Cost distribution insights

Example usage:

  • "Compare my costs across all cloud providers"

  • "Show me a chart of provider costs"

  • "Which provider is most expensive?"

๐Ÿ“Š cost_trends

Analyze cost trends over time

  • Historical cost analysis (30d, 60d, 90d, 6m, 1y)

  • Trend detection (increasing/decreasing/stable)

  • Volatility analysis

  • Spike detection

  • Daily/weekly/monthly granularity

Example usage:

  • "Show me cost trends for the last 30 days"

  • "Are my AWS costs increasing?"

  • "Detect any cost spikes in the past month"

๐Ÿ” cost_breakdown

Detailed cost breakdown analysis

  • Multi-dimensional breakdown (service, region, date, tag)

  • Top N cost drivers

  • Percentage-based filtering

  • Hierarchical drill-down

  • Cost concentration analysis

Example usage:

  • "Break down my costs by service"

  • "Show top 5 cost drivers"

  • "What services make up 80% of my costs?"

๐Ÿ“… cost_periods

Compare costs between time periods

  • Period-over-period comparison

  • Absolute and percentage changes

  • Service-level change tracking

  • Daily average comparison

  • New/discontinued service detection

Example usage:

  • "Compare this month vs last month"

  • "How much did costs increase since Q1?"

  • "Which services grew the most?"

Table of Contents

Installation

Prerequisites

  • Node.js 18 or higher

  • npm or yarn

  • Active accounts with the cloud providers you want to monitor

Steps

  1. Clone the repository:

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

npm install
  1. Copy the environment template:

cp .env.example .env
  1. Edit .env and add your credentials (see Provider Setup)

  2. Build the project:

npm run build

Quick Start

Running Standalone

# Development mode (with hot reload)
npm run dev

# Production mode
npm start

Integration with Claude Desktop

  1. Build the project first:

npm run build
  1. Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "cost-management": {
      "command": "node",
      "args": ["/absolute/path/to/cost-management-mcp/dist/index.js"],
      "env": {
        "AWS_ACCESS_KEY_ID": "your-key",
        "AWS_SECRET_ACCESS_KEY": "your-secret",
        "AWS_REGION": "us-east-1",
        "OPENAI_API_KEY": "your-key",
        "CACHE_TTL": "3600",
        "LOG_LEVEL": "info"
      }
    }
  }
}
  1. Restart Claude Desktop

  2. Use the tools in your conversation:

Can you check my AWS costs for this month?
What are my OpenAI API costs for the last 7 days?
List all my configured cloud providers.

Integration with Claude Code

Claude Code supports MCP servers through two configuration methods:

Create a .mcp.json file in your project root:

{
  "mcpServers": {
    "cost-management": {
      "command": "node",
      "args": ["/absolute/path/to/cost-management-mcp/dist/index.js"],
      "env": {
        "AWS_ACCESS_KEY_ID": "your-aws-access-key",
        "AWS_SECRET_ACCESS_KEY": "your-aws-secret-key",
        "AWS_REGION": "us-east-1",
        "OPENAI_API_KEY": "sk-...your-openai-key",
        "ANTHROPIC_API_KEY": "sk-ant-admin-...your-admin-key",
        "CACHE_TTL": "3600",
        "LOG_LEVEL": "info"
      }
    }
  }
}

This configuration will be automatically loaded when you open the project in Claude Code.

Method 2: VS Code settings (Global configuration)

  1. Open VS Code Settings (Cmd/Ctrl + ,)

  2. Search for "Claude Code MCP Servers"

  3. Click "Edit in settings.json"

  4. Add the cost management server configuration:

{
  "claudeCode.mcpServers": {
    "cost-management": {
      "command": "node",
      "args": ["/absolute/path/to/cost-management-mcp/dist/index.js"],
      "env": {
        "AWS_ACCESS_KEY_ID": "your-aws-access-key",
        "AWS_SECRET_ACCESS_KEY": "your-aws-secret-key",
        "AWS_REGION": "us-east-1",
        "OPENAI_API_KEY": "sk-...your-openai-key",
        "ANTHROPIC_API_KEY": "sk-ant-admin-...your-admin-key",
        "CACHE_TTL": "3600",
        "LOG_LEVEL": "info"
      }
    }
  }
}
  1. Reload VS Code window (Cmd/Ctrl + Shift + P โ†’ "Developer: Reload Window")

Using the Cost Management Server

Once configured, you can ask Claude Code about your cloud costs:

๐Ÿ“Š "What are my AWS costs for this month?"
๐Ÿ“ˆ "Show me OpenAI API usage trends"
๐Ÿ” "Break down my cloud expenses by service"
๐Ÿ’ฐ "Compare costs across all providers"

Security Note:

  • For project-specific .mcp.json, add it to .gitignore to avoid committing sensitive API keys

  • Consider using environment variables or a secrets manager for production use

  • The cache is optional - if not configured, the server will work without caching

Available Tools

cost_get

Retrieve cost data for specified providers and time periods.

Parameters:

  • provider (optional): Specific provider to query ('aws', 'openai', 'anthropic')

  • startDate (required): Start date in YYYY-MM-DD format

  • endDate (required): End date in YYYY-MM-DD format

  • granularity (optional): 'daily', 'monthly', or 'total' (default: 'total')

  • groupBy (optional): Array of dimensions to group by (e.g., ['SERVICE', 'REGION'])

Example Request:

{
  "provider": "aws",
  "startDate": "2024-01-01",
  "endDate": "2024-01-31",
  "granularity": "daily",
  "groupBy": ["SERVICE"]
}

Example Response:

{
  "success": true,
  "data": {
    "provider": "aws",
    "period": {
      "start": "2024-01-01T00:00:00.000Z",
      "end": "2024-01-31T23:59:59.999Z"
    },
    "costs": {
      "total": 1234.56,
      "currency": "USD",
      "breakdown": [
        {
          "service": "Amazon EC2",
          "amount": 800.0,
          "usage": {
            "quantity": 720,
            "unit": "Hours"
          }
        },
        {
          "service": "Amazon S3",
          "amount": 434.56
        }
      ]
    },
    "metadata": {
      "lastUpdated": "2024-01-31T12:00:00.000Z",
      "source": "api"
    }
  }
}

provider_list

List all configured providers and their connection status.

Response includes:

  • Provider name

  • Configuration status

  • Credential validation status

Example Response:

{
  "success": true,
  "data": {
    "providers": [
      {
        "name": "aws",
        "status": "active",
        "configured": true
      },
      {
        "name": "openai",
        "status": "active",
        "configured": true
    ],
    "configured": 2,
    "total": 3
  }
}

provider_balance

Check remaining balance or credits (provider-specific). Note: Currently not implemented for most providers

Provider Setup

AWS

  1. Enable Cost Explorer in AWS Console

    • Navigate to AWS Cost Management โ†’ Cost Explorer

    • Click "Enable Cost Explorer" (โš ๏ธ This action is irreversible)

    • Wait 24 hours for data to be available

  2. Create IAM User with minimal permissions:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": ["ce:GetCostAndUsage", "ce:GetCostForecast", "ce:GetDimensionValues"],
          "Resource": "*"
        }
      ]
    }
  3. Set environment variables:

    AWS_ACCESS_KEY_ID=your-access-key
    AWS_SECRET_ACCESS_KEY=your-secret-key
    AWS_REGION=us-east-1  # Cost Explorer only works in us-east-1

โš ๏ธ Important: AWS charges $0.01 per Cost Explorer API request. Caching is enabled by default (1 hour) to minimize costs.

OpenAI

  1. Get API Key from OpenAI Dashboard

  2. Ensure you have:

    • A paid account with usage history

    • API access enabled

  3. Set environment variable:

    OPENAI_API_KEY=sk-...your-api-key

โš ๏ธ Note: The Usage API is relatively new (December 2024). Ensure your account has access.

Anthropic

  1. Get Admin API Key from Anthropic Console

  2. Requirements:

    • Organization account (individual accounts are not supported)

    • Admin role to provision Admin API keys

    • Admin API key starts with sk-ant-admin... (different from regular API keys)

  3. Set environment variable:

    ANTHROPIC_API_KEY=sk-ant-admin-...your-admin-api-key

โš ๏ธ Important Notes:

  • Only Admin API keys can access cost and usage data

  • Cost data is available through two APIs:

    • Cost Report API: Provides actual billing data in USD

    • Usage Report API: Provides token-level details with calculated costs

  • Data typically appears within 5 minutes of API request completion

  • Supports prompt caching cost tracking

Configuration

Environment Variables

Variable

Description

Default

Required

AWS_ACCESS_KEY_ID

AWS access key

-

For AWS

AWS_SECRET_ACCESS_KEY

AWS secret key

-

For AWS

AWS_REGION

AWS region

us-east-1

For AWS

OPENAI_API_KEY

OpenAI API key

-

For OpenAI

ANTHROPIC_API_KEY

Anthropic Admin API key

-

For Anthropic

CACHE_TTL

Cache time-to-live in seconds

3600

No

CACHE_TYPE

Cache backend (memory/redis)

memory

No

REDIS_URL

Redis connection URL

-

If using Redis

LOG_LEVEL

Log verbosity (debug/info/warn/error)

info

No

MCP_SERVER_PORT

Server port

3000

No

Cache Configuration

The cache helps reduce API costs and improve performance:

  • Memory Cache (default): Fast, no setup required, data lost on restart

  • Redis Cache: Persistent, shared across instances, requires Redis server

To use Redis:

CACHE_TYPE=redis
REDIS_URL=redis://localhost:6379

Logging

Structured JSON logging is used for easy parsing:

# View logs in development
npm run dev

# View logs in production with jq
npm start 2>&1 | jq '.'

# Filter errors only
npm start 2>&1 | jq 'select(.level == "error")'

Development

Project Structure

cost-management-mcp/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ common/          # Shared utilities and types
โ”‚   โ”‚   โ”œโ”€โ”€ cache.ts     # Caching implementation
โ”‚   โ”‚   โ”œโ”€โ”€ config.ts    # Configuration management
โ”‚   โ”‚   โ”œโ”€โ”€ errors.ts    # Custom error classes
โ”‚   โ”‚   โ”œโ”€โ”€ types.ts     # TypeScript interfaces
โ”‚   โ”‚   โ””โ”€โ”€ utils.ts     # Helper functions
โ”‚   โ”œโ”€โ”€ providers/       # Provider implementations
โ”‚   โ”‚   โ”œโ”€โ”€ aws/         # AWS Cost Explorer
โ”‚   โ”‚   โ”œโ”€โ”€ openai/      # OpenAI Usage API
โ”‚   โ”‚   โ”œโ”€โ”€ anthropic/   # Anthropic Admin API
โ”‚   โ”œโ”€โ”€ tools/           # MCP tool implementations
โ”‚   โ”‚   โ”œโ”€โ”€ getCosts.ts
โ”‚   โ”‚   โ”œโ”€โ”€ listProviders.ts
โ”‚   โ”‚   โ””โ”€โ”€ checkBalance.ts
โ”‚   โ”œโ”€โ”€ server.ts        # MCP server setup
โ”‚   โ””โ”€โ”€ index.ts         # Entry point
โ”œโ”€โ”€ tests/               # Test files
โ”œโ”€โ”€ docs/                # Additional documentation
โ””โ”€โ”€ scripts/             # Utility scripts

Commands

# Development with hot reload
npm run dev

# Build TypeScript to JavaScript
npm run build

# Run production server
npm start

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

# Type check without building
npm run typecheck

# Clean build artifacts
npm run clean

Adding a New Provider

  1. Create provider directory:

mkdir -p src/providers/newprovider
  1. Implement required files:

  • types.ts - TypeScript interfaces

  • transformer.ts - Convert API response to unified format

  • client.ts - API client implementing ProviderClient

  • index.ts - Public exports

  1. Update server.ts to include the new provider

  2. Add tests in tests/providers/newprovider/

Testing

Tests use Jest with TypeScript support:

# Run all tests
npm test

# Run tests for specific provider
npm test -- aws

# Run with coverage
npm run test:coverage

# Debug tests
node --inspect-brk node_modules/.bin/jest --runInBand

Architecture

Design Principles

  1. Unified Interface: All providers implement the same ProviderClient interface

  2. Error Resilience: Automatic retry with exponential backoff

  3. Cost Optimization: Aggressive caching to minimize API calls

  4. Type Safety: Full TypeScript coverage with strict mode

  5. Extensibility: Easy to add new providers or tools

Data Flow

User Request โ†’ MCP Tool โ†’ Provider Client โ†’ Cache Check
                                              โ†“ (miss)
                                          External API
                                              โ†“
                                          Transformer
                                              โ†“
                                          Cache Store
                                              โ†“
                                          Response

Error Handling

The system implements a hierarchical error handling strategy:

  1. Provider Errors: Specific to each cloud provider

  2. Authentication Errors: Invalid or expired credentials

  3. Rate Limit Errors: Automatic retry with backoff

  4. Validation Errors: Invalid input parameters

  5. Network Errors: Retryable connection issues

Troubleshooting

Common Issues

"Authentication failed" error

  • Verify your API keys/credentials are correct

  • Check if the credentials have the required permissions

  • For AWS, ensure you're using us-east-1 region for Cost Explorer

No cost data returned

  • AWS: Wait 24 hours after enabling Cost Explorer

  • OpenAI: Verify you have a paid account with usage

High AWS costs

  • Cost Explorer API charges $0.01 per request

  • Increase CACHE_TTL to reduce API calls

  • Use Redis cache for persistence across restarts

"Rate limit exceeded" error

  • The system automatically retries with exponential backoff

  • If persistent, check your API quotas

  • Consider increasing cache TTL

Debug Mode

Enable debug logging for more information:

LOG_LEVEL=debug npm run dev

Health Check

Test individual providers:

# In your MCP client
Use the provider_list tool to check all providers

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository

  2. Create a feature branch: git checkout -b feature/your-feature

  3. Make your changes

  4. Add tests for new functionality

  5. Ensure all tests pass: npm test

  6. Lint your code: npm run lint

  7. Commit with descriptive message

  8. Push to your fork and submit a PR

Code Style

  • Follow TypeScript best practices

  • Use meaningful variable names

  • Add JSDoc comments for public APIs

  • Keep functions small and focused

  • Write tests for new features

๐Ÿ“Š Project Status

Build & Test

  • CI/CD: Automated testing on push and PR

  • Node Support: 18.x and 20.x

  • Coverage: Comprehensive test suite with coverage reporting

Security

  • Dependency Scanning: Weekly automated updates

  • Secret Detection: Continuous monitoring for exposed credentials

  • Code Analysis: CodeQL security scanning

Quality

  • Type Safety: Strict TypeScript configuration

  • Linting: ESLint with auto-fix on commit

  • Formatting: Prettier code formatting

License

MIT License - see LICENSE file for details


ๆ—ฅๆœฌ่ชžใƒ‰ใ‚ญใƒฅใƒกใƒณใƒˆ

ๆฆ‚่ฆ

Cost Management MCPใฏใ€่ค‡ๆ•ฐใฎใ‚ฏใƒฉใ‚ฆใƒ‰ใƒ—ใƒญใƒใ‚คใƒ€ใƒผใจAPIใ‚ตใƒผใƒ“ใ‚นใฎใ‚ณใ‚นใƒˆใ‚’็ตฑไธ€็š„ใซ็ฎก็†ใ™ใ‚‹ใŸใ‚ใฎModel Context Protocol (MCP)ใ‚ตใƒผใƒใƒผใงใ™ใ€‚

ไธปใชๆฉŸ่ƒฝ

  • ๐Ÿ” AWSใ€OpenAIใ€Anthropicใฎใ‚ณใ‚นใƒˆใ‚’ไธ€ๅ…ƒ็ฎก็†

  • ๐Ÿ’พ APIใ‚ณใ‚นใƒˆใ‚’ๆœ€ๅฐ้™ใซๆŠ‘ใˆใ‚‹ใ‚คใƒณใƒ†ใƒชใ‚ธใ‚งใƒณใƒˆใ‚ญใƒฃใƒƒใ‚ทใƒณใ‚ฐ

  • ๐Ÿ“Š ๆŸ”่ปŸใชๆ—ฅไป˜็ฏ„ๅ›ฒใจ้›†่จˆใ‚ชใƒ—ใ‚ทใƒงใƒณ

  • ๐Ÿ” ็’ฐๅขƒๅค‰ๆ•ฐใซใ‚ˆใ‚‹ๅฎ‰ๅ…จใช่ช่จผๆƒ…ๅ ฑ็ฎก็†

  • ๐Ÿš€ Claude Desktopใจใฎ็ฐกๅ˜ใช็ตฑๅˆ

  • โšก TypeScriptใซใ‚ˆใ‚‹ๅž‹ๅฎ‰ๅ…จๆ€ง

  • ๐Ÿงช ๅŒ…ๆ‹ฌ็š„ใชใƒ†ใ‚นใƒˆใ‚ซใƒใƒฌใƒƒใ‚ธ

  • ๐Ÿ”„ ๆŒ‡ๆ•ฐใƒใƒƒใ‚ฏใ‚ชใƒ•ใซใ‚ˆใ‚‹่‡ชๅ‹•ใƒชใƒˆใƒฉใ‚ค

  • ๐Ÿ›ก๏ธ CodeQLใจTrufflehogใซใ‚ˆใ‚‹ใ‚ปใ‚ญใƒฅใƒชใƒ†ใ‚ฃใ‚นใ‚ญใƒฃใƒณ

  • ๐Ÿ“ฆ Dependabotใซใ‚ˆใ‚‹่‡ชๅ‹•ไพๅญ˜้–ขไฟ‚ๆ›ดๆ–ฐ

๐Ÿ› ๏ธ ๅˆฉ็”จๅฏ่ƒฝใชMCPใƒ„ใƒผใƒซ

ใ“ใฎใ‚ตใƒผใƒใƒผใฏใ€ใ‚ณใ‚นใƒˆ็ฎก็†ใฎใŸใ‚ใฎ3ใคใฎๅผทๅŠ›ใชใƒ„ใƒผใƒซใ‚’ๆไพ›ใ—ใพใ™๏ผš

๐Ÿ“Š cost.get

่ฉณ็ดฐใชใ‚ณใ‚นใƒˆๅ†…่จณใ‚’ๅ–ๅพ—

  • ไปปๆ„ใฎๆœŸ้–“ใฎใ‚ณใ‚นใƒˆใ‚’ใƒใ‚งใƒƒใ‚ฏ

  • ็‰นๅฎšใฎใƒ—ใƒญใƒใ‚คใƒ€ใƒผ๏ผˆAWSใ€OpenAI๏ผ‰ใงใƒ•ใ‚ฃใƒซใ‚ฟใƒชใƒณใ‚ฐ

  • ๆ—ฅๆฌกใ€ๆœˆๆฌกใ€ใพใŸใฏๅˆ่จˆใ‚ณใ‚นใƒˆใ‚’่กจ็คบ

  • ใ‚ตใƒผใƒ“ใ‚นใƒฌใƒ™ใƒซใฎๅ†…่จณใ‚’็ขบ่ช

Claudeใงใฎไฝฟ็”จไพ‹๏ผš

  • ใ€ŒไปŠๆœˆใฎAWSใฎใ‚ณใ‚นใƒˆใ‚’ๆ•™ใˆใฆใ€

  • ใ€Œ้ŽๅŽป1้€ฑ้–“ใฎOpenAIใฎๆ—ฅๆฌกไฝฟ็”จ้‡ใ‚’่กจ็คบใ—ใฆใ€

  • ใ€Œใ‚ฏใƒฉใ‚ฆใƒ‰ใ‚ณใ‚นใƒˆใ‚’ใ‚ตใƒผใƒ“ใ‚นๅˆฅใซๅˆ†่งฃใ—ใฆใ€

๐Ÿ“‹ provider_list

ใƒ—ใƒญใƒใ‚คใƒ€ใƒผใฎ็Šถๆ…‹ใ‚’็ขบ่ช

  • ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹ใƒ—ใƒญใƒใ‚คใƒ€ใƒผใ‚’็ขบ่ช

  • API่ช่จผๆƒ…ๅ ฑใŒๆœ‰ๅŠนใ‹ใ‚’ๆคœ่จผ

  • ใ™ในใฆใฎ็ตฑๅˆใฎใƒ˜ใƒซใ‚นใƒใ‚งใƒƒใ‚ฏ

ไฝฟ็”จไพ‹๏ผš

  • ใ€Œใ™ในใฆใฎใ‚ฏใƒฉใ‚ฆใƒ‰ใƒ—ใƒญใƒใ‚คใƒ€ใƒผใ‚’ไธ€่ฆง่กจ็คบใ€

  • ใ€Œใฉใฎใ‚ณใ‚นใƒˆ่ฟฝ่ทกใ‚ตใƒผใƒ“ใ‚นใŒใ‚ขใ‚ฏใƒ†ใ‚ฃใƒ–๏ผŸใ€

๐Ÿ’ฐ provider_balance

ๆฎ‹้ซ˜ใฎ็ขบ่ช (่ฟ‘ๆ—ฅๅ…ฌ้–‹)

  • ใƒ—ใƒชใƒšใ‚คใƒ‰ๆฎ‹้ซ˜ใฎ่กจ็คบ

  • APIใ‚ฏใƒฌใ‚ธใƒƒใƒˆไฝฟ็”จ้‡ใฎ็›ฃ่ฆ–

  • ใ‚ฏใƒฌใ‚ธใƒƒใƒˆๆœŸ้™ๅ‰ใฎใ‚ขใƒฉใƒผใƒˆ

ใ‚คใƒณใ‚นใƒˆใƒผใƒซ

# ใƒชใƒใ‚ธใƒˆใƒชใฎใ‚ฏใƒญใƒผใƒณ
git clone https://github.com/knishioka/cost-management-mcp.git
cd cost-management-mcp

# ไพๅญ˜้–ขไฟ‚ใฎใ‚คใƒณใ‚นใƒˆใƒผใƒซ
npm install

# ็’ฐๅขƒๅค‰ๆ•ฐใฎ่จญๅฎš
cp .env.example .env
# .envใƒ•ใ‚กใ‚คใƒซใ‚’็ทจ้›†ใ—ใฆ่ช่จผๆƒ…ๅ ฑใ‚’่ฟฝๅŠ 

# ใƒ“ใƒซใƒ‰
npm run build

Claude Desktopใจใฎ็ตฑๅˆ

Claude Desktopใฎ่จญๅฎšใƒ•ใ‚กใ‚คใƒซใซไปฅไธ‹ใ‚’่ฟฝๅŠ ๏ผš

{
  "mcpServers": {
    "cost-management": {
      "command": "node",
      "args": ["/path/to/cost-management-mcp/dist/index.js"],
      "env": {
        "AWS_ACCESS_KEY_ID": "your-key",
        "AWS_SECRET_ACCESS_KEY": "your-secret",
        "OPENAI_API_KEY": "your-key"
      }
    }
  }
}

Claude Codeใจใฎ็ตฑๅˆ

Claude Codeใฏ2ใคใฎ่จญๅฎšๆ–นๆณ•ใงMCPใ‚ตใƒผใƒใƒผใ‚’ใ‚ตใƒใƒผใƒˆใ—ใฆใ„ใพใ™๏ผš

ๆ–นๆณ•1: ใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆๅ›บๆœ‰ใฎ่จญๅฎš๏ผˆๆŽจๅฅจ๏ผ‰

ใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆใฎใƒซใƒผใƒˆใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชใซ .mcp.json ใƒ•ใ‚กใ‚คใƒซใ‚’ไฝœๆˆ๏ผš

{
  "mcpServers": {
    "cost-management": {
      "command": "node",
      "args": ["/absolute/path/to/cost-management-mcp/dist/index.js"],
      "env": {
        "AWS_ACCESS_KEY_ID": "your-aws-access-key",
        "AWS_SECRET_ACCESS_KEY": "your-aws-secret-key",
        "AWS_REGION": "us-east-1",
        "OPENAI_API_KEY": "sk-...your-openai-key",
        "ANTHROPIC_API_KEY": "sk-ant-admin-...your-admin-key",
        "CACHE_TTL": "3600",
        "LOG_LEVEL": "info"
      }
    }
  }
}

ใ“ใฎ่จญๅฎšใฏใ€Claude Codeใงใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆใ‚’้–‹ใ„ใŸใจใใซ่‡ชๅ‹•็š„ใซ่ชญใฟ่พผใพใ‚Œใพใ™ใ€‚

ๆ–นๆณ•2: VS Code่จญๅฎš๏ผˆใ‚ฐใƒญใƒผใƒใƒซ่จญๅฎš๏ผ‰

  1. VS Code่จญๅฎšใ‚’้–‹ใ๏ผˆCmd/Ctrl + ,๏ผ‰

  2. ใ€ŒClaude Code MCP Serversใ€ใ‚’ๆคœ็ดข

  3. ใ€Œsettings.jsonใง็ทจ้›†ใ€ใ‚’ใ‚ฏใƒชใƒƒใ‚ฏ

  4. ใ‚ณใ‚นใƒˆ็ฎก็†ใ‚ตใƒผใƒใƒผใฎ่จญๅฎšใ‚’่ฟฝๅŠ ๏ผš

{
  "claudeCode.mcpServers": {
    "cost-management": {
      "command": "node",
      "args": ["/absolute/path/to/cost-management-mcp/dist/index.js"],
      "env": {
        "AWS_ACCESS_KEY_ID": "your-aws-access-key",
        "AWS_SECRET_ACCESS_KEY": "your-aws-secret-key",
        "AWS_REGION": "us-east-1",
        "OPENAI_API_KEY": "sk-...your-openai-key",
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/gcp-service-account.json",
        "GCP_BILLING_ACCOUNT_ID": "your-billing-account-id"
      }
    }
  }
}
  1. VS Codeใ‚ฆใ‚ฃใƒณใƒ‰ใ‚ฆใ‚’ใƒชใƒญใƒผใƒ‰๏ผˆCmd/Ctrl + Shift + P โ†’ ใ€Œ้–‹็™บ่€…: ใ‚ฆใ‚ฃใƒณใƒ‰ใ‚ฆใฎๅ†่ชญใฟ่พผใฟใ€๏ผ‰

ใ‚ณใ‚นใƒˆ็ฎก็†ใ‚ตใƒผใƒใƒผใฎไฝฟ็”จ

่จญๅฎšใŒๅฎŒไบ†ใ—ใŸใ‚‰ใ€Claude Codeใงใ‚ฏใƒฉใ‚ฆใƒ‰ใ‚ณใ‚นใƒˆใซใคใ„ใฆ่ณชๅ•ใงใใพใ™๏ผš

๐Ÿ“Š ใ€ŒไปŠๆœˆใฎAWSใ‚ณใ‚นใƒˆใ‚’ๆ•™ใˆใฆใ€
๐Ÿ“ˆ ใ€ŒOpenAI APIใฎไฝฟ็”จๅ‚พๅ‘ใ‚’่กจ็คบใ€
๐Ÿ” ใ€Œใ‚ตใƒผใƒ“ใ‚นๅˆฅใซใ‚ฏใƒฉใ‚ฆใƒ‰่ฒป็”จใ‚’ๅˆ†ๆžใ€
๐Ÿ’ฐ ใ€Œๅ…จใƒ—ใƒญใƒใ‚คใƒ€ใƒผใฎใ‚ณใ‚นใƒˆใ‚’ๆฏ”่ผƒใ€

ใ‚ปใ‚ญใƒฅใƒชใƒ†ใ‚ฃใซ้–ขใ™ใ‚‹ๆณจๆ„:

  • ใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆๅ›บๆœ‰ใฎ .mcp.json ใฏ .gitignore ใซ่ฟฝๅŠ ใ—ใฆใ€APIใ‚ญใƒผใ‚’ใ‚ณใƒŸใƒƒใƒˆใ—ใชใ„ใ‚ˆใ†ใซใ—ใฆใใ ใ•ใ„

  • ๆœฌ็•ช็’ฐๅขƒใงใฏ็’ฐๅขƒๅค‰ๆ•ฐใ‚„ใ‚ทใƒผใ‚ฏใƒฌใƒƒใƒˆ็ฎก็†ใƒ„ใƒผใƒซใฎไฝฟ็”จใ‚’ๆคœ่จŽใ—ใฆใใ ใ•ใ„

  • ใ‚ญใƒฃใƒƒใ‚ทใƒฅใฏใ‚ชใƒ—ใ‚ทใƒงใƒณใงใ™ - ่จญๅฎšใ•ใ‚Œใฆใ„ใชใ„ๅ ดๅˆใ€ใ‚ตใƒผใƒใƒผใฏใ‚ญใƒฃใƒƒใ‚ทใƒฅใชใ—ใงๅ‹•ไฝœใ—ใพใ™

ไฝฟ็”จไพ‹

ไปŠๆœˆใฎAWSใฎใ‚ณใ‚นใƒˆใ‚’ๆ•™ใˆใฆ
้ŽๅŽป7ๆ—ฅ้–“ใฎOpenAI APIใฎไฝฟ็”จๆ–™้‡‘ใฏ๏ผŸ
่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹ใ‚ฏใƒฉใ‚ฆใƒ‰ใƒ—ใƒญใƒใ‚คใƒ€ใƒผใ‚’ไธ€่ฆง่กจ็คบใ—ใฆ

ใƒ—ใƒญใƒใ‚คใƒ€ใƒผใฎ่จญๅฎš

ๅ„ใƒ—ใƒญใƒใ‚คใƒ€ใƒผใฎ่ฉณ็ดฐใช่จญๅฎšๆ–นๆณ•ใฏ่‹ฑ่ชž็‰ˆใƒ‰ใ‚ญใƒฅใƒกใƒณใƒˆใ‚’ๅ‚็…งใ—ใฆใใ ใ•ใ„ใ€‚

้–‹็™บ

# ้–‹็™บใƒขใƒผใƒ‰๏ผˆใƒ›ใƒƒใƒˆใƒชใƒญใƒผใƒ‰ไป˜ใ๏ผ‰
npm run dev

# ใƒ†ใ‚นใƒˆใฎๅฎŸ่กŒ
npm test

# ใƒชใƒณใƒˆใƒใ‚งใƒƒใ‚ฏ
npm run lint

# ๅž‹ใƒใ‚งใƒƒใ‚ฏ
npm run typecheck

๐Ÿ“Š ใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆใ‚นใƒ†ใƒผใ‚ฟใ‚น

ใƒ“ใƒซใƒ‰๏ผ†ใƒ†ใ‚นใƒˆ

  • CI/CD: ใƒ—ใƒƒใ‚ทใƒฅใจPRๆ™‚ใฎ่‡ชๅ‹•ใƒ†ใ‚นใƒˆ

  • Nodeใ‚ตใƒใƒผใƒˆ: 18.xใจ20.x

  • ใ‚ซใƒใƒฌใƒƒใ‚ธ: ใ‚ซใƒใƒฌใƒƒใ‚ธใƒฌใƒใƒผใƒˆไป˜ใใฎๅŒ…ๆ‹ฌ็š„ใชใƒ†ใ‚นใƒˆใ‚นใ‚คใƒผใƒˆ

ใ‚ปใ‚ญใƒฅใƒชใƒ†ใ‚ฃ

  • ไพๅญ˜้–ขไฟ‚ใ‚นใ‚ญใƒฃใƒณ: ้€ฑๆฌก่‡ชๅ‹•ๆ›ดๆ–ฐ

  • ใ‚ทใƒผใ‚ฏใƒฌใƒƒใƒˆๆคœๅ‡บ: ๅ…ฌ้–‹ใ•ใ‚ŒใŸ่ช่จผๆƒ…ๅ ฑใฎ็ถ™็ถš็š„็›ฃ่ฆ–

  • ใ‚ณใƒผใƒ‰ๅˆ†ๆž: CodeQLใ‚ปใ‚ญใƒฅใƒชใƒ†ใ‚ฃใ‚นใ‚ญใƒฃใƒณ

ๅ“่ณช

  • ๅž‹ๅฎ‰ๅ…จๆ€ง: ๅŽณๆ ผใชTypeScript่จญๅฎš

  • ใƒชใƒณใƒ†ใ‚ฃใƒณใ‚ฐ: ใ‚ณใƒŸใƒƒใƒˆๆ™‚ใฎESLint่‡ชๅ‹•ไฟฎๆญฃ

  • ใƒ•ใ‚ฉใƒผใƒžใƒƒใƒˆ: Prettierใ‚ณใƒผใƒ‰ใƒ•ใ‚ฉใƒผใƒžใƒƒใƒˆ

ใƒฉใ‚คใ‚ปใƒณใ‚น

MIT License


Built with โค๏ธ using TypeScript and MCP

Install Server
A
security โ€“ no known vulnerabilities
A
license - permissive license
B
quality - B tier

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/knishioka/cost-management-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server