Skip to main content
Glama

cost_explorer_summary_tool

Analyze AWS spending patterns to identify cost drivers and optimize cloud expenses using granular data breakdowns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNo
granularityNoDAILY
authNo

Implementation Reference

  • MCP tool handler decorated with @mcp.tool (serves as registration). Builds AWS session and calls the core cost_explorer_summary helper function.
    @mcp.tool def cost_explorer_summary_tool(days: int = 30, granularity: str = "DAILY", auth: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: session = build_boto3_session(auth) out = cost_explorer_summary(session, days=days, granularity=granularity) return out
  • Core helper function that performs the AWS Cost Explorer API call to get cost and usage summary data for the specified period and granularity.
    def cost_explorer_summary(session: boto3.Session, days: int = 30, granularity: str = "DAILY") -> Dict[str, Any]: ce = session.client("ce", region_name="us-east-1") # Cost Explorer is us-east-1 for API rng = _dates(days) try: resp = ce.get_cost_and_usage( TimePeriod=rng, Granularity=granularity, Metrics=["UnblendedCost"], ) return {"time_period": rng, "granularity": granularity, "results": resp.get("ResultsByTime", [])} except ClientError as e: return {"time_period": rng, "granularity": granularity, "error": str(e), "results": []}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/oldcoder01/aws-mcp-audit'

If you have feedback or need assistance with the MCP directory API, please join our Discord server