#!/bin/bash
echo "🔍 COMPARING COST PARAMETERS: MCP vs Curl Script"
echo "==============================================="
# Credentials
USERNAME="elisha@umbrellacost.net"
PASSWORD="G37oi57Kp@cNzx"
BASE_URL="https://api.umbrellacost.io/api/v1"
echo "📝 Authenticating..."
# Get authentication token
AUTH_RESPONSE=$(curl -s -X POST \
"${BASE_URL}/authentication/token/generate" \
-H "Content-Type: application/json" \
-d "{\"username\":\"${USERNAME}\",\"password\":\"${PASSWORD}\"}")
# Extract tokens
JWT_TOKEN=$(echo "$AUTH_RESPONSE" | grep -o '"Authorization":"[^"]*"' | cut -d'"' -f4)
API_KEY=$(echo "$AUTH_RESPONSE" | grep -o '"apikey":"[^"]*"' | cut -d'"' -f4)
# Get proper API key
ACCOUNTS_RESPONSE=$(curl -s -X GET \
"${BASE_URL}/user-management/accounts" \
-H "Authorization: $JWT_TOKEN" \
-H "apikey: $API_KEY")
PROPER_ACCOUNT_KEY=$(echo "$ACCOUNTS_RESPONSE" | grep -o '"accountKey":"[^"]*"' | head -1 | cut -d'"' -f4)
USER_KEY=$(echo "$API_KEY" | cut -d':' -f1)
PROPER_API_KEY="${USER_KEY}:${PROPER_ACCOUNT_KEY}:0"
echo "✅ Authentication successful"
echo ""
echo "🔧 TEST 1: Curl Script Parameters (cost only)"
echo "============================================="
echo "Parameters: costType=cost"
CURL_RESPONSE=$(curl -s -X GET \
"${BASE_URL}/invoices/caui?startDate=2025-08-10&endDate=2025-08-10&groupBy=service&periodGranLevel=day&costType=cost" \
-H "Authorization: $JWT_TOKEN" \
-H "apikey: $PROPER_API_KEY")
# Find Cloud Monitoring cost
CURL_MONITORING_COST=$(echo "$CURL_RESPONSE" | grep -o '"service_name":"Cloud Monitoring","total_cost":[^,]*' | grep -o '"total_cost":[^,]*' | cut -d':' -f2)
echo "Cloud Monitoring cost (cost only): \$${CURL_MONITORING_COST}"
echo ""
echo "🔧 TEST 2: MCP Default Parameters (cost + discount)"
echo "=================================================="
echo "Parameters: costType=cost,discount&isUnblended=true"
MCP_RESPONSE=$(curl -s -X GET \
"${BASE_URL}/invoices/caui?startDate=2025-08-10&endDate=2025-08-10&groupBy=service&periodGranLevel=day&costType=cost&costType=discount&isUnblended=true" \
-H "Authorization: $JWT_TOKEN" \
-H "apikey: $PROPER_API_KEY")
# Find Cloud Monitoring cost
MCP_MONITORING_COST=$(echo "$MCP_RESPONSE" | grep -o '"service_name":"Cloud Monitoring","total_cost":[^,]*' | grep -o '"total_cost":[^,]*' | cut -d':' -f2)
echo "Cloud Monitoring cost (cost + discount, unblended): \$${MCP_MONITORING_COST}"
echo ""
echo "🔧 TEST 3: Cost + Discount Comparison"
echo "===================================="
if [ ! -z "$CURL_MONITORING_COST" ] && [ ! -z "$MCP_MONITORING_COST" ]; then
echo "✅ Found Cloud Monitoring in both responses"
echo "Curl (cost only): \$${CURL_MONITORING_COST}"
echo "MCP (cost + discount): \$${MCP_MONITORING_COST}"
# Basic comparison
if [ "$CURL_MONITORING_COST" != "$MCP_MONITORING_COST" ]; then
echo "🚨 DIFFERENT PRICES CONFIRMED"
echo "Reason: Different costType parameters"
else
echo "✅ Same prices"
fi
else
echo "❌ Could not find Cloud Monitoring in one or both responses"
fi
echo ""
echo "📋 PARAMETER DIFFERENCE SUMMARY:"
echo "==============================="
echo "Curl Script: costType=cost (gross costs)"
echo "MCP Server: costType=cost,discount + isUnblended=true (net effective costs)"
echo ""
echo "💡 RECOMMENDATION: Update curl script to match MCP parameters for consistency"