Skip to main content
Glama
spot-mcp-server

spot-mcp-server

by JussiSavola

spot-mcp-server

MCP server for Finnish electricity spot prices, powered by api.spot-hinta.fi.

Exposes real-time and forward-looking spot price data as MCP tools, making electricity prices available to AI agents and LLM-based automations without requiring them to call external APIs directly.

Background

Finnish electricity prices change every 15 minutes (96 slots per day). Knowing the current price rank and upcoming price windows is essential for smart home automations — pre-heating during cheap hours, deferring loads during expensive ones, and letting an AI agent reason about trade-offs between comfort and cost.

This server fills the gap: a lightweight MCP endpoint that any MCP-compatible AI client (Claude, etc.) can query to get structured, reasoned price data.

Related MCP server: tibber-mcp-server

Tools

Tool

Description

get_current_price

Current quarter-hour: rank, price with/without tax. Served from cache.

get_today_prices

All quarter-hour slots for today.

get_tomorrow_prices

All quarter-hour slots for tomorrow, if published (~14:15 Finnish time).

get_prices_for_hours(hour_from, hour_to)

Filtered time window with min/max/avg summary and cheapest/most expensive slot.

get_cheapest_remaining_slots(n)

Top N cheapest slots remaining today, sorted by price.

get_today_summary

Current price context: rank, assessment (very cheap → very expensive), position in today's range, tomorrow availability.

Prices are in EUR/kWh. Rank is a 1–96 percentile within today's prices (1 = cheapest quarter-hour, 96 = most expensive). Days may have 23, 24, or 25 slots per hour due to DST transitions.

Cache strategy

A single /TodayAndDayForward fetch populates all data. Prices are static once published; cache expires only when new data can appear:

  • Tomorrow's data present → expires at midnight after tomorrow

  • Only today's data, before 14:15 → expires at midnight tonight

  • Only today's data, after 14:15 → expires in 15 min (lazy poll until tomorrow is published)

Current price is derived from the cache by matching the current quarter-hour slot — no separate /JustNow call is made.

Requirements

  • Python 3.10+

  • fastmcp

  • httpx

  • tzdata

Installation

git clone https://github.com/JussiSavola/spot-mcp-server.git
cd spot-mcp-server
pip install -r requirements.txt

Running

python spot_hinta_mcp.py

Default port: 8765. Override with environment variable:

SPOT_HINTA_PORT=9000 python spot_hinta_mcp.py

MCP endpoint (Streamable HTTP transport):

http://localhost:8765/mcp

Or via run.sh:

bash run.sh

Connecting to Claude

Add to your Claude MCP configuration:

{
  "mcpServers": {
    "spot-hinta": {
      "type": "url",
      "url": "http://localhost:8765/mcp"
    }
  }
}

Tests

pip install pytest
pytest test_spot_hinta.py -v

Tests cover cache TTL logic, quarter-hour slot matching, DST transition handling, and data parsing. Network calls are mocked.

Data source

api.spot-hinta.fi — free Finnish electricity spot price API. Endpoint used: /TodayAndDayForward.

License

PolyForm Noncommercial 1.0.0. Personal, hobby, educational and research use, and use by noncommercial organizations, is permitted. Commercial use requires a separate license from the author: Jussi Savola, https://github.com/JussiSavola.

Versions up to and including commit e611c45 were published with "MIT" stated in this README; those versions remain available under MIT.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      A read-only MCP server that exposes European day-ahead electricity prices for ~41 bidding zones via tools like hourly prices, cheapest hours, current price, and cross-zone summary, enabling AI agents to query energy market data.
      1
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables querying Tibber electricity prices, forecasts, consumption data, cheapest hours, and live Pulse measurements through natural language.
      7
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Provides real-time electricity prices, cheapest hours, and contract comparison for 40+ countries, enabling AI agents to make energy-aware decisions.
      5
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents and assistants to query Polish electricity market data from the SENS Energy Data API by discovering operators and tariffs, fetching composite prices, and inspecting tariff components through natural language.
      4
      MIT