Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
# floor of requires-python, and every version the classifiers claim
python-version: ["3.10", "3.12", "3.13", "3.14"]
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6

Expand All @@ -30,7 +30,7 @@ jobs:
run: |
python -m pip install --upgrade pip
# [pscad] is psutil, which PSCAD/tests import. [surge] is surge-py,
# whose marker (>=3.12,<3.15) leaves it uninstalled on 3.10, where the
# whose marker (>=3.12,<3.15) leaves it uninstalled on 3.11, where the
# suite skips itself.
python -m pip install -e ".[pscad,surge]" pytest

Expand Down
2 changes: 1 addition & 1 deletion ANDES/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MCP server for ANDES (Python-based power system dynamic analysis), enabling powe

## Requirements

- Python 3.10 or higher
- Python 3.11 or higher
- [ANDES](https://andes.readthedocs.io/)

Install dependencies:
Expand Down
2 changes: 1 addition & 1 deletion ANDES/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
andes
mcp>=2,<3
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13
2 changes: 1 addition & 1 deletion Egret/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MCP server for Egret power system optimization, enabling unit commitment, AC OPF

## Requirements

- Python 3.10 or higher
- Python 3.11 or higher
- [Egret](https://github.com/grid-parity-exchange/Egret)
- Gurobi or ipopt solver for different tasks

Expand Down
2 changes: 1 addition & 1 deletion Egret/egret_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# MATPOWER marks an unlimited branch with rateA/B/C = 0. Egret's own parser
# stores that as None, which its models read as "no thermal limit", but they
# index these keys directly, so a converter that leaves them out (powerio 0.11.5
# does) fails with KeyError: 'rating_long_term'.
# through 0.12.1 do) fails with KeyError: 'rating_long_term'.
_BRANCH_RATING_KEYS = ("rating_long_term", "rating_short_term", "rating_emergency")


Expand Down
2 changes: 1 addition & 1 deletion Egret/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gridx-egret
pyomo
mcp>=2,<3
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13
2 changes: 1 addition & 1 deletion GenX/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Below is the computation calling this skill executes.

## Setup

Requires Python ≥ 3.10 and (for submission) a SLURM cluster with `sbatch` on
Requires Python ≥ 3.11 and (for submission) a SLURM cluster with `sbatch` on
`PATH` plus a local GenX.jl checkout. GenX itself is Julia; this connector
reads the CSVs a completed run produces and submits new ones.

Expand Down
2 changes: 1 addition & 1 deletion GenX/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# `pip install "powermcp[genx]"` covers the same ground.
mcp>=2,<3
# GenX/server.py imports powermcp.sandbox, which re-exports powerio's path policy.
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13
pandas>=2.0,<3
matplotlib>=3.7
2 changes: 1 addition & 1 deletion LTSpice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MCP server for LTSpice electronic circuit simulation, enabling automated netlist

## Requirements

- Python 3.10 or higher
- Python 3.11 or higher
- [PyLTSpice](https://github.com/nunobrum/LTSpice)
- LTSpice installed on your system (or via Wine on macOS/Linux)

Expand Down
2 changes: 1 addition & 1 deletion LTSpice/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Core MCP dependencies
mcp>=2,<3
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13

# Circuit simulation dependencies
matplotlib
Expand Down
2 changes: 1 addition & 1 deletion OpenDSS/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MCP server for OpenDSS distribution studies using `py_dss_toolkit` and `py_dss_i

## Requirements

- Python 3.10 or higher
- Python 3.11 or higher
- Install from the **PowerMCP** repository root so the editable path resolves:

```bash
Expand Down
2 changes: 1 addition & 1 deletion OpenDSS/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
py_dss_toolkit
mcp>=2,<3
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13
2 changes: 1 addition & 1 deletion PSCAD/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A professional, robust Model Context Protocol (MCP) server for **Power System Co
### 1. Prerequisites
- **Windows OS**: Required for local PSCAD automation (RMI).
- **PSCAD Installed**: Ensure PSCAD and its Python libraries are available on your system.
- **Python 3.10+**: Recommended for best compatibility.
- **Python 3.11+**: Recommended for best compatibility.

### 2. Automated Setup
The easiest way to get started is by running the automated installer:
Expand Down
4 changes: 2 additions & 2 deletions PSCAD/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ name = "pscad-mcp"
version = "0.1.0"
description = "A professional, robust MCP server for PSCAD."
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.11"
license = {text = "MIT"}
authors = [
{name = "LL0pez20", email = "luansantos@poli.ufrj.br"}
]
dependencies = [
"mcp>=2,<3",
"powerio[mcp,matrix]>=0.11.2,<0.12",
"powerio[mcp,matrix]>=0.12.1,<0.13",
"psutil"
]

Expand Down
2 changes: 1 addition & 1 deletion PSLF/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MCP server for PSLF (GE Positive Sequence Load Flow), enabling case management,

## Requirements

- Python 3.10 or higher
- Python 3.11 or higher
- PSLF with PSLF_PYTHON API
- [pandas](https://pandas.pydata.org/)

Expand Down
2 changes: 1 addition & 1 deletion PSLF/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pandas
mcp>=2,<3
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13
2 changes: 1 addition & 1 deletion PSSE/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MCP server for PSS/E (Siemens PTI) power system analysis. Supports PSSE 35+ with

## Requirements

- Python 3.10 or higher
- Python 3.11 or higher
- PSSE 35+ installed with Python API (PSSPY)
- [mcp](https://pypi.org/project/mcp/)

Expand Down
2 changes: 1 addition & 1 deletion PSSE/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mcp>=2,<3
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13
2 changes: 1 addition & 1 deletion PowerFactory/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MCP Python SDK 2 server framework
mcp>=2,<3
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13

# Scientific stack
numpy>=1.26
Expand Down
2 changes: 1 addition & 1 deletion PowerWorld/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MCP server for PowerWorld Simulator via Easy SimAuto (ESA), enabling power flow

## Requirements

- Python 3.10 or higher
- Python 3.11 or higher
- [Easy SimAuto (ESA)](https://github.com/mzy2240/ESA)

Install dependencies:
Expand Down
2 changes: 1 addition & 1 deletion PowerWorld/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
esa
numba
mcp>=2,<3
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13
2 changes: 1 addition & 1 deletion PyPSA/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A comprehensive Model Context Protocol (MCP) server for PyPSA (Python for Power
## Requirements

- [PyPSA](https://pypsa.org/) >= 0.35.2 and < 2
- Python 3.10 or higher
- Python 3.11 or higher
- MCP Python SDK 2.x
- At least one LP solver supported by PyPSA:
- **Open Source**: HiGHS (recommended), CBC, GLPK
Expand Down
34 changes: 22 additions & 12 deletions PyPSA/pypsa_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ def _optimize(network: Network, **kwargs):
return network.optimize(**kwargs)


def _line_loading_pct(network: Network):
"""Loading of each line in the first snapshot, as a percentage of the
bound PyPSA enforces, ``s_nom * s_max_pu``.

powerio >= 0.12 writes an unlimited branch as a positive placeholder
``s_nom`` with ``s_max_pu = inf``, so ``s_nom`` alone is not a limit. A line
with no bound, or with a zero bound, reads 0 %.
"""
flow = np.sqrt(network.lines_t.p0.iloc[0] ** 2 + network.lines_t.q0.iloc[0] ** 2)
s_max_pu = network.get_switchable_as_dense("Line", "s_max_pu").iloc[0]
loading = flow / (network.lines.s_nom * s_max_pu) * 100
return loading.replace([np.inf, -np.inf], np.nan).fillna(0.0)


# ============= Network Information =============

@mcp.tool()
Expand Down Expand Up @@ -175,11 +189,7 @@ def run_contingency_analysis(
network.pf(use_seed=True)

base_v = network.buses_t.v_mag_pu.iloc[0]
base_p0 = network.lines_t.p0.iloc[0]
base_q0 = network.lines_t.q0.iloc[0]
base_s_nom = network.lines.s_nom
base_loading = np.sqrt(base_p0**2 + base_q0**2) / base_s_nom * 100
base_loading = base_loading.replace([np.inf, -np.inf], np.nan).fillna(0.0)
base_loading = _line_loading_pct(network)

base_case = {
"converged": True,
Expand Down Expand Up @@ -248,11 +258,7 @@ def run_contingency_analysis(
voltage_violations.append({"bus": bus, "vm_pu": round(v, 4)})

# Check thermal violations
p0 = n.lines_t.p0.iloc[0]
q0 = n.lines_t.q0.iloc[0]
s_nom = n.lines.s_nom
loading = np.sqrt(p0**2 + q0**2) / s_nom * 100
loading = loading.replace([np.inf, -np.inf], np.nan).fillna(0.0)
loading = _line_loading_pct(n)

loading_violations = []
for line_id_inner in loading.index:
Expand Down Expand Up @@ -820,7 +826,9 @@ def import_case_from_any(
source_format: Input format name (matpower, powermodels-json,
egret-json, psse, powerworld); inferred from the file extension
when omitted
overwrite_zero_s_nom: Replacement s_nom for branches with rating 0
overwrite_zero_s_nom: Replacement s_nom for branches whose thermal
bound is zero. An unlimited branch (MATPOWER rate 0, an absent
Egret rating) arrives unbounded, with s_max_pu = inf, and is kept
operating_point: Compatibility alias for time_index
study_commit: Retired package selector; export a Tellegen Study state as IR
time_index: Explicit TimeSeries index
Expand Down Expand Up @@ -906,7 +914,9 @@ def import_case_from_json(
Args:
network_json: The JSON transport string from powerio
output_path: Where to save the imported network (.nc)
overwrite_zero_s_nom: Replacement s_nom for branches with rating 0
overwrite_zero_s_nom: Replacement s_nom for branches whose thermal
bound is zero. An unlimited branch (MATPOWER rate 0, an absent
Egret rating) arrives unbounded, with s_max_pu = inf, and is kept
operating_point: Compatibility alias for time_index
study_commit: Retired package selector; export a Tellegen Study state as IR
time_index: Explicit TimeSeries index
Expand Down
2 changes: 1 addition & 1 deletion PyPSA/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pypsa>=0.35.2,<2
numpy>=1.24.0
pandas>=2.0.0
mcp>=2,<3
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![PyPI](https://img.shields.io/pypi/v/powermcp.svg)](https://pypi.org/project/powermcp/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python Version](https://img.shields.io/badge/python-3.10%20to%203.14-blue.svg)](https://www.python.org/downloads/)
[![Python Version](https://img.shields.io/badge/python-3.11%20to%203.14-blue.svg)](https://www.python.org/downloads/)

PowerMCP is an open-source collection of MCP servers for power system software such as PSS/E, PowerWorld, PowerFactory, PSLF, PSCAD, OpenDSS, pandapower, and PyPSA. These tools enable LLMs to directly interact with power system applications, facilitating intelligent coordination, simulation, and control in the energy domain.

Expand Down Expand Up @@ -99,7 +99,7 @@ After it finishes, restart your MCP client (start a new Claude Code or Codex ses

### Install it yourself

PowerMCP installs as a single Python package with an interactive CLI. Python 3.10 through 3.14 is supported.
PowerMCP installs as a single Python package with an interactive CLI. Python 3.11 through 3.14 is supported.

```bash
pip install powermcp
Expand Down Expand Up @@ -185,12 +185,14 @@ These tools wrap commercial or locally-installed software, so PowerMCP stores th
### Case compilation between servers (PowerIO)

PowerIO IR is the exchange format of this repository. PowerMCP runs the
server shipped in PowerIO 0.11.2 (`powermcp run powerio` is `python -m
server shipped in PowerIO 0.12 (`powermcp run powerio` is `python -m
powerio.mcp`); that server parses every grid exchange format, emits every
target, summarizes, diagnoses, normalizes, lowers multiconductor networks, and
calculates matrices. Its `parse` tool returns serialized **PowerIO IR
generation 2** (`"schema": "pio-ir"`, `"version": 2`), a typed module carrying
the electrical value, its provenance and its diagnostics. Every other server
calculates matrices. Its `parse` tool returns serialized **PowerIO IR**
(`"schema": "pio-ir"`, with `"version"` naming the PowerIO release that wrote
it, such as `"0.12.1"`; documents from PowerIO 0.11 state `2` and still
read), a typed module carrying the electrical value, its provenance and its
diagnostics. Every other server
here consumes that document: the pandapower, PyPSA, ANDES and Egret adapters
turn it into their own model with PowerIO's writers. PowerMCP itself never
re-parses, re-validates, or recomputes what PowerIO states; it routes a
Expand Down
2 changes: 1 addition & 1 deletion llms-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ python3 --version # macOS / Linux
py -0p # Windows: lists every installed Python
```

- Python **3.10 to 3.14** is supported. Prefer **3.12 or 3.13**, which every extra
- Python **3.11 to 3.14** is supported. Prefer **3.12 or 3.13**, which every extra
supports (`surge` needs 3.12 to 3.14; PLEXOSDB's `r2x` dependencies need 3.11
to 3.13).
- **PSS/E and PowerFactory load a vendor Python module built for one Python version.**
Expand Down
2 changes: 1 addition & 1 deletion pandapower/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MCP server for pandapower transmission system analysis, enabling network creatio

## Requirements

- Python 3.10 or higher
- Python 3.11 or higher
- [pandapower](https://github.com/e2nIEE/pandapower)

Install dependencies:
Expand Down
2 changes: 1 addition & 1 deletion pandapower/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pandapower
mcp>=2,<3
powerio[mcp,matrix]>=0.11.2,<0.12
powerio[mcp,matrix]>=0.12.1,<0.13
2 changes: 1 addition & 1 deletion powermcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This guide shows how to **install** and **test** the packaged version.

## 1. Install (as a user)

Requires **Python 3.10 through 3.14**.
Requires **Python 3.11 through 3.14**.

```bash
pip install powermcp
Expand Down
5 changes: 1 addition & 4 deletions powermcp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
from pathlib import Path
from typing import Any

try: # Python 3.11+
import tomllib
except ModuleNotFoundError: # Python 3.10
import tomli as tomllib # type: ignore[no-redef]
import tomllib

import tomli_w

Expand Down
17 changes: 6 additions & 11 deletions powermcp/solver_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

_IR_FORMATS = frozenset({"pio-ir", "pio"})
IR_SCHEMA = "pio-ir"
IR_VERSION = 2


_QUIET_SEVERITIES = frozenset({"remark", "note"})
Expand Down Expand Up @@ -85,15 +84,9 @@ def diagnostic_records(items: Any) -> list[dict[str, Any]]:


def value_type_name(module: powerio.PioModule) -> str:
"""The PowerIO structural type of a module's value.

powerio 0.11.2 publishes no accessor for it; its own MCP server reads the
same private attribute in `_canonical_type`. Isolating it here makes a
future public accessor a one-line change.
"""
inner = getattr(module, "_inner", None)
name = getattr(inner, "_type_name", None)
return str(name) if name else f"powerio.{type(module.value).__name__}"
"""The PowerIO structural type of a module's value, such as
``powerio.BalancedNetwork`` (``PioModule.type_name``, public since 0.12)."""
return module.type_name


def check_diagnostics(items: Any) -> None:
Expand Down Expand Up @@ -428,7 +421,9 @@ def resolve_solver_case(

``powerio_ir`` is the serialized module the powerio server's ``parse``,
``to_normalized`` or ``to_balanced`` tools return; ``network_json`` is its
compatibility alias and must carry the same generation-2 document.
compatibility alias and must carry the same document. IR is recognized by
its ``"schema": "pio-ir"`` header alone; powerio decides which header
versions it reads (0.12 reads its own release series and 0.11's ``2``).
``operating_point`` is a compatibility spelling for ``time_index``. Study
history belongs to Tellegen; legacy package commits require migration.
``edits`` are typed updates applied before validation; ``to_balanced``
Expand Down
5 changes: 1 addition & 4 deletions powermcp/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ def _existing_managed_tools(client_names: list[str]) -> set[str]:
keys: list[str] = []
try:
if name == "codex":
try:
import tomllib
except ModuleNotFoundError: # py3.10
import tomli as tomllib # type: ignore
import tomllib
keys = list((tomllib.loads(text).get("mcp_servers") or {}).keys())
else:
import json
Expand Down
Loading
Loading