ai-cost-optimizer
Cloudflare Workers MCP server: ai-cost-optimizer
Should I use this
Quality & Safety
Based on automated analysis of tool definitions and protocol compliance.
Context Cost
This is the approximate number of tokens consumed each time the server's tools are loaded into a model's context. Higher counts reduce the attention available for other tasks.
Install
One-Click Install
Add this to your `claude_desktop_config.json` file:
{
"mcpServers": {
"ai-cost-optimizer": {
"url": "https://api.lazy-mac.com/ai-cost-optimizer/mcp"
}
}
}Remote endpoints
https://api.lazy-mac.com/ai-cost-optimizer/mcpstreamable-httpWhat it can do
Tool inventory
Tools (5)
🟢cost_tracker(action, model, inputTokens, outputTokens, team, ...)
Record and retrieve AI API call costs by team. Persists to Cloudflare KV — survives cold starts and scale-out.
Input Schema
{
"type": "object",
"properties": {
"action": {
"type": "string",
"enum": [
"record",
"get"
],
"description": "\"record\" to log a call, \"get\" to retrieve recent records"
},
"model": {
"type": "string",
"description": "Model ID (e.g., claude-3-5-sonnet-20241022, gpt-4o, gemini-2.0-flash)"
},
"inputTokens": {
"type": "number",
"description": "Number of input/prompt tokens consumed"
},
"outputTokens": {
"type": "number",
"description": "Number of output/completion tokens generated"
},
"team": {
"type": "string",
"description": "Team or project identifier (default: \"default\")"
},
"metadata": {
"type": "object",
"description": "Optional key-value metadata (request ID, user, feature flag, etc.)"
}
},
"required": [
"action"
]
}🟢token_calculator(model, inputTokens, outputTokens)
Calculate cost from token counts for any supported AI model. Stateless — no KV required.
Input Schema
{
"type": "object",
"properties": {
"model": {
"type": "string",
"description": "Model ID to price"
},
"inputTokens": {
"type": "number",
"description": "Input token count"
},
"outputTokens": {
"type": "number",
"description": "Output token count"
}
},
"required": [
"model",
"inputTokens",
"outputTokens"
]
}🟡budget_alert(action, team, budgetLimit, threshold)
Set and check budget limits for teams. Raises a flag when a configurable spending threshold is reached.
Input Schema
{
"type": "object",
"properties": {
"action": {
"type": "string",
"enum": [
"set",
"check"
],
"description": "\"set\" to configure a budget, \"check\" to get current status"
},
"team": {
"type": "string",
"description": "Team identifier"
},
"budgetLimit": {
"type": "number",
"description": "USD budget cap"
},
"threshold": {
"type": "number",
"description": "Alert threshold percentage 0–100 (default: 80)"
}
},
"required": [
"action"
]
}🟢model_breakdown(team, days)
Analyze costs broken down by model for a given team over a configurable time window.
Input Schema
{
"type": "object",
"properties": {
"team": {
"type": "string",
"description": "Team identifier"
},
"days": {
"type": "number",
"description": "Lookback window in days (default: 30)"
}
}
}⚪cost_forecast(team, forecastDays, historicalDays)
Forecast future AI spend based on historical usage patterns using daily-average linear projection.
Input Schema
{
"type": "object",
"properties": {
"team": {
"type": "string",
"description": "Team identifier"
},
"forecastDays": {
"type": "number",
"description": "Days to project ahead (default: 7)"
},
"historicalDays": {
"type": "number",
"description": "Days of history to base the forecast on (default: 30)"
}
}
}Community
Evidence