Cloudflare Workers MCP server: ai-cost-optimizer
Maintain this server? Claim it
Call this server's tools from your browser. Nothing to install.
Requests go through mcptry because browsers can't call most MCP servers directly. Header values are sent to the server for that request only and are never stored or logged.
Tool list from our last check. Connect live to refresh it.
Set and check budget limits for teams. Raises a flag when a configurable spending threshold is reached.
"set" to configure a budget, "check" to get current status
Team identifier
Alert threshold percentage 0–100 (default: 80)
USD budget cap
This tool isn't marked read-only, so it may change something on the server or in an account you connected.
Set and check budget limits for teams. Raises a flag when a configurable spending threshold is reached.
| Argument | Type | Description |
|---|---|---|
| team | string | Team identifier |
| action* | string | "set" to configure a budget, "check" to get current status |
| threshold | number | Alert threshold percentage 0–100 (default: 80) |
| budgetLimit | number | USD budget cap |
{
"type": "object",
"required": [
"action"
],
"properties": {
"team": {
"type": "string",
"description": "Team identifier"
},
"action": {
"enum": [
"set",
"check"
],
"type": "string",
"description": "\"set\" to configure a budget, \"check\" to get current status"
},
"threshold": {
"type": "number",
"description": "Alert threshold percentage 0–100 (default: 80)"
},
"budgetLimit": {
"type": "number",
"description": "USD budget cap"
}
}
}Forecast future AI spend based on historical usage patterns using daily-average linear projection.
| Argument | Type | Description |
|---|---|---|
| team | string | Team identifier |
| forecastDays | number | Days to project ahead (default: 7) |
| historicalDays | number | Days of history to base the forecast on (default: 30) |
{
"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)"
}
}
}Record and retrieve AI API call costs by team. Persists to Cloudflare KV — survives cold starts and scale-out.
| Argument | Type | Description |
|---|---|---|
| team | string | Team or project identifier (default: "default") |
| model | string | Model ID (e.g., claude-3-5-sonnet-20241022, gpt-4o, gemini-2.0-flash) |
| action* | string | "record" to log a call, "get" to retrieve recent records |
| metadata | object | Optional key-value metadata (request ID, user, feature flag, etc.) |
| inputTokens | number | Number of input/prompt tokens consumed |
| outputTokens | number | Number of output/completion tokens generated |
{
"type": "object",
"required": [
"action"
],
"properties": {
"team": {
"type": "string",
"description": "Team or project identifier (default: \"default\")"
},
"model": {
"type": "string",
"description": "Model ID (e.g., claude-3-5-sonnet-20241022, gpt-4o, gemini-2.0-flash)"
},
"action": {
"enum": [
"record",
"get"
],
"type": "string",
"description": "\"record\" to log a call, \"get\" to retrieve recent records"
},
"metadata": {
"type": "object",
"description": "Optional key-value metadata (request ID, user, feature flag, etc.)"
},
"inputTokens": {
"type": "number",
"description": "Number of input/prompt tokens consumed"
},
"outputTokens": {
"type": "number",
"description": "Number of output/completion tokens generated"
}
}
}Analyze costs broken down by model for a given team over a configurable time window.
| Argument | Type | Description |
|---|---|---|
| days | number | Lookback window in days (default: 30) |
| team | string | Team identifier |
{
"type": "object",
"properties": {
"days": {
"type": "number",
"description": "Lookback window in days (default: 30)"
},
"team": {
"type": "string",
"description": "Team identifier"
}
}
}Calculate cost from token counts for any supported AI model. Stateless — no KV required.
| Argument | Type | Description |
|---|---|---|
| model* | string | Model ID to price |
| inputTokens* | number | Input token count |
| outputTokens* | number | Output token count |
{
"type": "object",
"required": [
"model",
"inputTokens",
"outputTokens"
],
"properties": {
"model": {
"type": "string",
"description": "Model ID to price"
},
"inputTokens": {
"type": "number",
"description": "Input token count"
},
"outputTokens": {
"type": "number",
"description": "Output token count"
}
}
}