cost_guard_configure
Set weekly budget limits and alerts to control API spending in agent-safety-mcp, preventing unexpected costs during AI operations.
Instructions
Configure the cost guard budget.
Args: weekly_budget_usd: Maximum spend per week in USD. alert_at_pct: Warn when spend reaches this percentage (0.0-1.0). dry_run: If true, all calls raise BudgetExceededError (safe for testing).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| weekly_budget_usd | No | ||
| alert_at_pct | No | ||
| dry_run | No |
Implementation Reference
- src/agent_safety_mcp/server.py:97-121 (handler)The handler for the 'cost_guard_configure' tool, which updates the global '_guard' state with a new CostGuard instance using the provided configuration parameters.
@mcp.tool() def cost_guard_configure( weekly_budget_usd: float = 10.0, alert_at_pct: float = 0.80, dry_run: bool = False, ) -> dict: """Configure the cost guard budget. Args: weekly_budget_usd: Maximum spend per week in USD. alert_at_pct: Warn when spend reaches this percentage (0.0-1.0). dry_run: If true, all calls raise BudgetExceededError (safe for testing). """ global _guard _guard = CostGuard( weekly_budget_usd=weekly_budget_usd, alert_at_pct=alert_at_pct, dry_run=dry_run, ) return { "status": "configured", "weekly_budget_usd": weekly_budget_usd, "alert_at_pct": alert_at_pct, "dry_run": dry_run, }