Skip to main content
Glama
jagan-shanmugam

Climatiq MCP Server

set-api-key

Configure authentication for carbon emissions calculations by setting your Climatiq API key to enable authorized access to climate impact data.

Instructions

Set the Climatiq API key for authentication. This allows the server to make authorized requests to the Climatiq API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
api_keyYesYour Climatiq API key obtained from app.climatiq.io

Implementation Reference

  • The handler function that extracts the api_key from arguments, validates it by making a test API request to Climatiq, stores it in the config if valid, and returns a success message.
    async def set_api_key_tool(config, arguments, server, climatiq_request):
        """
        Set the Climatiq API key for authentication with the API.
        
        This tool configures the Climatiq API key used for all subsequent API calls.
        The key is stored in memory for the duration of the server session.
        """
        api_key = arguments.get("api_key")
        
        if not api_key:
            raise ValueError("API key is required")
        
        # Validate API key by making a test request
        test_headers = {
            "Authorization": f"Bearer {api_key}",
            "Content-Type": "application/json"
        }
        
        try:
            # Use httpx directly as we can't use climatiq_request yet
            async with httpx.AsyncClient(timeout=10.0) as client:
                response = await client.get(f"{config['base_url']}/data/v1/search", 
                                            params={"query": "electricity", "data_version": config["data_version"]},
                                            headers=test_headers)
                
                if response.status_code != 200:
                    error_detail = "Invalid API key or API connection issue"
                    try:
                        error_json = response.json()
                        if "error" in error_json:
                            error_detail = error_json["error"]
                        elif "message" in error_json:
                            error_detail = error_json["message"]
                    except:
                        pass
                        
                    raise ValueError(f"API key validation failed: {error_detail}")
            
            # If we get here, the API key is valid
            config["api_key"] = api_key
            return "Climatiq API key configured successfully. You can now use other tools to calculate emissions."
            
        except httpx.RequestError as e:
            raise ValueError(f"Failed to connect to Climatiq API: {str(e)}")
        except Exception as e:
            raise ValueError(f"Error validating API key: {str(e)}")
  • The input schema definition specifying that the tool requires a string 'api_key' parameter.
    inputSchema={
        "type": "object",
        "properties": {
            "api_key": {"type": "string", "description": "Your Climatiq API key obtained from app.climatiq.io"},
        },
        "required": ["api_key"],
    },
  • The tool registration in get_tool_definitions() list, including name, description, and input schema.
    types.Tool(
        name="set-api-key",
        description="Set the Climatiq API key for authentication. This allows the server to make authorized requests to the Climatiq API.",
        inputSchema={
            "type": "object",
            "properties": {
                "api_key": {"type": "string", "description": "Your Climatiq API key obtained from app.climatiq.io"},
            },
            "required": ["api_key"],
        },
    ),
  • The dispatch logic in handle_call_tool() that routes 'set-api-key' calls to the set_api_key_tool handler.
    if name == "set-api-key":
        result_text = await set_api_key_tool(config, arguments, server, climatiq_request)
  • The list_tools() handler returns the tool definitions from tools.get_tool_definitions(), which includes 'set-api-key'.
    return get_tool_definitions()
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It clearly indicates this is a configuration/mutation tool (setting an API key) and explains the authentication purpose. However, it doesn't address important behavioral aspects like whether this persists across sessions, if it overwrites existing keys, what happens on failure, or any rate limits/security implications.

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 consists of two focused sentences that directly address the tool's purpose and usage. Every word earns its place with zero redundancy or fluff. The information is front-loaded and efficiently structured.

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?

For a single-parameter authentication tool with no annotations and no output schema, the description provides adequate basic context about what the tool does and why. However, it lacks details about behavioral consequences (persistence, error handling) and doesn't explain what 'success' looks like since there's no output schema to document return values.

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?

The schema description coverage is 100%, with the single parameter 'api_key' well-documented in the schema itself. The description doesn't add any additional parameter semantics beyond what the schema already provides (it mentions 'API key' but doesn't elaborate on format, validation, or source requirements). 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.

Purpose5/5

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

The description clearly states the specific action ('Set') and resource ('Climatiq API key for authentication'), with the explicit purpose of enabling authorized API requests. It distinguishes this from sibling tools that perform emission calculations or searches, making it immediately clear this is an authentication configuration tool.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool: 'for authentication' and 'to make authorized requests to the Climatiq API.' It implies this should be used before calling other emission calculation tools that require authentication, providing clear contextual guidance without needing to list specific alternatives.

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