Skip to main content
Glama
power-market-tutor

power-market-tutor

Power Market Tutor (power-market-tutor)

An interactive Electricity Market Clearing & Settlement Sandbox built for AI-assisted learning. It provides a zero-dependency MCP Server, a Python CLI / library, and a portable Agent Skill compatible with Qoder, Antigravity, Claude Code, and Cursor.

电力市场交互式学习沙盒与 AI 助教工具包:内置确定性的 统一边际出清(SMP)、2 节点 / 3 节点直流潮流与节点边际电价(LMP & PTDF 阻塞分析) 以及 国内电力现货市场“中长期差价合约(CfD)+ 日前 + 实时”偏差结算 计算引擎,彻底消除大模型在电价出清与电费结算推导中的算术幻觉。


Features / 核心功能

  • Uniform Marginal Clearing (simulate_smp_clearing): Merit-order dispatch stack, marginal unit identification, inframarginal generator rent, and comparison with Pay-as-Bid.

  • 2-Bus Radial LMP (simulate_two_bus_lmp): Exact decomposition of $\text{LMP} = \text{LMP}{\text{energy}} + \text{LMP}{\text{congestion}}$, shadow prices, and Congestion Rent ($\text{Rent} = \Delta \text{LMP} \times F_{AB}$).

  • 3-Bus Kirchhoff Loop LMP (simulate_three_bus_loop_lmp): Power Transfer Distribution Factor (PTDF) loop-flow model demonstrating why nodal prices can counter-intuitively exceed the highest generator bid in the system.

  • Chinese Spot Market CfD Dual/Triple Settlement (calculate_cfd_spot_settlement): Full breakdown of Mid-to-Long-Term contract settlement + Day-Ahead deviation + Real-Time deviation, alongside dispatch incentive analysis.

  • Portable Agent Skill (skills/electricity-market-tutor/SKILL.md): Drop-in domain tutor prompt rules ensuring AI assistants distinguish PJM/ISO theory from Chinese provincial spot market rules.


Related MCP server: embedcalc-mcp

Quick Start / 快速上手

1. Install Locally

pip install -e .

2. Run Benchmark CLI Cases

# 1) 5-generator Merit-Order SMP Clearing
pmt smp --demand 420

# 2) 2-Bus Radial Congestion & LMP
pmt lmp2 --load 300 --limit 120

# 3) 3-Bus Kirchhoff Loop Flow (Counter-Intuitive High LMP!)
pmt lmp3 --load 300 --limit 120

# 4) CfD + Spot Dual Settlement
pmt settle --qc 300 --pc 380 --qs 200 --ps 150 --cost 300

3. Configure MCP Server (Qoder / Claude / Cursor / Antigravity)

Add to your IDE's MCP configuration JSON:

{
  "mcpServers": {
    "power-market-tutor": {
      "command": "python",
      "args": ["-m", "power_market_tutor.mcp_server"]
    }
  }
}

4. Run Tests

python -m unittest discover -s tests -v

License

MIT © cyc-dacaigouzi

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
      MCP server providing embedded engineering calculators and code generators as tools for AI agents, enabling precise, deterministic embedded math and C code generation.
      29
      74 npm
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to compute exact pump.fun bonding-curve state, buy and sell quotes, dev-buy plans, and seeded launch simulations through MCP tools.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables computing weighted orderbook imbalance, micro-price, and market-order VWAP execution slippage, alongside concentrated liquidity optimization, negative-cycle triangular arbitrage detection, and Bayesian Black-Litterman portfolio rebalancing, through standard MCP tool calls.
      7
      MIT