cloud-computing-emission
Calculate carbon emissions from cloud computing usage by provider, service, and region to assess digital environmental impact.
Instructions
Calculate emissions from cloud computing services by provider, service type, and region to assess digital carbon footprint.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| provider | Yes | Cloud provider (aws, azure, gcp) | |
| service | Yes | Cloud service (e.g., compute, storage, database) | |
| region | Yes | Cloud region (e.g., us-east-1, europe-west1) | |
| usage_amount | Yes | Amount of cloud resources used | |
| usage_unit | Yes | Unit for cloud resource (e.g., kWh, GB-hours, CPU-hours) |
Implementation Reference
- src/climatiq_mcp_server/tools.py:449-504 (handler)The async handler function that executes the tool logic: extracts parameters, constructs Climatiq API request with dynamic activity_id, calls API, formats response, handles errors.async def cloud_computing_emission_tool(config, arguments, server, climatiq_request): """ Calculate carbon emissions from cloud computing resource usage. This specialized tool estimates the carbon footprint of cloud computing services across major providers (AWS, Azure, GCP). It accounts for: - The specific cloud provider (affects emission factors) - The type of service used (compute, storage, networking, etc.) - The region/data center location (significant regional variations in grid emissions) - Usage amount and units (CPU hours, GB-months, etc.) This tool helps organizations understand and measure the environmental impact of their cloud infrastructure and can support sustainable cloud deployment decisions. """ provider = arguments.get("provider") service = arguments.get("service") region = arguments.get("region") usage_amount = arguments.get("usage_amount") usage_unit = arguments.get("usage_unit") if not provider or not service or not region or not usage_amount or not usage_unit: raise ValueError("Missing required parameters for cloud computing emission calculation") # Construct the request to the Climatiq API request_data = { "emission_factor": { "activity_id": f"cloud_computing-{provider}-{service}-{region}", "data_version": config["data_version"] }, "parameters": { usage_unit: usage_amount } } try: result = await climatiq_request("/data/v1/estimate", request_data) # Store in cache cache_id = f"cloud_{provider}_{service}_{region}_{usage_amount}_{usage_unit}_{id(result)}" co2e = result.get("co2e", 0) co2e_unit = result.get("co2e_unit", "kg") result_text = f"Cloud computing usage of {usage_amount} {usage_unit} with {provider} {service} in {region} " result_text += f"results in {co2e} {co2e_unit} of CO2e emissions." result_text += f"\n\nDetailed results are available as a resource with ID: {cache_id}" return result_text, result, cache_id except ValueError as e: if "API request failed" in str(e): error_text = f"Error calculating emissions: {str(e)}\n\n" error_text += "This might be due to an unsupported provider/service/region combination. " error_text += "Try searching for the correct emission factor first using the search-emission-factors tool with a query like 'cloud_computing'." return error_text, None, None else:
- The input schema definition for the tool, specifying parameters and requirements, returned by get_tool_definitions().types.Tool( name="cloud-computing-emission", description="Calculate emissions from cloud computing services by provider, service type, and region to assess digital carbon footprint.", inputSchema={ "type": "object", "properties": { "provider": {"type": "string", "description": "Cloud provider (aws, azure, gcp)"}, "service": {"type": "string", "description": "Cloud service (e.g., compute, storage, database)"}, "region": {"type": "string", "description": "Cloud region (e.g., us-east-1, europe-west1)"}, "usage_amount": {"type": "number", "description": "Amount of cloud resources used"}, "usage_unit": {"type": "string", "description": "Unit for cloud resource (e.g., kWh, GB-hours, CPU-hours)"}, }, "required": ["provider", "service", "region", "usage_amount", "usage_unit"], }, ),
- src/climatiq_mcp_server/server.py:256-257 (registration)Registration and dispatch to the handler in the MCP server's call_tool handler.elif name == "cloud-computing-emission": result_text, result, cache_id = await cloud_computing_emission_tool(config, arguments, server, climatiq_request)
- src/climatiq_mcp_server/server.py:32-44 (registration)Import of the tool handler function from tools.py module.from climatiq_mcp_server.tools import ( set_api_key_tool, electricity_emission_tool, travel_emission_tool, search_emission_factors_tool, custom_emission_calculation_tool, cloud_computing_emission_tool, freight_emission_tool, procurement_emission_tool, hotel_emission_tool, travel_spend_tool, get_tool_definitions )