Skip to main content
Glama

hotel-emission

Calculate carbon emissions from hotel stays using location and nights stayed to assess environmental impact.

Instructions

Calculate carbon emissions from hotel stays based on the number of nights stayed and the location of the hotel.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hotel_nightsYesNumber of nights stayed
locationYesLocation of the hotel
yearNoYear of the hotel stay

Implementation Reference

  • The `hotel_emission_tool` function implements the core logic for calculating CO2e emissions from hotel stays using the Climatiq API.
    async def hotel_emission_tool(config, arguments, server, climatiq_request): """ Calculate carbon emissions from hotel stays. This tool estimates the greenhouse gas emissions associated with hotel accommodations based on the number of nights stayed and the location of the hotel. It provides valuable data for calculating business travel emissions. """ hotel_nights = arguments.get("hotel_nights") location = arguments.get("location") year = arguments.get("year") if not hotel_nights or not location: raise ValueError("Missing required parameters for hotel emission calculation") # Construct the request to the Climatiq API request_data = { "hotel_nights": hotel_nights, "location": location } if year: request_data["year"] = year try: result = await climatiq_request("/travel/v1-preview1/hotel", request_data) # Store in cache cache_id = f"hotel_{hotel_nights}_{id(result)}" co2e = result.get("co2e", 0) co2e_unit = result.get("co2e_unit", "kg") location_name = result.get("location", {}).get("name", "unknown location") result_text = f"Hotel stay for {hotel_nights} nights in {location_name} " 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: error_text = f"Error calculating hotel emissions: {str(e)}" return error_text, None, None
  • Tool registration in `get_tool_definitions()` including name, description, and input schema.
    types.Tool( name="hotel-emission", description="Calculate carbon emissions from hotel stays based on the number of nights stayed and the location of the hotel.", inputSchema={ "type": "object", "properties": { "hotel_nights": {"type": "number", "description": "Number of nights stayed"}, "location": {"type": "string", "description": "Location of the hotel"}, "year": {"type": "number", "description": "Year of the hotel stay"}, }, "required": ["hotel_nights", "location"], }, ),
  • Input schema definition for the hotel-emission tool, specifying required parameters: hotel_nights and location.
    types.Tool( name="hotel-emission", description="Calculate carbon emissions from hotel stays based on the number of nights stayed and the location of the hotel.", inputSchema={ "type": "object", "properties": { "hotel_nights": {"type": "number", "description": "Number of nights stayed"}, "location": {"type": "string", "description": "Location of the hotel"}, "year": {"type": "number", "description": "Year of the hotel stay"}, }, "required": ["hotel_nights", "location"], }, ),
  • Dispatch logic in `@server.call_tool()` handler that routes 'hotel-emission' calls to the hotel_emission_tool function.
    elif name == "hotel-emission": result_text, result, cache_id = await hotel_emission_tool(config, arguments, server, climatiq_request)

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