Skip to main content
Glama
jagan-shanmugam

Climatiq MCP Server

electricity-emission

Calculate carbon emissions from electricity consumption using energy amount and regional grid data to assess environmental impact.

Instructions

Calculate carbon emissions from electricity consumption based on energy amount and regional grid mix.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
energyYesAmount of energy consumed
energy_unitYesEnergy unit (kWh, MWh, etc.)
regionNoRegion code (e.g., US, GB, FR) representing the electricity grid locationUS

Implementation Reference

  • Handler function that performs the electricity emission calculation by querying the Climatiq API with the appropriate emission factor and parameters.
    async def electricity_emission_tool(config, arguments, server, climatiq_request):
        """
        Calculate carbon emissions from electricity consumption.
        
        This tool calculates the greenhouse gas emissions associated with electricity usage based on:
        - The amount of energy consumed (in kWh, MWh, etc.)
        - The region/country where the electricity is consumed (affecting the grid mix)
        
        It uses Climatiq's electricity emission factors which account for the specific energy 
        generation mix of the specified region, providing accurate CO2e estimations.
        """
        energy = arguments.get("energy")
        energy_unit = arguments.get("energy_unit")
        region = arguments.get("region", "US")
        
        if not energy or not energy_unit:
            raise ValueError("Missing required parameters for electricity emission calculation")
            
        # Construct the request to the Climatiq API
        request_data = {
            "emission_factor": {
                "activity_id": "electricity-supply_grid-source_residual_mix",
                "data_version": config["data_version"],
                "region": region
            },
            "parameters": {
                "energy": energy,
                "energy_unit": energy_unit
            }
        }
        
        try:
            result = await climatiq_request("/data/v1/estimate", request_data)
            
            # Store in cache
            cache_id = f"electricity_{energy}_{energy_unit}_{region}_{id(result)}"
            
            co2e = result.get("co2e", 0)
            co2e_unit = result.get("co2e_unit", "kg")
            result_text = f"Electricity consumption of {energy} {energy_unit} in {region} results in {co2e} {co2e_unit} of CO2e emissions."
            
            if "emission_factor" in result and result["emission_factor"].get("name"):
                ef_name = result["emission_factor"]["name"]
                result_text += f"\nEmission factor used: {ef_name}"
            
            result_text += f"\n\nDetailed results are available as a resource with ID: {cache_id}"
            
            return result_text, result, cache_id
        except Exception as e:
            error_msg = f"Error calculating electricity emissions: {str(e)}"
            raise ValueError(error_msg)
  • Input schema defining the parameters for the electricity-emission tool: energy (number), energy_unit (string), region (string, default 'US').
    inputSchema={
        "type": "object",
        "properties": {
            "energy": {"type": "number", "description": "Amount of energy consumed"},
            "energy_unit": {"type": "string", "description": "Energy unit (kWh, MWh, etc.)"},
            "region": {"type": "string", "description": "Region code (e.g., US, GB, FR) representing the electricity grid location", "default": "US"},
        },
        "required": ["energy", "energy_unit"],
    },
  • Dispatch logic in the MCP call_tool handler that routes 'electricity-emission' tool calls to the electricity_emission_tool function.
    elif name == "electricity-emission":
        result_text, result, cache_id = await electricity_emission_tool(config, arguments, server, climatiq_request)
  • MCP server.list_tools() handler that returns the list of tool definitions, including electricity-emission, via get_tool_definitions().
    async def handle_list_tools() -> list[types.Tool]:
        """
        List available tools for interacting with the Climatiq API.
        """
        return get_tool_definitions()
  • Tool registration definition in get_tool_definitions() that defines the electricity-emission tool name, description, and schema for MCP server.
    types.Tool(
        name="electricity-emission",
        description="Calculate carbon emissions from electricity consumption based on energy amount and regional grid mix.",
        inputSchema={
            "type": "object",
            "properties": {
                "energy": {"type": "number", "description": "Amount of energy consumed"},
                "energy_unit": {"type": "string", "description": "Energy unit (kWh, MWh, etc.)"},
                "region": {"type": "string", "description": "Region code (e.g., US, GB, FR) representing the electricity grid location", "default": "US"},
            },
            "required": ["energy", "energy_unit"],
        },
    ),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the calculation action but lacks details on permissions, rate limits, error handling, or output format. For a tool with no annotation coverage, this leaves significant gaps in understanding its operational traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. Every part of the sentence contributes directly to explaining what the tool does, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of an emission calculation tool with no annotations and no output schema, the description is incomplete. It doesn't explain the return values, error conditions, or behavioral aspects like data sources or accuracy, which are crucial for proper usage in this context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters (energy, energy_unit, region) with descriptions. The description adds marginal value by mentioning 'energy amount and regional grid mix', which aligns with the parameters but doesn't provide additional syntax or format details beyond what the schema offers.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('calculate') and resource ('carbon emissions from electricity consumption'), and it mentions the key inputs ('energy amount and regional grid mix'). However, it doesn't explicitly differentiate from sibling tools like 'custom-emission-calculation' or 'search-emission-factors', which might handle similar calculations differently.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose it over sibling tools such as 'custom-emission-calculation' for broader scenarios or 'search-emission-factors' for looking up data, nor does it specify prerequisites or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/jagan-shanmugam/climatiq-mcp-server'

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