ai-cost-optimizer

v1.0.0
io.github.lazymac2x/ai-cost-optimizer Checked 15 hours ago Published 6 months ago

Cloudflare Workers MCP server: ai-cost-optimizer

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

cost_tracker

Record and retrieve AI API call costs by team. Persists to Cloudflare KV — survives cold starts and scale-out.

ParameterTypeDescription
action *string"record" to log a call, "get" to retrieve recent records
inputTokensnumberNumber of input/prompt tokens consumed
metadataobjectOptional key-value metadata (request ID, user, feature flag, etc.)
modelstringModel ID (e.g., claude-3-5-sonnet-20241022, gpt-4o, gemini-2.0-flash)
outputTokensnumberNumber of output/completion tokens generated
teamstringTeam or project identifier (default: "default")

token_calculator

Calculate cost from token counts for any supported AI model. Stateless — no KV required.

ParameterTypeDescription
inputTokens *numberInput token count
model *stringModel ID to price
outputTokens *numberOutput token count

budget_alert

Set and check budget limits for teams. Raises a flag when a configurable spending threshold is reached.

ParameterTypeDescription
action *string"set" to configure a budget, "check" to get current status
budgetLimitnumberUSD budget cap
teamstringTeam identifier
thresholdnumberAlert threshold percentage 0–100 (default: 80)

model_breakdown

Analyze costs broken down by model for a given team over a configurable time window.

ParameterTypeDescription
daysnumberLookback window in days (default: 30)
teamstringTeam identifier

cost_forecast

Forecast future AI spend based on historical usage patterns using daily-average linear projection.

ParameterTypeDescription
forecastDaysnumberDays to project ahead (default: 7)
historicalDaysnumberDays of history to base the forecast on (default: 30)
teamstringTeam identifier