Skip to main content
Glama
robobobby

mcp-danish-energy

by robobobby

co2_emissions

Get real-time CO2 emission intensity data for Danish electricity production to identify low-carbon periods for scheduling energy-intensive tasks.

Instructions

Get real-time CO2 emission intensity of Danish electricity production (g CO2/kWh). Updated every 5 minutes. Useful for timing energy-intensive tasks to low-carbon periods.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
areaNoPrice area: DK1 or DK2, or a city/region name. Default: both areas.
hoursNoHours of history to return (default: 1, max: 24)

Implementation Reference

  • Complete tool registration and handler for 'co2_emissions'. Fetches real-time CO2 emission intensity from Danish electricity production via Energi Data Service API (CO2Emis dataset). Processes data by price area, calculates averages, and classifies emission levels (clean/moderate/high).
    server.tool(
      "co2_emissions",
      "Get real-time CO2 emission intensity of Danish electricity production (g CO2/kWh). Updated every 5 minutes. Useful for timing energy-intensive tasks to low-carbon periods.",
      {
        area: z.string().optional().describe("Price area: DK1 or DK2, or a city/region name. Default: both areas."),
        hours: z.number().optional().describe("Hours of history to return (default: 1, max: 24)"),
      },
      async ({ area, hours = 1 }) => {
        const priceArea = area ? resolvePriceArea(area) : null;
        const filter = priceArea ? JSON.stringify({ PriceArea: priceArea }) : undefined;
        const limit = Math.min(hours * 12, 288) * (priceArea ? 1 : 2); // 12 readings/hour (5min intervals)
    
        const data = await fetchDataset("CO2Emis", {
          limit,
          sort: "Minutes5DK desc",
          filter,
        });
    
        if (!data.records?.length) {
          return { content: [{ type: "text", text: "No CO2 emission data available." }] };
        }
    
        const byArea = {};
        for (const r of data.records) {
          if (!byArea[r.PriceArea]) byArea[r.PriceArea] = [];
          byArea[r.PriceArea].push(r);
        }
    
        let output = "# Danish CO2 Emission Intensity\n\n";
        for (const [areaCode, records] of Object.entries(byArea)) {
          const latest = records[0];
          const values = records.map(r => r.CO2Emission).filter(v => v != null);
          const avg = values.length ? values.reduce((a, b) => a + b, 0) / values.length : null;
    
          output += `## ${areaCode} — ${PRICE_AREAS[areaCode] || areaCode}\n\n`;
          output += `**Current:** ${latest.CO2Emission} g CO2/kWh (${latest.Minutes5DK?.replace("T", " ").slice(0, 16)})\n`;
          if (avg != null) output += `**Average (last ${hours}h):** ${avg.toFixed(0)} g CO2/kWh\n`;
    
          // Classify
          const co2 = latest.CO2Emission;
          let label = "🟢 Very clean";
          if (co2 > 300) label = "🔴 High emissions";
          else if (co2 > 200) label = "🟡 Moderate";
          else if (co2 > 100) label = "🟢 Clean";
          output += `**Status:** ${label}\n\n`;
        }
    
        output += "*Source: Energi Data Service (Energinet). Real-time 5-minute resolution.*\n";
        return { content: [{ type: "text", text: output }] };
      }
    );
  • Zod schema defining input parameters for co2_emissions tool: optional 'area' (price area string) and optional 'hours' (number, defaults to 1, max 24).
      area: z.string().optional().describe("Price area: DK1 or DK2, or a city/region name. Default: both areas."),
      hours: z.number().optional().describe("Hours of history to return (default: 1, max: 24)"),
    },
  • fetchDataset helper function that constructs API URL, sets parameters, makes HTTP request to Energi Data Service API, and returns JSON response. Used by co2_emissions to fetch from 'CO2Emis' dataset.
    async function fetchDataset(dataset, params = {}) {
      const url = new URL(`${BASE_URL}/${dataset}`);
      url.searchParams.set("format", "json");
      for (const [k, v] of Object.entries(params)) {
        if (v != null) url.searchParams.set(k, String(v));
      }
      const res = await fetch(url.toString(), { headers: { "User-Agent": USER_AGENT } });
      if (!res.ok) {
        const text = await res.text();
        throw new Error(`Energi Data Service API error (${res.status}): ${text}`);
      }
      return res.json();
    }
  • resolvePriceArea helper function that maps user input (DK1/DK2 codes or city/region names) to valid price area codes. Used by co2_emissions to resolve the 'area' parameter.
    function resolvePriceArea(input) {
      if (!input) return null;
      const upper = input.toUpperCase().trim();
      if (upper === "DK1" || upper === "DK2") return upper;
      const lower = input.toLowerCase().trim();
      // Map common regions
      if (["west", "western", "jylland", "jutland", "fyn", "funen", "esbjerg", "aarhus", "aalborg", "odense", "herning", "vejle", "kolding", "horsens", "randers", "viborg", "silkeborg"].includes(lower)) return "DK1";
      if (["east", "eastern", "sjælland", "zealand", "copenhagen", "københavn", "amager", "roskilde", "helsingør", "hillerød", "næstved", "køge", "lolland", "falster", "bornholm"].includes(lower)) return "DK2";
      return null;
    }
Behavior4/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 effectively describes key behavioral traits: real-time nature, update frequency ('Updated every 5 minutes'), and the practical application context. It doesn't mention rate limits, authentication needs, or error conditions, but provides substantial operational context.

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 perfectly front-loaded with the core purpose, followed by operational details and usage context. Every sentence earns its place: the first states what it does, the second provides update frequency, and the third explains practical application. Zero wasted words.

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

Completeness4/5

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

For a read-only data retrieval tool with no output schema, the description provides excellent context about what data is returned (CO2 intensity), its real-time nature, update frequency, and practical use case. It doesn't describe the return format or structure, but given the tool's relative simplicity and clear purpose, this is reasonably complete.

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?

With 100% schema description coverage, the input schema already documents both parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline expectation but doesn't provide additional semantic context.

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 ('Get real-time CO2 emission intensity'), resource ('Danish electricity production'), and measurement unit ('g CO2/kWh'). It distinguishes from sibling tools like 'electricity_prices' and 'energy_mix' by focusing specifically on carbon intensity rather than pricing or generation mix.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool ('Useful for timing energy-intensive tasks to low-carbon periods'), which implicitly suggests it's for carbon-aware scheduling. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools.

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/robobobby/mcp-danish-energy'

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