Coverage for mcp/tools/costs.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-06-15 15:07 +0000

1"""Cost tracking MCP tools.""" 

2 

3import cli_runner 

4from audit import audit_logged 

5from server import mcp 

6 

7 

8@mcp.tool(tags={"safe", "costs"}) 

9@audit_logged 

10def cost_summary(days: int = 30) -> str: 

11 """Get total GCO spend broken down by AWS service. 

12 

13 Args: 

14 days: Number of days to look back. 

15 """ 

16 return cli_runner._run_cli("costs", "summary", "--days", str(days)) 

17 

18 

19@mcp.tool(tags={"safe", "costs"}) 

20@audit_logged 

21def cost_by_region(days: int = 30) -> str: 

22 """Get cost breakdown by AWS region. 

23 

24 Args: 

25 days: Number of days to look back. 

26 """ 

27 return cli_runner._run_cli("costs", "regions", "--days", str(days)) 

28 

29 

30@mcp.tool(tags={"safe", "costs"}) 

31@audit_logged 

32def cost_trend(days: int = 14) -> str: 

33 """Get daily cost trend. 

34 

35 Args: 

36 days: Number of days to show. 

37 """ 

38 return cli_runner._run_cli("costs", "trend", "--days", str(days)) 

39 

40 

41@mcp.tool(tags={"safe", "costs"}) 

42@audit_logged 

43def cost_forecast(days_ahead: int = 30) -> str: 

44 """Forecast GCO costs for the next N days. 

45 

46 Args: 

47 days_ahead: Days to forecast ahead. 

48 """ 

49 return cli_runner._run_cli("costs", "forecast", "--days", str(days_ahead))