Skip to main content
Glama
jagan-shanmugam

Climatiq MCP Server

custom-emission-calculation

Calculate carbon emissions using specific emission factors identified by activity IDs for precise environmental impact assessments.

Instructions

Calculate emissions using any specific emission factor identified by its activity_id, allowing for precise and flexible carbon calculations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activity_idYesEmission factor activity ID (found via search-emission-factors)
valueYesActivity value (amount of the activity)
unitYesActivity unit (e.g., kWh, km, kg, etc.)

Implementation Reference

  • The primary handler function that implements the logic for the 'custom-emission-calculation' tool. It takes an activity_id, value, and unit, constructs a request to the Climatiq API, processes the response, and returns formatted results with caching.
    async def custom_emission_calculation_tool(config, arguments, server, climatiq_request):
        """
        Calculate emissions using a specific emission factor by activity ID.
        
        This advanced tool allows for precise carbon calculations using any emission factor 
        available in the Climatiq database. Users need to specify:
        - The exact activity_id (which can be found using the search-emission-factors tool)
        - The value of the activity (e.g., amount consumed, distance traveled)
        - The unit of measurement (e.g., kWh, km, kg)
        
        This tool is highly flexible and can be used for any emission calculation supported
        by Climatiq when you know the specific emission factor you need to use.
        """
        activity_id = arguments.get("activity_id")
        value = arguments.get("value")
        unit = arguments.get("unit")
        
        if not activity_id or value is None or not unit:
            raise ValueError("Missing required parameters for custom emission calculation")
            
        # Construct the request to the Climatiq API
        request_data = {
            "emission_factor": {
                "activity_id": activity_id,
                "data_version": config["data_version"]
            },
            "parameters": {
                unit: value
            }
        }
        
        try:
            result = await climatiq_request("/data/v1/estimate", request_data)
            
            # Store in cache
            cache_id = f"custom_{activity_id}_{value}_{unit}_{id(result)}"
            
            co2e = result.get("co2e", 0)
            co2e_unit = result.get("co2e_unit", "kg")
            factor_name = result.get("emission_factor", {}).get("name", "Custom factor")
            
            result_text = f"Custom calculation using '{factor_name}' activity:\n"
            result_text += f"{value} {unit} results in {co2e} {co2e_unit} of CO2e emissions."
            
            if "emission_factor" in result:
                ef = result["emission_factor"]
                result_text += f"\n\nFactor details:"
                result_text += f"\nName: {ef.get('name', 'N/A')}"
                result_text += f"\nRegion: {ef.get('region', 'Global')}"
                result_text += f"\nSource: {ef.get('source', 'Unknown')}"
            
            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 in custom emission calculation: {str(e)}"
            raise ValueError(error_msg)
  • The tool registration definition in get_tool_definitions(), including the name, description, and input schema for the MCP server to recognize and validate calls to this tool.
    types.Tool(
        name="custom-emission-calculation",
        description="Calculate emissions using any specific emission factor identified by its activity_id, allowing for precise and flexible carbon calculations.",
        inputSchema={
            "type": "object",
            "properties": {
                "activity_id": {"type": "string", "description": "Emission factor activity ID (found via search-emission-factors)"},
                "value": {"type": "number", "description": "Activity value (amount of the activity)"},
                "unit": {"type": "string", "description": "Activity unit (e.g., kWh, km, kg, etc.)"},
            },
            "required": ["activity_id", "value", "unit"],
        },
    ),
  • The dispatch logic in the main @server.call_tool() handler that routes calls to 'custom-emission-calculation' to the specific tool function.
    elif name == "custom-emission-calculation":
        result_text, result, cache_id = await custom_emission_calculation_tool(config, arguments, server, climatiq_request)
  • The input schema definition specifying the required parameters and their types for the custom-emission-calculation tool.
    inputSchema={
        "type": "object",
        "properties": {
            "activity_id": {"type": "string", "description": "Emission factor activity ID (found via search-emission-factors)"},
            "value": {"type": "number", "description": "Activity value (amount of the activity)"},
            "unit": {"type": "string", "description": "Activity unit (e.g., kWh, km, kg, etc.)"},
        },
        "required": ["activity_id", "value", "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. While it states the tool calculates emissions, it doesn't describe what the calculation returns (units, format), whether it requires authentication (though set-api-key is a sibling), rate limits, error conditions, or how it handles invalid inputs. For a calculation tool with zero annotation coverage, this leaves significant behavioral gaps.

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

Conciseness4/5

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

The description is a single, efficient sentence that conveys the core purpose without unnecessary words. It's front-loaded with the main action ('Calculate emissions') and includes a qualifying phrase about flexibility. However, it could be slightly more structured by explicitly separating purpose from context.

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 no annotations, no output schema, and a calculation tool with potential complexity, the description is incomplete. It doesn't explain what the tool returns (e.g., emissions in CO2e, units), prerequisites (e.g., needing an API key via set-api-key), or error handling. The schema covers inputs well, but the overall context for agent usage is lacking.

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%, with all three parameters well-documented in the schema. The description adds minimal value beyond the schema, mentioning 'activity_id' and 'carbon calculations' but not explaining parameter relationships or providing additional context like example values or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

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: 'Calculate emissions using any specific emission factor identified by its activity_id'. It specifies the verb ('calculate'), resource ('emissions'), and mechanism ('using emission factor identified by activity_id'). However, it doesn't explicitly distinguish this general-purpose calculation tool from its more specific sibling tools like 'electricity-emission' or 'travel-emission'.

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

Usage Guidelines3/5

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

The description implies usage context through 'allowing for precise and flexible carbon calculations' and references 'activity_id (found via search-emission-factors)' in the schema. This suggests this tool is for custom calculations after finding factors via search-emission-factors, but it doesn't explicitly state when to use this vs. the specialized sibling tools (e.g., electricity-emission for electricity-specific calculations).

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