From 01f45fafa7689b39a4855a694e6faa8b0279a90a Mon Sep 17 00:00:00 2001 From: Qian Zhang Date: Wed, 11 Nov 2026 11:14:01 -0500 Subject: [PATCH 1/2] Add an AI-agent install guide and refresh the README Add llms-install.md, a step-by-step guide for AI coding agents (Claude Code, Codex, Cursor, Cline) to install PowerMCP: check the platform and Python, create a persistent venv, install the right extras, store vendor software paths, write the MCP client config, and verify with `powermcp doctor`. It covers the installer's non-TTY behaviour (no pip step or path prompts), why `--yes` fails in uv venvs, and that `--tools` prunes powermcp_* entries for tools left out of the list. README: - open the Installation section with a copy-paste agent prompt that points at llms-install.md, and link it from the intro and Quick start - add a supported-tools table (tool id, pip extra, platform, notes) - quote extras in pip commands for zsh; add the `windows` extra - document `doctor [tool]`, `--version`, `--clients` values, the PLEXOSDB install note, and the absolute-interpreter client entries - add the feature-release, Grid Impact Evaluation and PowerSkills demos - update the Core Team from poweragent.seas.harvard.edu and point the Contributing link at the new site and Slack community Co-Authored-By: Claude Opus 5.5 --- README.md | 91 ++++++++++++++--- llms-install.md | 266 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 342 insertions(+), 15 deletions(-) create mode 100644 llms-install.md diff --git a/README.md b/README.md index 6614542a..af8983f9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,14 @@ # PowerMCP ⚑ +[![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/) -PowerMCP is an open-source collection of MCP servers for power system software like PowerWorld and OpenDSS. These tools enable LLMs to directly interact with power system applications, facilitating intelligent coordination, simulation, and control in the energy domain. +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. + +PowerMCP is part of [PowerAgent](https://poweragent.seas.harvard.edu/), an open-source community for agentic AI in power systems, maintained by the Power and AI Initiative (PAI) at Harvard SEAS. + +> **Install with your AI agent:** paste [this prompt](#-install-with-an-ai-agent-recommended) into Claude Code, Codex, or another coding agent and it will install and configure PowerMCP for you. ## 🌟 What is MCP? @@ -29,7 +34,7 @@ We're building an open-source community focused on accelerating AI adoption in t > **πŸš€ New to PowerMCP? Start here!** -The recommended way to get started is the `powermcp` package and its installer (see the **Installation** section below): +The recommended way to get started is the `powermcp` package and its installer. Either let an AI coding agent do it ([copy the prompt](#-install-with-an-ai-agent-recommended)), or run it yourself (see the **Installation** section below): ```bash pip install powermcp @@ -43,6 +48,12 @@ powermcp install # pick tools, capture local paths, write your MCP client Check out these demos showcasing PowerMCP in action: +- [**PowerMCP New Feature Release**](https://www.youtube.com/watch?v=xwTcNZLmIW8): pip install, automatic setup with `powermcp install`, and PowerIO integration. + +- [**Grid Impact Evaluation Demo**](https://www.youtube.com/watch?v=LxF8RqsNf04): Agentic AI streamlines the grid impact evaluation of large loads such as data centers, automating the analysis and report generation. + +- [**PowerSkills + PowerMCP Demo**](https://www.youtube.com/watch?v=bxZu47f6fUE): [PowerSkills](https://github.com/Power-Agent/PowerSkills) and PowerMCP together give AI agents the domain knowledge and structured instructions for simulation, analysis, and optimization across industry software tools, with reports in an industry-standard format. + - [**Contingency Evaluation Demo**](https://www.youtube.com/watch?v=MbF-SlBI4Ws): An LLM automatically operates power system software, such as PowerWorld and pandapower, to perform contingency analysis and generate professional reports. - [**Loadgrowth Evaluation Demo**](https://www.youtube.com/watch?v=euFUvhhV5dM): An LLM automatically operates power system software, such as PowerWorld, to evaluate different load growth scenarios and generate professional reports with recommendations. @@ -66,28 +77,72 @@ Check out these helpful tutorials to get started with MCP: ## πŸ“¦ Installation +### πŸ€– Install with an AI agent (recommended) + +More and more people install PowerMCP by asking an AI coding agent such as **Claude Code**, **Codex**, Cursor, or Cline to do it. Open the agent in a terminal on the machine where your power-system software lives, then paste this prompt and fill in the two lists: + +```text +Install and configure PowerMCP (https://github.com/Power-Agent/PowerMCP) on this computer. +Follow the agent guide step by step: +https://raw.githubusercontent.com/Power-Agent/PowerMCP/main/llms-install.md + +Tools I want, in addition to the core pandapower, PyPSA and PowerIO: +MCP clients to configure: + +Use a dedicated virtual environment. Ask me before guessing the install path of any +commercial software. Finish by running `powermcp doctor` and telling me what is left for me to do. +``` + +The agent follows [`llms-install.md`](llms-install.md): it checks your OS and Python, creates a virtual environment, installs the right extras, stores vendor software paths, writes the MCP client configuration without touching your other servers, and verifies the result. If your agent can't open web links, clone this repository and tell it to read `llms-install.md` from the clone. + +After it finishes, restart your MCP client (start a new Claude Code or Codex session, or fully quit and reopen Claude Desktop) so it loads the new servers. + +### Install it yourself + PowerMCP installs as a single Python package with an interactive CLI. Python 3.10 through 3.14 is supported. ```bash pip install powermcp ``` -The base install includes the open-source engines that need no extra setup β€” **pandapower**, **PyPSA**, and **PowerIO** (the cross-server case-conversion substrate). Every other tool is opt-in via an extra: +The base install includes the open-source engines that need no extra setup: **pandapower**, **PyPSA**, and **PowerIO** (the cross-server case-conversion substrate). Every other tool is opt-in via an extra. Quote the brackets, since zsh (the macOS default shell) otherwise rejects them: ```bash -pip install powermcp[psse] # add PSS/E support -pip install powermcp[andes,opendss] # add several tools at once -pip install powermcp[opensource] # all open-source tools (ANDES, Egret, OpenDSS, surge, HOPE, LTSpice, GenX) -pip install powermcp[all] # everything (closed-source tools still need the local software) +pip install "powermcp[psse]" # add PSS/E support +pip install "powermcp[andes,opendss]" # add several tools at once +pip install "powermcp[opensource]" # all open-source tools (ANDES, Egret, OpenDSS, surge, HOPE, LTSpice, GenX) +pip install "powermcp[windows]" # all Windows vendor tools (PowerWorld, PSS/E, PSLF, PowerFactory, PSCAD) +pip install "powermcp[all]" # everything (closed-source tools still need the local software) ``` +### Supported tools + +| Tool | `powermcp` id | pip extra | Platform | Notes | +|---|---|---|---|---| +| pandapower | `pandapower` | *(core)* | any | | +| PyPSA | `pypsa` | *(core)* | any | HiGHS included; CBC, GLPK, Gurobi optional | +| PowerIO | `powerio` | *(core)* | any | case parsing, conversion, and matrices for every other server | +| ANDES | `andes` | `andes` | any | | +| Egret | `egret` | `egret` | any | needs ipopt or Gurobi | +| OpenDSS | `opendss` | `opendss` | any | | +| surge | `surge` | `surge` | any | Python 3.12 to 3.14 | +| HOPE | `hope` | `hope` | any | needs a HOPE.jl checkout and Julia | +| GenX | `genx` | `genx` | any | needs a GenX.jl checkout; SLURM to submit cases | +| LTSpice | `ltspice` | `ltspice` | any | LTspice must be installed (auto-detected) | +| PLEXOS database | `plexosdb` | `plexosdb` | any | Python 3.11 to 3.13; extra manual steps in [PLEXOSDB/README.md](PLEXOSDB/README.md) | +| PowerWorld | `powerworld` | `powerworld` | Windows | needs a running, licensed Simulator | +| PSS/E | `psse` | `psse` | Windows | needs PSS/E installed | +| GE PSLF | `pslf` | `pslf` | Windows | needs PSLF installed | +| PowerFactory | `powerfactory` | `powerfactory` | Windows | needs PowerFactory installed | +| PSCAD | `pscad` | `pscad-windows` | Windows | needs PSCAD installed | + ### Set up with the interactive installer ```bash powermcp install ``` -The wizard lets you pick tools (pandapower + PyPSA + PowerIO pre-selected), captures the local install path for any closed-source/EXE-based tools you choose (PSS/E, PSLF, PowerFactory, PSCAD, LTSpice), installs the right extras, and writes the MCP client configuration for **Claude Desktop**, **Claude Code**, and the **Codex CLI**. Use `--dry-run` to preview the changes, or `--yes` for a non-interactive core install. +The wizard lets you pick tools (pandapower + PyPSA + PowerIO pre-selected), captures the local install path for any tools that need one (PSS/E, PSLF, PowerFactory, LTSpice, HOPE, GenX), installs the right extras, and writes the MCP client configuration for **Claude Desktop**, **Claude Code**, and the **Codex CLI**. Each entry launches the server with the absolute path of the Python interpreter that ran the installer, so keep that environment in place. Use `--dry-run` to preview the changes, `--clients` to pick which clients to configure, or `--yes` for a non-interactive core install. In the interactive picker, move with ↑/↓ and **press SPACE to toggle each tool** before ENTER (ENTER alone keeps only the preselected tools). Prefer not to use the checkbox? Choose tools directly: @@ -96,17 +151,18 @@ powermcp install --tools psse,andes # core + the listed tools powermcp install --all # every tool available on this platform ``` -Re-running `powermcp install` pre-checks the tools you've already installed or configured, so it **preserves and updates** your setup instead of resetting to the core tools. Paths for tools like LTSpice are **auto-detected and pre-filled**, so you can usually just press Enter. +Re-running `powermcp install` interactively pre-checks the tools you've already installed or configured, so it **preserves and updates** your setup instead of resetting to the core tools. With `--tools`, list every tool you want to keep: `powermcp_*` entries for tools left out of the list are removed. Paths for tools like LTSpice are **auto-detected and pre-filled**, so you can usually just press Enter. ### CLI commands | Command | Description | |---|---| -| `powermcp install` | Setup wizard β€” interactive, or `--tools ` / `--all` (also `--dry-run`, `--yes`, `--clients`) | +| `powermcp install` | Setup wizard: interactive, or `--tools ` / `--all` (also `--dry-run`, `--yes`, `--clients claude-desktop,claude-code,codex,none`) | | `powermcp run ` | Launch a server over stdio (used by the generated client config) | | `powermcp list` | List the available tools, extras, and Windows-only flags | -| `powermcp doctor` | Check each tool's dependencies and configured paths | +| `powermcp doctor [tool]` | Check dependencies and configured paths for every tool, or for one | | `powermcp config show` / `config set . ` | Inspect / set local software paths | +| `powermcp --version` | Print the installed version | ### Closed-source / EXE-based tools @@ -121,7 +177,8 @@ These tools wrap commercial or locally-installed software, so PowerMCP stores th | HOPE | `hope.repo_root`, `hope.julia_bin`, `hope.julia_depot_path` | `powermcp config set hope.repo_root "C:\src\HOPE"` | | GenX | `genx.repo_root` | `powermcp config set genx.repo_root "/home/me/GenX.jl"` β€” the GenX.jl checkout; `GENX_DIR` overrides it | | PowerWorld | *(none)* | `esa` auto-discovers a running, licensed Simulator via COM; the `powerworld` extra also installs `numba` (required by esa) | -| PSCAD | *(none)* | `pip install powermcp[pscad-windows]` provides `mhi-pscad`; PSCAD must be installed | +| PSCAD | *(none)* | `pip install "powermcp[pscad-windows]"` provides `mhi-pscad`; PSCAD must be installed | +| PLEXOS database | *(none)* | The upstream `plexosdb-mcp` package is not on PyPI yet; install it as described in [PLEXOSDB/README.md](PLEXOSDB/README.md) | > The Codex *Desktop* app on Windows has been reported to overwrite `~/.codex/config.toml`; the Codex *CLI* is unaffected. If you use both, re-run `powermcp install` after Desktop edits. @@ -252,7 +309,7 @@ python -m powerio.mcp # powerio ships its own server; the clone holds > **Note:** All MCPs should be tested via an MCP client (Claude Desktop, Claude Code, or Codex) before submitting a PR to ensure consistency. -`powermcp install` writes the client configuration for you. The generated entries look like the example in [`config.json`](config.json). (The **[PowerMCP Tutorial PDF](PowerMCP_Tutorial.pdf)** covers the older manual / low-code setup and isn't needed for the package install.) +`powermcp install` writes the client configuration for you. Each generated entry runs ` -m powermcp run ` with the absolute interpreter path, because GUI clients such as Claude Desktop don't inherit your shell `PATH`. [`config.json`](config.json) shows the shorter form that works when `powermcp` is on `PATH`. For clients the installer doesn't write (Cursor, VS Code, and others), add the same command and arguments by hand; [`llms-install.md`](llms-install.md) has an example. (The **[PowerMCP Tutorial PDF](PowerMCP_Tutorial.pdf)** covers the older manual / low-code setup and isn't needed for the package install.) ## πŸ“š Documentation @@ -263,7 +320,7 @@ For detailed documentation about MCP, please visit: ## 🀝 Contributing -We welcome contributions! Please see our [Contributing Guidelines](https://power-agent.github.io/) for details. +We welcome contributions! Please see our [Contributing Guidelines](https://poweragent.seas.harvard.edu/) for details, and join the conversation in the [PowerAgent Slack community](https://join.slack.com/t/poweragentslack/shared_invite/zt-3c14g1lv4-LfwB2DQU1_ZwTyxJO6k_5Q). ## πŸ“„ License @@ -272,7 +329,11 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file ## πŸ™ Acknowledgments ### Core Team -- [Qian Zhang](https://www.linkedin.com/in/qian-zhang-75323111b/), [Steven Black](https://www.linkedin.com/in/steven-black-09322b31/), [Paulo Radatz](https://www.linkedin.com/in/pauloradatz/), [Andrea Pomarico](https://www.linkedin.com/in/andrea-pomarico-2695a2218/), [Muhy Eddin Za’ter](https://scholar.google.com/citations?user=_IFFYFAAAAAJ&hl=en), [Luan Lopes dos Santos](https://www.linkedin.com/in/luan-lopes/), [Stephen Jenkins](https://www.linkedin.com/in/stephenjenkins2/), [Maanas Goel](https://www.linkedin.com/in/maanas-goel/), [Shen Wang](https://www.linkedin.com/in/swang16/), [Drew Gray](https://www.linkedin.com/in/drew-gray-b09ba426/), [Samuel Talkington](https://samueltalkington.com/) +PowerAgent leads: [Qian Zhang](https://qianzhang.xyz/) (student lead) and [Le Xie](https://seas.harvard.edu/person/le-xie) (faculty lead) + +PowerMCP: [Qian Zhang](https://qianzhang.xyz/), [Steven Black](https://www.linkedin.com/in/steven-black-09322b31/), [Paulo Radatz](https://www.linkedin.com/in/pauloradatz/), [Andrea Pomarico](https://www.linkedin.com/in/andrea-pomarico-2695a2218/), [Muhy Eddin Za'ter](https://scholar.google.com/citations?user=_IFFYFAAAAAJ&hl=en), [Luan Lopes dos Santos](https://www.linkedin.com/in/luan-lopes/), [Stephen Jenkins](https://www.linkedin.com/in/stephenjenkins2/), [Maanas Goel](https://www.linkedin.com/in/maanas-goel/), [Shen Wang](https://www.linkedin.com/in/swang16/), [Drew Gray](https://www.linkedin.com/in/drew-gray-b09ba426/), [Samuel Talkington](https://samueltalkington.com/), [Laura Hwa](https://www.linkedin.com/in/laurahwa/), [Leo Winiecki](https://www.linkedin.com/in/leo-winiecki-3337b716a/), [Brian Horakh](https://www.linkedin.com/in/brianhorakh/), [Aswin Krishna Poyil](https://www.linkedin.com/in/aswinkrishnapoyil/), [Burhan Abdullah](https://www.linkedin.com/in/burhanabdullah/) + +The full PowerAgent team, including PowerFM, PowerSkills, PowerWF, and the PowerAgent Platform, is listed at [poweragent.seas.harvard.edu](https://poweragent.seas.harvard.edu/). ### Special Thanks - All contributors who help make this project better diff --git a/llms-install.md b/llms-install.md new file mode 100644 index 00000000..051d4088 --- /dev/null +++ b/llms-install.md @@ -0,0 +1,266 @@ +# PowerMCP: installation guide for AI agents + +This file is written for an AI coding agent (Claude Code, Codex, Cursor, Cline, or +similar) that a user has asked to install and configure PowerMCP. Humans can follow +it too, but the [README](README.md) is the shorter read. + +**Goal:** install the `powermcp` Python package with the power-system tools the user +wants, store the local paths of any vendor software, register one MCP server per tool +in the user's MCP client(s), and verify that the servers start. + +Work through the steps in order. Every command is non-interactive and safe to run from +an agent shell, which has no TTY. + +## Ground rules + +1. **Ask once, up front, for what you can't find out.** If the user's request doesn't + already say, ask in a single message: + - which tools they want (the core tools pandapower, PyPSA and PowerIO are always + installed; see the table in step 3), + - which MCP clients to configure (`claude-code`, `claude-desktop`, `codex`, or + another client), + - the install path of any commercial software you can't locate yourself (step 4). +2. **Don't install into the system Python** and don't use `sudo`. Use a dedicated + virtual environment (step 2). +3. **Commercial software is the user's to install.** PSS/E, PSLF, PowerFactory, + PowerWorld, PSCAD and LTspice must already be installed and licensed on this + machine. Never download vendor installers or enter license details. +4. **Leave the user's other MCP servers alone.** The installer only adds, updates or + removes entries whose names start with `powermcp_`, and it backs up each client + config file once (`*.powermcp.bak`) before its first write. +5. **Use one interpreter throughout.** The client config records the absolute path of + the Python interpreter that ran `powermcp install`. Run every command below through + that same interpreter, written `"$PY" -m ...` in this guide. + +## Step 1: check the environment + +```bash +uname -a 2>/dev/null || ver # OS +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 + 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.** + Match the venv to the vendor folder: `PSSPY311` needs Python 3.11, and + `PowerFactory 2024\Python\3.11` needs Python 3.11. +- **Windows only:** `powerworld`, `psse`, `pslf`, `powerfactory`, `pscad`. On macOS + or Linux the installer skips them with `Not available on this platform/Python`. + Tell the user instead of trying to work around it. +- See which clients are present: `claude --version` (Claude Code), + `codex --version` (Codex CLI), and the Claude Desktop config folder from step 5. + +## Step 2: create a persistent virtual environment + +The venv must survive: the MCP client launches the servers from it, so deleting or +moving it breaks them. Don't create it in a temporary or build directory. If the user +already has an environment they want to use (a conda env, a project venv), use that. + +macOS / Linux: + +```bash +python3.12 -m venv ~/.venvs/powermcp +PY="$HOME/.venvs/powermcp/bin/python" +"$PY" -m pip install --upgrade pip +``` + +Windows (PowerShell): + +```powershell +py -3.12 -m venv "$env:USERPROFILE\.venvs\powermcp" +$PY = "$env:USERPROFILE\.venvs\powermcp\Scripts\python.exe" +& $PY -m pip install --upgrade pip +``` + +In PowerShell, run the later commands as `& $PY -m ...` instead of `"$PY" -m ...`. + +With **uv** instead: `uv venv -p 3.12 ~/.venvs/powermcp`, then install with +`uv pip install --python "$PY" ...`. A uv venv has no `pip`, so never pass `--yes` to +`powermcp install` there (step 5 explains why). + +## Step 3: install the package and the extras + +Map each tool the user wants to its pip extra: + +| Tool id | Software | pip extra | Platform | Also needs | +|---|---|---|---|---| +| `pandapower` | pandapower | *(core)* | any | | +| `pypsa` | PyPSA | *(core)* | any | HiGHS ships with the core install; CBC, GLPK or Gurobi optional | +| `powerio` | PowerIO case conversion | *(core)* | any | | +| `andes` | ANDES | `andes` | any | | +| `egret` | Egret | `egret` | any | an optimization solver on PATH (ipopt or Gurobi) | +| `opendss` | OpenDSS | `opendss` | any | | +| `surge` | surge | `surge` | any, Python 3.12+ | | +| `hope` | HOPE | `hope` | any | a HOPE.jl checkout and Julia (paths in step 4) | +| `genx` | GenX | `genx` | any | a GenX.jl checkout (path in step 4); SLURM `sbatch` to submit cases | +| `ltspice` | LTspice | `ltspice` | any | LTspice installed (executable auto-detected) | +| `plexosdb` | PLEXOS database | `plexosdb` | any, Python 3.11 to 3.13 | extra manual steps, see [PLEXOSDB/README.md](PLEXOSDB/README.md) | +| `powerworld` | PowerWorld Simulator | `powerworld` | Windows | a running, licensed Simulator | +| `psse` | PSS/E | `psse` | Windows | PSS/E installed (paths in step 4) | +| `pslf` | GE PSLF | `pslf` | Windows | PSLF installed (path in step 4) | +| `powerfactory` | DIgSILENT PowerFactory | `powerfactory` | Windows | PowerFactory installed (path in step 4) | +| `pscad` | PSCAD | `pscad-windows` | Windows | PSCAD installed | + +Convenience extras: `opensource` (every open-source extra), `windows` (every Windows +vendor tool), `all` (everything). + +Install the core package and the extras in one command. **Quote the brackets**; +zsh (the macOS default shell) otherwise rejects them: + +```bash +"$PY" -m pip install "powermcp[andes,opendss]" # core + ANDES + OpenDSS +"$PY" -m pip install powermcp # core tools only +``` + +Developers working from a clone of this repository install it in editable mode instead: +`"$PY" -m pip install -e ".[andes,opendss]"`. + +Confirm the install: `"$PY" -m powermcp --version` and `"$PY" -m powermcp list`. + +## Step 4: store vendor software paths (only for tools that need them) + +Skip this step if the user picked only tools without paths (`pandapower`, `pypsa`, +`powerio`, `andes`, `egret`, `opendss`, `surge`, `powerworld`, `pscad`). + +For each key below, look in the typical location first, confirm the path exists, +and ask the user only if you can't find it. Then store it: + +```bash +"$PY" -m powermcp config set . "" +``` + +| Key | What it points to | Typical location | +|---|---|---| +| `psse.python_lib` | PSS/E `PSSPYxxx` folder matching the venv Python | `C:\Program Files\PTI\PSSE36\36.2\PSSPY311` | +| `psse.bin` | PSS/E `PSSBIN` folder | `C:\Program Files\PTI\PSSE36\36.2\PSSBIN` | +| `pslf.python_lib` | folder that contains the `PSLF_PYTHON` module | `C:\Program Files\GE PSLF\PSLF_PYTHON` | +| `powerfactory.python_path` | PowerFactory's Python folder matching the venv Python | `C:\Program Files\DIgSILENT\PowerFactory 2024\Python\3.11` | +| `ltspice.exe` | LTspice executable (normally auto-detected, so set it only when `doctor` reports it missing) | `C:\Program Files\ADI\LTspice\LTspice.exe` | +| `hope.repo_root` | root of the user's HOPE.jl checkout | ask the user | +| `hope.julia_bin` | Julia executable | output of `which julia` / `where julia` | +| `hope.julia_depot_path` | optional `JULIA_DEPOT_PATH` | leave unset unless the user has one | +| `genx.repo_root` | root of the user's GenX.jl checkout | ask the user | + +The values live in `~/.powermcp/config.toml`; `"$PY" -m powermcp config show` prints it. + +## Step 5: write the MCP client configuration + +**5a. Find what's already configured.** Re-running the installer with `--tools` +removes every `powermcp_*` entry whose tool isn't in the list. Before writing, read the +existing entries and add those tools to your `--tools` list unless the user asked to +drop them: + +| Client | Config file | Where PowerMCP's entries are | +|---|---|---| +| Claude Code | `~/.claude.json` | `mcpServers.powermcp_*` (or run `claude mcp list`) | +| Claude Desktop (macOS) | `~/Library/Application Support/Claude/claude_desktop_config.json` | `mcpServers.powermcp_*` | +| Claude Desktop (Windows) | `%APPDATA%\Claude\claude_desktop_config.json` | `mcpServers.powermcp_*` | +| Claude Desktop (Linux) | `~/.config/Claude/claude_desktop_config.json` | `mcpServers.powermcp_*` | +| Codex CLI | `~/.codex/config.toml` (or `$CODEX_HOME/config.toml`) | `[mcp_servers.powermcp_*]` tables | + +**5b. Preview, then write.** `--tools` takes comma-separated tool ids; the core +tools are always added. `--clients` takes any of `claude-code`, `claude-desktop`, +`codex` (the default is all three); configure only the clients the user uses. + +```bash +"$PY" -m powermcp install --tools andes,opendss --clients claude-code,codex --dry-run +"$PY" -m powermcp install --tools andes,opendss --clients claude-code,codex +``` + +Run from an agent shell, which has no TTY, `powermcp install --tools ...` skips the +checkbox picker, the path prompts and its own `pip install`, and only writes the client +config. Steps 3 and 4 already covered the rest, so that's what you want. Don't add +`--yes`: it makes the installer run `python -m pip install` itself, which fails in a +uv venv. + +**Other MCP clients** (Cursor, VS Code, Windsurf, Cline, Gemini CLI and others) aren't +written by the installer. Add one stdio server per tool by following that client's +MCP documentation, with the absolute interpreter path as the command: + +```json +{ + "mcpServers": { + "powermcp_pandapower": { + "command": "/Users/me/.venvs/powermcp/bin/python", + "args": ["-m", "powermcp", "run", "pandapower"] + } + } +} +``` + +On Windows the command is the venv's `Scripts\python.exe`, with backslashes escaped in +JSON (`"C:\\Users\\me\\.venvs\\powermcp\\Scripts\\python.exe"`). + +## Step 6 (optional): let the servers read the user's case folders + +The servers read and write files only beneath their allowed roots. With no setting, +that's the directory the server process started in; for Claude Code and Codex this is +usually the project folder. If the user keeps cases elsewhere, ask which folders to +allow and set `POWERIO_MCP_ALLOWED_ROOTS` in the `env` of each `powermcp_*` entry +(separate folders with `:` on macOS/Linux, `;` on Windows): + +```json +"powermcp_pandapower": { + "command": "...", + "args": ["-m", "powermcp", "run", "pandapower"], + "env": { "POWERIO_MCP_ALLOWED_ROOTS": "/Users/me/cases:/Users/me/studies" } +} +``` + +In Codex's TOML, add `env = { POWERIO_MCP_ALLOWED_ROOTS = "/Users/me/cases" }` to each +`[mcp_servers.powermcp_*]` table. Re-running `powermcp install` rewrites the +`powermcp_*` entries and drops this `env` block, so add it again afterwards. + +## Step 7: verify + +```bash +"$PY" -m powermcp doctor # every tool, or: "$PY" -m powermcp doctor psse +``` + +- **dependencies:** each selected tool shows `ok`. `missing; pip install powermcp[x]` + means the extra isn't installed in this venv (go back to step 3). +- **config paths:** `set: .` means a required path is still missing + (go back to step 4). +- Windows-only tools show `skipped, Windows-only` on other platforms. +- The closing notes list tools that also need an external solver or runtime on PATH. + +Then check that the client sees the servers: + +- **Claude Code:** `claude mcp list` should list each `powermcp_*` server as connected. +- **Codex CLI:** `codex mcp list`. +- **Claude Desktop:** the user must fully quit Claude Desktop (from the menu bar or + system tray, not just the window) and reopen it; **Settings > Developer** then shows + each server's status. + +Don't run `powermcp run ` in the foreground to test: it's a stdio server and +waits for input indefinitely. Use `doctor` and the client's own listing instead. + +## Step 8: report to the user + +Finish with a short summary: + +- the interpreter path the clients will launch (`$PY`), +- the tools installed and the clients configured, +- vendor paths stored, and any still missing, +- external requirements left for the user (licenses, ipopt/Gurobi, Julia, SLURM), +- that MCP clients load new servers only at startup: restart Claude Code or Codex + (start a new session), and fully quit and reopen Claude Desktop, +- a first prompt to try, such as *"Create the IEEE 9-bus case in pandapower and run an + AC power flow."* + +## Troubleshooting + +| Symptom | Fix | +|---|---| +| `zsh: no matches found: powermcp[...]` | Quote the requirement: `"powermcp[andes]"`. | +| `Not available on this platform/Python, skipped: ` | That tool is Windows-only, or (for `surge`) needs Python 3.12+. Use another venv or skip the tool. | +| `No module named pip` | uv venv: install with `uv pip install --python "$PY" ...` and don't pass `--yes` to `powermcp install`. | +| A server shows as failed in the client | Check that the entry's `command` path exists, then run `"$PY" -m powermcp doctor `. | +| PSS/E or PowerFactory fails to import | The venv's Python version doesn't match the vendor folder (`PSSPY311` needs 3.11). Rebuild the venv with the matching Python. | +| Tool calls refuse a file path | The file is outside the allowed roots; see step 6. | +| Codex servers vanish on Windows | The Codex *Desktop* app has been reported to rewrite `~/.codex/config.toml`. Re-run step 5b after it does. The Codex CLI is unaffected. | + +To upgrade later: `"$PY" -m pip install --upgrade "powermcp[]"`, then +re-run step 5b with the full tool list. From 44bbb291deabd87b6dd63fbe01c146e3023647b7 Mon Sep 17 00:00:00 2001 From: Qian Zhang Date: Wed, 11 Nov 2026 11:30:30 -0500 Subject: [PATCH 2/2] Keep the clean pandapower fixture clean under powerio 0.11.8+ powerio 0.11.8 started reporting EMIT.PANDAPOWER.FIELD_DROPPED when a branch carries rate_b/rate_c values, since pandapower holds a single loading limit. CLEAN_CASE set all three ratings to 250, so test_pandapower_response_states_an_empty_warnings_list now gets that warning and fails on Python 3.11+ (3.10 still resolves powerio 0.11.7, which predates the diagnostic). Set rate_b and rate_c to 0, MATPOWER's "unset", so the fixture again carries nothing pandapower drops and the test keeps checking what it is for: a clean load states an empty warnings list. Passes under powerio 0.11.7 and 0.11.11. Co-Authored-By: Claude Opus 5.5 --- tests/test_powerio_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_powerio_server.py b/tests/test_powerio_server.py index b9d0e7fc..c6f96caf 100644 --- a/tests/test_powerio_server.py +++ b/tests/test_powerio_server.py @@ -65,7 +65,7 @@ \t1 60 10 0 0 1.0 100 1 100 0; ]; mpc.branch = [ -\t1 2 0.01 0.1 0.0 250 250 250 0 0 1 -360 360; +\t1 2 0.01 0.1 0.0 250 0 0 0 0 1 -360 360; ]; """