dk_co2_emissions
Check real-time CO2 emissions from Danish electricity production to schedule energy-intensive tasks during low-carbon periods. Provides emission intensity data for specific areas with historical tracking.
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
| Name | Required | Description | Default |
|---|---|---|---|
| area | No | Price area: DK1 or DK2, or a city/region name. Default: both areas. | |
| hours | No | Hours of history to return (default: 1, max: 24) |
Implementation Reference
- src/servers/danish-energy.js:107-157 (handler)The 'dk_co2_emissions' tool handler is registered using 'server.tool'. It fetches CO2 emission data from the Energi Data Service API and formats it into a summary report.
server.tool( "dk_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 }] }; } );