Skip to main content
Glama
robobobby
by robobobby

dk_electricity_prices

Retrieve Danish electricity spot prices for today and tomorrow, including hourly rates for DK1 and DK2 areas to help manage energy costs.

Instructions

Get current and upcoming Danish electricity spot prices (Elspot). Returns hourly prices for today and tomorrow (when available). Prices include the raw spot price, not taxes/tariffs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
areaNoPrice area: DK1 (western Denmark) or DK2 (eastern Denmark), or a city/region name. Default: both areas.
hoursNoNumber of hours to return (default: 24, max: 168 for a full week)

Implementation Reference

  • The handler function for the 'dk_electricity_prices' tool, which fetches data from the Energi Data Service API and formats it into a text report.
    async ({ area, hours = 24 }) => {
      const priceArea = area ? resolvePriceArea(area) : null;
      const filter = priceArea ? JSON.stringify({ PriceArea: priceArea }) : undefined;
      const limit = priceArea ? hours : hours * 2; // Both areas = 2x rows
    
      const data = await fetchDataset("Elspotprices", {
        limit,
        sort: "HourDK desc",
        filter,
        start: "now-P1D",
      });
    
      if (!data.records?.length) {
        return { content: [{ type: "text", text: "No price data available for the requested period." }] };
      }
    
      // Group by area
      const byArea = {};
      for (const r of data.records) {
        if (!byArea[r.PriceArea]) byArea[r.PriceArea] = [];
        byArea[r.PriceArea].push(r);
      }
    
      let output = "# Danish Electricity Spot Prices\n\n";
      for (const [areaCode, records] of Object.entries(byArea)) {
        output += `## ${areaCode} — ${PRICE_AREAS[areaCode] || areaCode}\n\n`;
    
        // Stats
        const prices = records.map(r => r.SpotPriceDKK).filter(p => p != null);
        if (prices.length) {
          const avg = prices.reduce((a, b) => a + b, 0) / prices.length;
          const min = Math.min(...prices);
          const max = Math.max(...prices);
          output += `**Average:** ${formatPrice(avg)}\n`;
          output += `**Range:** ${formatPrice(min)} — ${formatPrice(max)}\n\n`;
        }
    
        output += "| Time (DK) | Price |\n|---|---|\n";
        for (const r of records.slice(0, 48)) {
          const time = r.HourDK?.replace("T", " ").slice(0, 16) || "?";
          output += `| ${time} | ${formatPrice(r.SpotPriceDKK)} |\n`;
        }
        output += "\n";
      }
    
      output += "*Source: Energi Data Service (Energinet). Prices are spot prices excl. taxes, tariffs, and VAT.*\n";
    
      return { content: [{ type: "text", text: output }] };
    }
  • Registration of the 'dk_electricity_prices' tool within the server instance.
    server.tool(
      "dk_electricity_prices",
      "Get current and upcoming Danish electricity spot prices (Elspot). Returns hourly prices for today and tomorrow (when available). Prices include the raw spot price, not taxes/tariffs.",
      {
        area: z.string().optional().describe("Price area: DK1 (western Denmark) or DK2 (eastern Denmark), or a city/region name. Default: both areas."),
        hours: z.number().optional().describe("Number of hours to return (default: 24, max: 168 for a full week)"),
      },
      async ({ area, hours = 24 }) => {
        const priceArea = area ? resolvePriceArea(area) : null;
        const filter = priceArea ? JSON.stringify({ PriceArea: priceArea }) : undefined;
        const limit = priceArea ? hours : hours * 2; // Both areas = 2x rows
    
        const data = await fetchDataset("Elspotprices", {
          limit,
          sort: "HourDK desc",
          filter,
          start: "now-P1D",
        });
    
        if (!data.records?.length) {
          return { content: [{ type: "text", text: "No price data available for the requested period." }] };
        }
    
        // Group by area
        const byArea = {};
        for (const r of data.records) {
          if (!byArea[r.PriceArea]) byArea[r.PriceArea] = [];
          byArea[r.PriceArea].push(r);
        }
    
        let output = "# Danish Electricity Spot Prices\n\n";
        for (const [areaCode, records] of Object.entries(byArea)) {
          output += `## ${areaCode} — ${PRICE_AREAS[areaCode] || areaCode}\n\n`;
    
          // Stats
          const prices = records.map(r => r.SpotPriceDKK).filter(p => p != null);
          if (prices.length) {
            const avg = prices.reduce((a, b) => a + b, 0) / prices.length;
            const min = Math.min(...prices);
            const max = Math.max(...prices);
            output += `**Average:** ${formatPrice(avg)}\n`;
            output += `**Range:** ${formatPrice(min)} — ${formatPrice(max)}\n\n`;
          }
    
          output += "| Time (DK) | Price |\n|---|---|\n";
          for (const r of records.slice(0, 48)) {
            const time = r.HourDK?.replace("T", " ").slice(0, 16) || "?";
            output += `| ${time} | ${formatPrice(r.SpotPriceDKK)} |\n`;
          }
          output += "\n";
        }
    
        output += "*Source: Energi Data Service (Energinet). Prices are spot prices excl. taxes, tariffs, and VAT.*\n";
    
        return { content: [{ type: "text", text: output }] };
      }
    );
  • Input schema definition for the 'dk_electricity_prices' tool using Zod.
    {
      area: z.string().optional().describe("Price area: DK1 (western Denmark) or DK2 (eastern Denmark), or a city/region name. Default: both areas."),
      hours: z.number().optional().describe("Number of hours to return (default: 24, max: 168 for a full week)"),
    },

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-nordic'

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