DEV Community

Cover image for I Built an MCP Server That Gives AI Agents Real-Time AWS Pricing Data
constantquadruped
constantquadruped

Posted on

I Built an MCP Server That Gives AI Agents Real-Time AWS Pricing Data

How I solved the 'how much will this cost?' problem for AI-powered infrastructure tools

The Problem

You're building an AI agent that provisions cloud infrastructure. User says: "Spin up a t3.medium in the cheapest region."

Your agent has no idea what that costs. Or which region is cheapest. Or whether reserved instances would save money.

I kept hitting this wall while building AI-powered DevOps tools. The agent could do things, but couldn't answer the most basic question: "How much will this cost?"

The Solution: AWS Pricing MCP

I built an MCP-compatible API that returns real-time AWS pricing data. It's live on RapidAPI now.

What it does:

  • Query pricing for 20 AWS services (EC2, RDS, Lambda, S3, DynamoDB, ECS, EKS, etc.)
  • Compare prices across all 18 AWS regions
  • Get on-demand vs reserved instance breakdowns
  • Estimate monthly costs for multi-instance workloads

How It Works

The API follows MCP (Model Context Protocol) conventions, so any MCP-compatible AI client can use it directly.

Basic Query

curl -X GET "https://aws-pricing-mcp.p.rapidapi.com/ec2/pricing?instance_type=t3.medium&region=us-east-1" \
  -H "X-RapidAPI-Key: YOUR_KEY"
Enter fullscreen mode Exit fullscreen mode

Response

{
  "instance_type": "t3.medium",
  "region": "us-east-1",
  "prices": {
    "on_demand_hourly": 0.0416,
    "on_demand_monthly": 30.37,
    "reserved_1yr_no_upfront_monthly": 24.82,
    "reserved_1yr_all_upfront_monthly": 21.90,
    "reserved_3yr_all_upfront_monthly": 14.60
  },
  "vcpu": 2,
  "memory_gb": 4,
  "potential_savings": {
    "reserved_1yr_percent": 27.9,
    "reserved_3yr_percent": 51.9
  }
}
Enter fullscreen mode Exit fullscreen mode

Region Comparison

This is where it gets useful. Find the cheapest region for any instance type:

curl -X GET "https://aws-pricing-mcp.p.rapidapi.com/ec2/compare-regions?instance_type=m5.xlarge"
Enter fullscreen mode Exit fullscreen mode
{
  "instance_type": "m5.xlarge",
  "cheapest_region": "us-east-2",
  "cheapest_price_monthly": 140.16,
  "most_expensive_region": "ap-northeast-1",
  "most_expensive_price_monthly": 185.04,
  "potential_savings_percent": 24.2,
  "all_regions": [
    {"region": "us-east-2", "monthly": 140.16},
    {"region": "us-east-1", "monthly": 142.08},
    ...
  ]
}
Enter fullscreen mode Exit fullscreen mode

Multi-Service Cost Estimation

Estimate costs for a complete workload:

curl -X POST "https://aws-pricing-mcp.p.rapidapi.com/estimate" \
  -H "Content-Type: application/json" \
  -d '{
    "region": "us-west-2",
    "resources": [
      {"service": "ec2", "instance_type": "t3.medium", "count": 3},
      {"service": "rds", "instance_type": "db.t3.medium", "count": 1},
      {"service": "s3", "storage_gb": 100}
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

Integration with AI Agents

If you're building with Claude, GPT, or any MCP-compatible system, the API responses are structured for easy parsing. No wrestling with AWS's pricing API directly.

Example prompt your users might give:

"What's the cheapest way to run a 3-node web tier with a managed database in AWS?"

Your agent can now actually answer that with real numbers.

Services Supported

Service Pricing Data
EC2 On-demand, Reserved (1yr/3yr), Spot
RDS All engines, Multi-AZ
Lambda Request + duration
S3 Storage classes, transfer
DynamoDB On-demand + provisioned
ECS/EKS Fargate + EC2 launch types
ElastiCache Redis + Memcached
OpenSearch Instance + storage
... 20 services total

Pricing

Tier Requests/Month Price
Free 100 $0
Pro 5,000 $49
Ultra 25,000 $149
Mega 100,000 $299

The free tier is enough to prototype and test.

Why I Built This

Two reasons:

  1. AWS's pricing API is painful. The official API requires you to construct complex filter queries and returns data in a format optimized for AWS, not developers.

  2. AI agents need structured data. When you're building tools that AI can use, you need clean JSON with predictable schemas. Not XML. Not HTML scraping. Not "check the console."

Try It

The API is live on RapidAPI:

👉 AWS Pricing MCP on RapidAPI

Free tier available. No credit card required to start.


https://twitter.com/CrawlingTheWeb

Top comments (0)