Skip to main content
Glama
Paszymaja

elicznik-mcp

by Paszymaja

elicznik-tauron

非官方的 CLI 和 MCP 服务器,用于 Tauron eLicznik 门户 (https://elicznik.tauron-dystrybucja.pl)。通过命令行获取用电量、发电量和电表读数,或通过 Model Context Protocol 将其暴露给 AI 智能体。

与 Tauron 无关联。使用门户所用的同一个内部 Web API。

功能

  • 登录:通过 Keycloak 表单 POST 完成(无需浏览器);会话 Cookie 缓存到磁盘并自动刷新。

  • CLI(elicznik):列出计量点、获取能耗数据和登记读数。

  • MCP 服务器(elicznik-mcp,stdio):以工具形式向 OpenCode 或 Claude 等 MCP 客户端公开相同的数据。

可用数据:

数据

粒度

用电量 / 发电量 / 净

小时、天、月、年

每小时费率区(zone)

小时

累计电表读数

天

Related MCP server: Enapter MCP Server

环境要求

Python 3.10+ 和 uv。

设置

uv sync --extra mcp
cp .env.example .env   # then fill in your credentials

.env:

ELICZNIK_USERNAME=your-login-or-email
ELICZNIK_PASSWORD=your-password
# Optional: pick a specific metering point if you have more than one
# ELICZNIK_SITE=5842033_61898031_5842033

会话 Cookie 缓存到 elicznik_session.json(已被 git 忽略),因此只需登录一次;当会话过期时,客户端会自动重新认证。

CLI

# List metering points
uv run elicznik meters

# Hourly consumption for a day (defaults: today, metric=consumption, resolution=hour)
uv run elicznik energy --metric consumption --from 2026-08-24 --to 2026-08-24

# Daily / monthly / yearly totals
uv run elicznik energy --metric consumption --resolution day   --from 2026-08-01 --to 2026-08-26
uv run elicznik energy --metric consumption --resolution month --from 2026-01-01 --to 2026-08-26
uv run elicznik energy --metric generation  --resolution year  --from 2026-01-01 --to 2026-08-26

# Output formats: table (default), csv, json
uv run elicznik energy --metric consumption --resolution day --from 2026-08-01 --to 2026-08-26 --format json

# Cumulative meter register readings (billing readings)
uv run elicznik readings --from 2026-08-01 --to 2026-08-26
uv run elicznik readings --from 2026-08-01 --to 2026-08-26 --generation   # returned energy

指标:consumption、generation、net_consumption、net_generation。

MCP 服务器

该服务器提供四个工具:

  • list_meters — 列出计量点

  • get_energy(metric, start_date, end_date, resolution) — 获取单个指标,包含总计和每个计量点的值

  • get_readings(start_date, end_date, resolution) — 获取每个计量点的全部四个指标

  • get_meter_readings(start_date, end_date, generation) — 获取累计电表读数

OpenCode

添加到 ~/.config/opencode/opencode.json:

{
  "mcp": {
    "elicznik": {
      "type": "local",
      "command": ["uv", "run", "--directory", "/home/paszymaja/github_projects/elicznik-tauron", "elicznik-mcp"],
      "enabled": true
    }
  }
}

Claude for Desktop

添加到 claude_desktop_config.json:

{
  "mcpServers": {
    "elicznik": {
      "command": "uv",
      "args": ["--directory", "/ABSOLUTE/PATH/TO/elicznik-tauron", "run", "elicznik-mcp"]
    }
  }
}

服务器从项目目录中的 .env 读取凭据(或从 ELICZNIK_USERNAME / ELICZNIK_PASSWORD 环境变量读取)。

Docker

容器镜像已发布到 GitHub Container Registry(ghcr.io/paszymaja/elicznik-tauron)。凭据从 ELICZNIK_USERNAME / ELICZNIK_PASSWORD 环境变量读取(无需 .env);会话缓存写入 /tmp(临时)。

# CLI
docker run --rm \
  -e ELICZNIK_USERNAME -e ELICZNIK_PASSWORD \
  ghcr.io/paszymaja/elicznik-tauron:latest meters

docker run --rm \
  -e ELICZNIK_USERNAME -e ELICZNIK_PASSWORD \
  ghcr.io/paszymaja/elicznik-tauron:latest \
  energy --metric consumption --resolution day --from 2026-08-01 --to 2026-08-26

# MCP server over stdio (note the -i flag for stdin)
docker run -i --rm \
  -e ELICZNIK_USERNAME -e ELICZNIK_PASSWORD \
  ghcr.io/paszymaja/elicznik-tauron:latest mcp

要在本地构建镜像:

docker build -t elicznik-tauron .

开发

uv sync --extra mcp
uv run pytest

备注

  • 门户的 TLS 服务器协商的密码套件会被 Python 默认的 OpenSSL 策略拒绝;客户端挂载了一个 DEFAULT@SECLEVEL=1 适配器作为变通方案(见 session.py)。

  • 逐小时 CSV 时间戳标记的是结束小时;客户端会将它们规范化为与图表 API 约定一致的整点开始时间戳。

  • 时间戳使用本地时区(Europe/Warsaw),不含时区偏移。

许可证

MIT

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides AI agents and LLMs access to the Nikola TEST MCP API through standardized MCP tools for seamless integration and interaction.
    -
  • 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
    -