Skip to main content
Glama
jagan-shanmugam

Climatiq MCP Server

search-emission-factors

Search Climatiq's database for emission factors by keyword, category, region, year, and source to find appropriate data for carbon calculations.

Instructions

Search Climatiq's database for emission factors by keyword, category, region, year, source, and other metadata to find appropriate factors for calculations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query for emission factors (e.g., 'electricity', 'flight', 'truck')
categoryNoCategory of emission factors (e.g., 'Energy', 'Transport')
regionNoRegion code to filter results (e.g., 'US', 'EU')
yearNoYear of emission factors
sourceNoSource organization of emission factors (e.g., 'IPCC', 'EPA', 'BEIS')
data_versionNoData version of emission factors
unit_typeNoUnit type of emission factors (e.g., 'energy', 'distance', 'weight')

Implementation Reference

  • Main handler function that executes the search-emission-factors tool by calling the Climatiq API search endpoint, processing results, and formatting a user-friendly summary of the top emission factors.
    async def search_emission_factors_tool(config, arguments, server, climatiq_request):
        """
        Search for emission factors in the Climatiq database.
        
        This tool allows users to search through Climatiq's extensive database of emission factors
        using keywords and filters. It helps users find the appropriate emission factors for 
        specific activities, regions, or categories. The search results include:
        - The name of the emission factor
        - Activity ID (used for custom calculations)
        - Region specificity
        - Year of publication
        - Category classification
        - Source organization
        - Available units
        
        This tool is especially useful before performing custom calculations, as it helps 
        identify the correct activity_id to use.
        """
        query = arguments.get("query")
        category = arguments.get("category", "")
        region = arguments.get("region", "")
        year = arguments.get("year", "")
        source = arguments.get("source", "")
        data_version = arguments.get("data_version", config["data_version"])
        unit_type = arguments.get("unit_type", "")
        
        if not query:
            raise ValueError("Missing search query")
            
        # Construct the request to the Climatiq API
        params = {
            "query": query,
            "data_version": data_version
        }
        
        # Add all optional filters if provided
        if category:
            params["category"] = category
        if region:
            params["region"] = region
        if year:
            params["year"] = year
        if source:
            params["source"] = source
        if unit_type:
            params["unit_type"] = unit_type
        
        try:    
            result = await climatiq_request("/data/v1/search", params, method="GET")
            
            # Process search results
            results = result.get("results", [])
            total_count = len(results)
            
            if total_count == 0:
                result_text = "No emission factors found matching your search criteria."
                return result_text, {}, None
                
            # Format a summary of the results
            result_text = f"Found {total_count} emission factors matching '{query}'.\n\n"
            
            # Display the first 5 results (or fewer if less are available)
            max_display = min(5, total_count)
            result_text += f"Here are the first {max_display} results:\n\n"
            
            for i in range(max_display):
                ef = results[i]
                result_text += f"{i+1}. {ef.get('name', 'Unnamed factor')}\n"
                result_text += f"   Activity ID: {ef.get('activity_id', 'N/A')}\n"
                result_text += f"   Region: {ef.get('region_name', ef.get('region', 'N/A'))}\n"
                result_text += f"   Year: {ef.get('year', 'N/A')}\n"
                result_text += f"   Source: {ef.get('source', 'N/A')}\n"
                if ef.get('unit'):
                    result_text += f"   Unit: {ef.get('unit', 'N/A')}\n"
                result_text += "\n"
            
            # If there are more results than we displayed
            if total_count > max_display:
                result_text += f"\n... and {total_count - max_display} more results."
                
            # Include a note about using these factors with the custom calculation tool
            result_text += "\n\nTo use one of these emission factors, copy its Activity ID and use it with the custom-emission-calculation tool."
            
            # Cache the search results
            cache_id = f"search_{query.replace(' ', '_')}_{id(result)}"
            
            return result_text, result, cache_id
        except Exception as e:
            error_msg = f"Error searching emission factors: {str(e)}"
            raise ValueError(error_msg)
  • Pydantic/MCP schema definition for the search-emission-factors tool, including input parameters and validation rules.
    types.Tool(
        name="search-emission-factors",
        description="Search Climatiq's database for emission factors by keyword, category, region, year, source, and other metadata to find appropriate factors for calculations.",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {"type": "string", "description": "Search query for emission factors (e.g., 'electricity', 'flight', 'truck')"},
                "category": {"type": "string", "description": "Category of emission factors (e.g., 'Energy', 'Transport')", "default": ""},
                "region": {"type": "string", "description": "Region code to filter results (e.g., 'US', 'EU')", "default": ""},
                "year": {"type": "integer", "description": "Year of emission factors", "default": 2022},
                "source": {"type": "string", "description": "Source organization of emission factors (e.g., 'IPCC', 'EPA', 'BEIS')", "default": ""},
                "data_version": {"type": "string", "description": "Data version of emission factors", "default": ""},
                "unit_type": {"type": "string", "description": "Unit type of emission factors (e.g., 'energy', 'distance', 'weight')", "default": ""}
            },
            "required": ["query"],
        },
    ),
  • Tool dispatch/registration in the MCP server's handle_call_tool method, routing calls to the handler function.
    elif name == "search-emission-factors":
        result_text, result, cache_id = await search_emission_factors_tool(config, arguments, server, climatiq_request)
  • Registers the tool list handler which provides the tool schema via get_tool_definitions() including search-emission-factors.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        """
        List available tools for interacting with the Climatiq API.
        """
        return get_tool_definitions()
  • Import of the search_emission_factors_tool handler from tools.py.
    search_emission_factors_tool,
Behavior2/5

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

No annotations are provided, so the description carries full burden. It describes the search functionality but lacks behavioral details: it doesn't mention whether this is a read-only operation, how results are returned (e.g., pagination, format), rate limits, authentication requirements, or error handling. For a search tool with 7 parameters and no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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 front-loads the core purpose. It avoids redundancy by not repeating schema details. However, it could be slightly more structured by separating the action from the goal (e.g., 'Search for emission factors... Use this to...'), but overall it's concise and well-focused.

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

Completeness3/5

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

Given the complexity (7 parameters, no annotations, no output schema), the description is adequate but incomplete. It covers the basic purpose and parameters but lacks behavioral transparency and clear usage differentiation from siblings. Without an output schema, it doesn't describe return values, which is a gap for a search tool. It meets minimum viability but has clear room for improvement.

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 7 parameters well-documented in the schema. The description adds minimal value beyond the schema by listing the same parameters (keyword, category, region, year, source, other metadata) without providing additional context like examples beyond 'query' or explaining interactions between parameters. This meets the baseline for high schema coverage.

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: 'Search Climatiq's database for emission factors by keyword, category, region, year, source, and other metadata to find appropriate factors for calculations.' It specifies the action (search), resource (emission factors database), and scope (by various metadata). However, it doesn't explicitly distinguish this general search tool from the more specific sibling tools like 'electricity-emission' or 'travel-emission' that appear to target specific domains.

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 'to find appropriate factors for calculations,' suggesting this is for discovery before calculation. However, it provides no explicit guidance on when to use this tool versus the more specific sibling tools (e.g., 'electricity-emission' for electricity-related factors), nor does it mention prerequisites like API key setup (though 'set-api-key' exists as a sibling). The guidance is present but incomplete.

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