Skip to main content
Glama
robobobby

mcp-danish-energy

by robobobby

cheapest_hours

Identify the most cost-effective hours for electricity usage in Denmark to schedule energy-intensive tasks like EV charging or appliance operation based on spot prices.

Instructions

Find the cheapest hours to use electricity today/tomorrow. Useful for scheduling EV charging, laundry, dishwasher, heat pumps, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
areaYesPrice area: DK1 or DK2, or a city/region name.
countNoNumber of cheapest hours to return (default: 5)
consecutiveNoIf true, find the cheapest consecutive block of 'count' hours (default: false)

Implementation Reference

  • Handler function for 'cheapest_hours' tool - implements the core logic to fetch electricity spot prices and find the cheapest hours (either individual or consecutive blocks). Fetches data from Elspotprices dataset, filters by price area, and returns either the N cheapest hours or the cheapest consecutive block of hours.
    async ({ area, count = 5, consecutive = false }) => {
      const priceArea = resolvePriceArea(area);
      if (!priceArea) {
        return { content: [{ type: "text", text: "Could not determine price area. Use DK1 (western Denmark) or DK2 (eastern Denmark), or a city name." }] };
      }
    
      const data = await fetchDataset("Elspotprices", {
        limit: 48,
        sort: "HourDK asc",
        filter: JSON.stringify({ PriceArea: priceArea }),
        start: "now-PT1H",
      });
    
      if (!data.records?.length) {
        return { content: [{ type: "text", text: "No price data available." }] };
      }
    
      const records = data.records.filter(r => r.SpotPriceDKK != null);
    
      let output = `# Cheapest Hours — ${priceArea} (${PRICE_AREAS[priceArea]})\n\n`;
    
      if (consecutive && count > 1) {
        // Find cheapest consecutive block
        let bestStart = 0;
        let bestAvg = Infinity;
        for (let i = 0; i <= records.length - count; i++) {
          const block = records.slice(i, i + count);
          const avg = block.reduce((s, r) => s + r.SpotPriceDKK, 0) / count;
          if (avg < bestAvg) {
            bestAvg = avg;
            bestStart = i;
          }
        }
    
        const block = records.slice(bestStart, bestStart + count);
        output += `**Best ${count}-hour block:**\n`;
        output += `**Start:** ${block[0].HourDK?.replace("T", " ").slice(0, 16)}\n`;
        output += `**End:** ${block[block.length - 1].HourDK?.replace("T", " ").slice(0, 16)} + 1h\n`;
        output += `**Average price:** ${formatPrice(bestAvg)}\n\n`;
    
        output += "| Hour | Price |\n|---|---|\n";
        for (const r of block) {
          output += `| ${r.HourDK?.replace("T", " ").slice(0, 16)} | ${formatPrice(r.SpotPriceDKK)} |\n`;
        }
      } else {
        // Find N cheapest individual hours
        const sorted = [...records].sort((a, b) => a.SpotPriceDKK - b.SpotPriceDKK);
        const cheapest = sorted.slice(0, count);
    
        output += `**${count} cheapest hours:**\n\n`;
        output += "| Rank | Hour | Price |\n|---|---|---|\n";
        for (let i = 0; i < cheapest.length; i++) {
          const r = cheapest[i];
          output += `| ${i + 1} | ${r.HourDK?.replace("T", " ").slice(0, 16)} | ${formatPrice(r.SpotPriceDKK)} |\n`;
        }
      }
    
      output += "\n*Prices are spot prices excl. taxes, tariffs, and VAT. Source: Energi Data Service.*\n";
      return { content: [{ type: "text", text: output }] };
    }
  • Input schema definition for 'cheapest_hours' tool using Zod. Defines three parameters: 'area' (required string for price area), 'count' (optional number, default 5), and 'consecutive' (optional boolean, default false) to determine whether to find individual hours or a consecutive block.
    {
      area: z.string().describe("Price area: DK1 or DK2, or a city/region name."),
      count: z.number().optional().describe("Number of cheapest hours to return (default: 5)"),
      consecutive: z.boolean().optional().describe("If true, find the cheapest consecutive block of 'count' hours (default: false)"),
    },
  • src/index.js:238-306 (registration)
    Registration of 'cheapest_hours' tool with the MCP server using server.tool(). Includes the tool name, description ('Find the cheapest hours to use electricity today/tomorrow. Useful for scheduling EV charging, laundry, dishwasher, heat pumps, etc.'), input schema, and handler function.
    server.tool(
      "cheapest_hours",
      "Find the cheapest hours to use electricity today/tomorrow. Useful for scheduling EV charging, laundry, dishwasher, heat pumps, etc.",
      {
        area: z.string().describe("Price area: DK1 or DK2, or a city/region name."),
        count: z.number().optional().describe("Number of cheapest hours to return (default: 5)"),
        consecutive: z.boolean().optional().describe("If true, find the cheapest consecutive block of 'count' hours (default: false)"),
      },
      async ({ area, count = 5, consecutive = false }) => {
        const priceArea = resolvePriceArea(area);
        if (!priceArea) {
          return { content: [{ type: "text", text: "Could not determine price area. Use DK1 (western Denmark) or DK2 (eastern Denmark), or a city name." }] };
        }
    
        const data = await fetchDataset("Elspotprices", {
          limit: 48,
          sort: "HourDK asc",
          filter: JSON.stringify({ PriceArea: priceArea }),
          start: "now-PT1H",
        });
    
        if (!data.records?.length) {
          return { content: [{ type: "text", text: "No price data available." }] };
        }
    
        const records = data.records.filter(r => r.SpotPriceDKK != null);
    
        let output = `# Cheapest Hours — ${priceArea} (${PRICE_AREAS[priceArea]})\n\n`;
    
        if (consecutive && count > 1) {
          // Find cheapest consecutive block
          let bestStart = 0;
          let bestAvg = Infinity;
          for (let i = 0; i <= records.length - count; i++) {
            const block = records.slice(i, i + count);
            const avg = block.reduce((s, r) => s + r.SpotPriceDKK, 0) / count;
            if (avg < bestAvg) {
              bestAvg = avg;
              bestStart = i;
            }
          }
    
          const block = records.slice(bestStart, bestStart + count);
          output += `**Best ${count}-hour block:**\n`;
          output += `**Start:** ${block[0].HourDK?.replace("T", " ").slice(0, 16)}\n`;
          output += `**End:** ${block[block.length - 1].HourDK?.replace("T", " ").slice(0, 16)} + 1h\n`;
          output += `**Average price:** ${formatPrice(bestAvg)}\n\n`;
    
          output += "| Hour | Price |\n|---|---|\n";
          for (const r of block) {
            output += `| ${r.HourDK?.replace("T", " ").slice(0, 16)} | ${formatPrice(r.SpotPriceDKK)} |\n`;
          }
        } else {
          // Find N cheapest individual hours
          const sorted = [...records].sort((a, b) => a.SpotPriceDKK - b.SpotPriceDKK);
          const cheapest = sorted.slice(0, count);
    
          output += `**${count} cheapest hours:**\n\n`;
          output += "| Rank | Hour | Price |\n|---|---|---|\n";
          for (let i = 0; i < cheapest.length; i++) {
            const r = cheapest[i];
            output += `| ${i + 1} | ${r.HourDK?.replace("T", " ").slice(0, 16)} | ${formatPrice(r.SpotPriceDKK)} |\n`;
          }
        }
    
        output += "\n*Prices are spot prices excl. taxes, tariffs, and VAT. Source: Energi Data Service.*\n";
        return { content: [{ type: "text", text: output }] };
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool finds cheapest hours but does not disclose critical traits like data source, update frequency, accuracy, rate limits, authentication needs, or error handling. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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 appropriately sized and front-loaded, with two concise sentences that directly state the purpose and provide useful examples. Every sentence earns its place without redundancy or unnecessary details.

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

Completeness2/5

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

Given the complexity of electricity pricing data and the lack of annotations and output schema, the description is incomplete. It does not explain what the tool returns (e.g., list of hours, prices), data freshness, or limitations, which are essential for an agent to use it effectively in scheduling decisions.

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%, so the schema already documents all parameters (area, count, consecutive). The description does not add any additional meaning or context beyond what the schema provides, such as explaining how 'area' affects results or the implications of 'consecutive'. Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool's purpose with a specific verb ('Find') and resource ('cheapest hours to use electricity'), and it distinguishes from siblings by focusing on cost optimization rather than emissions, prices, or energy mix. The examples (EV charging, laundry, etc.) further clarify the use case.

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 for when to use this tool ('today/tomorrow' and for scheduling appliances), but it does not explicitly state when not to use it or name alternatives among the sibling tools. It implies usage for cost-saving scenarios but lacks explicit exclusions.

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