open-energy-transition/pypsa-mcp
PyPSA MCP: PyPSA Energy Modeling for LLMs
b771396ec065pypsamcp0.1.4 in pyproject.tomlPaths from tool input into commands, SQL, files and URLs
How much power the tools give an agent over the machine
Hidden instructions and poisoning in text for the model
Known vulnerabilities in the packages the server uses
How the server reads credentials and where they can go
Whether the tools do only what their descriptions say
How far the analysis went
- Supply Chain: the dependency files state no exact versions the scanner could check, so it has no number
Top risks in plain words
- HIGHTool
run_simulationexecutes code by design: an agent steered by prompt injection can use it that way.
How to use it safely
Practical steps from what we found in this server. They lower the risk; they do not replace a review of the code.
- Run it in a container or a virtual machine
run_simulationcan start programs or run code they are given. Keep it away from your home folder, keys and other projects. - Turn off the tools you do not use
Most MCP clients let you disable single tools. If you do not need
run_simulation, switch them off. - Keep confirmations on
Leave your MCP client's confirmation prompt on for tools that change files, run commands or send data.
What its tools can do on your machine
The server offers 22 tools. When an AI agent calls them, this is what their code can do on the machine where the server runs, as traced in the source. Tools that call code the scanner could not follow may do more.
None of the tools reaches any of these in the code the scanner could trace.
Where its requests and secrets go
Read from the names along each tool's calls, not from a run: what the code says, not every address it may reach at run time.
The literal addresses the tools' requests name.
- None: no request names a fixed host.
Constants or settings that start an address; the value comes from configuration.
- None seen.
Credential-like environment variables. Give the server a key with the least access it needs.
- None: no credential-like variable is read by the tools.
Text it brings in from outside
No tool was seen returning text from outside the server to the model.
Tool annotations
No tool declares MCP annotations (readOnlyHint, destructiveHint and the rest). Clients use them to decide what to confirm; directories such as Anthropic's and OpenAI's ask for them.
Tools, prompts and resources (22: 22 tools)
Open a row for its full description. Chips show what its code can reach, and which risky capability its own description declares.
run_simulationtool Run a simulation on a PyPSA network.Executes code
Run a simulation on a PyPSA network.
Supports 8 modes: pf, lpf, optimize, mga, security_constrained,
rolling_horizon, transmission_expansion_iterative, optimize_and_pf.add_bustool [Deprecated] Add a bus to a PyPSA model. Use add_component() instead.
[Deprecated] Add a bus to a PyPSA model. Use add_component() instead.
Args:
model_id: The ID of the model
bus_id: The ID for the new bus
v_nom: Nominal voltage in kV
x: x-coordinate for plotting
y: y-coordinate for plotting
carrier: Energy carrier (e.g., "AC", "DC")
country: Country code if applicableadd_componenttool Add any PyPSA component to a model.
Add any PyPSA component to a model.
Args:
model_id: The model to add the component to
component_type: Component type (e.g. 'Generator', 'Bus', 'Line')
component_id: Unique ID for the new component
params: Static/scalar input parameters
time_series: Time-varying parameters as {attr: [values...]}add_generatortool [Deprecated] Add a generator to a PyPSA model. Use add_component() instead.
[Deprecated] Add a generator to a PyPSA model. Use add_component() instead.
Args:
model_id: The ID of the model
generator_id: The ID for the new generator
bus: The bus ID to connect to
p_nom: Nominal power capacity in MW
p_nom_extendable: Whether capacity can be expanded
capital_cost: Investment cost in currency/MW
marginal_cost: Operational cost in currency/MWh
carrier: Energy carrier (e.g., "wind", "solar")
efficiency: Generator efficiency (0 to 1)add_linetool [Deprecated] Add a transmission line to a PyPSA model. Use add_component() instead.
[Deprecated] Add a transmission line to a PyPSA model. Use add_component() instead.
Args:
model_id: The ID of the model
line_id: The ID for the new line
bus0: The ID of the first bus
bus1: The ID of the second bus
x: Reactance in ohm
r: Resistance in ohm
s_nom: Nominal apparent power capacity in MVA
s_nom_extendable: Whether capacity can be expanded
capital_cost: Investment cost in currency/MW
length: Line length in kmadd_loadtool [Deprecated] Add a load to a PyPSA model. Use add_component() instead.
[Deprecated] Add a load to a PyPSA model. Use add_component() instead.
Args:
model_id: The ID of the model
load_id: The ID for the new load
bus: The bus ID to connect to
p_set: Active power demand in MW
q_set: Reactive power demand in MVArcluster_networktool Cluster a network spatially or temporally, storing result as a new model.
Cluster a network spatially or temporally, storing result as a new model.
Args:
model_id: Source model ID.
domain: 'spatial' or 'temporal'.
method: Clustering method. Spatial: 'kmeans', 'hac', 'greedy_modularity'.
Temporal: 'resample', 'downsample', 'segment', 'snapshot_map'.
output_model_id: ID to store the clustered network under.
n_clusters: Number of clusters (spatial methods).
bus_weightings: Optional bus weighting dict (spatial).
line_length_factor: Line length factor (spatial kmeans).
affinity: Affinity metric (spatial hac).
linkage: Linkage method (spatial hac).
with_time: Include time in spatial clustering.
aggregate_generators_weighted: Weight generator aggregation.
scale_link_capital_costs: Scale link capital costs.
offset: Resample offset string, e.g. '3h' (temporal resample).
stride: Downsample stride (temporal downsample).
num_segments: Number of segments (temporal segment).
solver: Solver for segmentation (temporal segment).
snapshot_map: Snapshot mapping dict (temporal snapshot_map).
Returns:
Dict with clustering summary including input/output bus and snapshot counts.configure_timetool Configure time snapshots, investment periods, scenarios, or risk preference.
Configure time snapshots, investment periods, scenarios, or risk preference.
Args:
model_id: The model to configure
mode: One of 'snapshots', 'investment_periods', 'scenarios', 'risk_preference'
snapshots: ISO datetime strings (mode='snapshots')
weightings: Snapshot weightings dict (mode='snapshots')
periods: Investment years e.g. [2025, 2030] (mode='investment_periods')
scenarios: Scenario definition (mode='scenarios')
alpha: CVaR confidence level (mode='risk_preference')
omega: Weight on CVaR term 0-1 (mode='risk_preference')create_energy_modeltool Create a new PyPSA energy model with the given ID.
Create a new PyPSA energy model with the given ID.
Args:
model_id: A unique identifier for the model
name: A descriptive name for the model (defaults to model_id if not provided)
override: Whether to override an existing model with the same IDdelete_modeltool Delete a PyPSA model by ID.
Delete a PyPSA model by ID.
Args:
model_id: The ID of the model to deletedescribe_componenttool Describe the full input-parameter schema for a PyPSA component type.
Describe the full input-parameter schema for a PyPSA component type.
Args:
component_type: Component type name (e.g. 'Generator', 'Bus', or 'generators')
include_defaults: Whether to include default values in the responseexport_model_summarytool Export a comprehensive summary of the model.
Export a comprehensive summary of the model.
Args:
model_id: The ID of the model to exportget_statisticstool Get statistics from a solved PyPSA model.
Get statistics from a solved PyPSA model.
Args:
model_id: The model to query
metric: Metric name or 'all'. One of: system_cost, capex, opex, fom,
overnight_cost, installed_capacity, optimal_capacity,
expanded_capacity, installed_capex, expanded_capex,
capacity_factor, curtailment, energy_balance, supply,
withdrawal, revenue, market_value, prices, transmission
components: Filter to specific component types
carrier: Filter by carrier name
bus_carrier: Filter by bus carrier
groupby: Aggregation grouping (e.g. 'carrier', 'bus')
aggregate_across_components: Merge component types into one row per carrier
nice_names: Use human-readable carrier names
drop_zero: Omit zero-value rowslist_component_typestool List all available PyPSA component types with descriptions.
List all available PyPSA component types with descriptions.
Returns the catalog of 13 user-facing component types. No model required.list_modelstool List all currently available PyPSA models.
List all currently available PyPSA models.
network_iotool Perform I/O and network manipulation operations.
Perform I/O and network manipulation operations.
Operations:
- export_netcdf: Export network to NetCDF file (requires path)
- export_csv: Export network to CSV folder (requires path)
- import_netcdf: Import network from NetCDF file (requires path), stores as model_id
- import_csv: Import network from CSV folder (requires path), stores as model_id
- merge: Merge another network into this one (requires other_model_id, output_model_id)
- copy: Copy this network (optionally subset by snapshots/buses), stores as output_model_id
- consistency_check: Run consistency check on the networkquery_componentstool Query components of a given type, optionally filtered.
Query components of a given type, optionally filtered.
Args:
model_id: The model to query
component_type: Component type (e.g. 'Generator', 'Bus')
filters: Optional {attr: value} dict to filter rowsremove_componenttool Remove a component from a model.
Remove a component from a model.
Args:
model_id: The model containing the component
component_type: Component type (e.g. 'Generator', 'Bus')
component_id: ID of the component to removerun_optimizationtool [Deprecated] Run optimization. Use run_simulation(mode='optimize') instead.
[Deprecated] Run optimization. Use run_simulation(mode='optimize') instead.
Args:
model_id: The model ID
solver_name: Solver to use
formulation: Network formulation
extra_functionality: Custom constraint coderun_powerflowtool [Deprecated] Run power flow. Use run_simulation(mode='pf') instead.
[Deprecated] Run power flow. Use run_simulation(mode='pf') instead.
Args:
model_id: The model ID
snapshot: Specific snapshot to run for (optional)set_snapshotstool [Deprecated] Set time snapshots. Use configure_time(mode='snapshots') instead.
[Deprecated] Set time snapshots. Use configure_time(mode='snapshots') instead.
Args:
model_id: The model ID
snapshots: List of datetime stringsupdate_componenttool Update parameters of an existing component.
Update parameters of an existing component.
Args:
model_id: The model containing the component
component_type: Component type (e.g. 'Generator', 'Bus')
component_id: ID of the component to update
params: Static/scalar parameters to update
time_series: Time-varying parameters to update as {attr: [values...]}Text the model reads (22)
Every tool, prompt and resource description as written in the code: the model sees all of it, the user usually does not.
cluster_network tool
Cluster a network spatially or temporally, storing result as a new model.
Args:
model_id: Source model ID.
domain: 'spatial' or 'temporal'.
method: Clustering method. Spatial: 'kmeans', 'hac', 'greedy_modularity'.
Temporal: 'resample', 'downsample', 'segment', 'snapshot_map'.
output_model_id: ID to store the clustered network under.
n_clusters: Number of clusters (spatial methods).
bus_weightings: Optional bus weighting dict (spatial).
line_length_factor: Line length factor (spatial kmeans).
affinity: Affinity metric (spatial hac).
linkage: Linkage method (spatial hac).
with_time: Include time in spatial clustering.
aggregate_generators_weighted: Weight generator aggregation.
scale_link_capital_costs: Scale link capital costs.
offset: Resample offset string, e.g. '3h' (temporal resample).
stride: Downsample stride (temporal downsample).
num_segments: Number of segments (temporal segment).
solver: Solver for segmentation (temporal segment).
snapshot_map: Snapshot mapping dict (temporal snapshot_map).
Returns:
Dict with clustering summary including input/output bus and snapshot counts.add_component tool
Add any PyPSA component to a model.
Args:
model_id: The model to add the component to
component_type: Component type (e.g. 'Generator', 'Bus', 'Line')
component_id: Unique ID for the new component
params: Static/scalar input parameters
time_series: Time-varying parameters as {attr: [values...]}update_component tool
Update parameters of an existing component.
Args:
model_id: The model containing the component
component_type: Component type (e.g. 'Generator', 'Bus')
component_id: ID of the component to update
params: Static/scalar parameters to update
time_series: Time-varying parameters to update as {attr: [values...]}remove_component tool
Remove a component from a model.
Args:
model_id: The model containing the component
component_type: Component type (e.g. 'Generator', 'Bus')
component_id: ID of the component to removequery_components tool
Query components of a given type, optionally filtered.
Args:
model_id: The model to query
component_type: Component type (e.g. 'Generator', 'Bus')
filters: Optional {attr: value} dict to filter rowsadd_bus tool
[Deprecated] Add a bus to a PyPSA model. Use add_component() instead.
Args:
model_id: The ID of the model
bus_id: The ID for the new bus
v_nom: Nominal voltage in kV
x: x-coordinate for plotting
y: y-coordinate for plotting
carrier: Energy carrier (e.g., "AC", "DC")
country: Country code if applicableadd_generator tool
[Deprecated] Add a generator to a PyPSA model. Use add_component() instead.
Args:
model_id: The ID of the model
generator_id: The ID for the new generator
bus: The bus ID to connect to
p_nom: Nominal power capacity in MW
p_nom_extendable: Whether capacity can be expanded
capital_cost: Investment cost in currency/MW
marginal_cost: Operational cost in currency/MWh
carrier: Energy carrier (e.g., "wind", "solar")
efficiency: Generator efficiency (0 to 1)add_load tool
[Deprecated] Add a load to a PyPSA model. Use add_component() instead.
Args:
model_id: The ID of the model
load_id: The ID for the new load
bus: The bus ID to connect to
p_set: Active power demand in MW
q_set: Reactive power demand in MVAradd_line tool
[Deprecated] Add a transmission line to a PyPSA model. Use add_component() instead.
Args:
model_id: The ID of the model
line_id: The ID for the new line
bus0: The ID of the first bus
bus1: The ID of the second bus
x: Reactance in ohm
r: Resistance in ohm
s_nom: Nominal apparent power capacity in MVA
s_nom_extendable: Whether capacity can be expanded
capital_cost: Investment cost in currency/MW
length: Line length in kmset_snapshots tool
[Deprecated] Set time snapshots. Use configure_time(mode='snapshots') instead.
Args:
model_id: The model ID
snapshots: List of datetime stringsrun_powerflow tool
[Deprecated] Run power flow. Use run_simulation(mode='pf') instead.
Args:
model_id: The model ID
snapshot: Specific snapshot to run for (optional)run_optimization tool
[Deprecated] Run optimization. Use run_simulation(mode='optimize') instead.
Args:
model_id: The model ID
solver_name: Solver to use
formulation: Network formulation
extra_functionality: Custom constraint codelist_component_types tool
List all available PyPSA component types with descriptions.
Returns the catalog of 13 user-facing component types. No model required.describe_component tool
Describe the full input-parameter schema for a PyPSA component type.
Args:
component_type: Component type name (e.g. 'Generator', 'Bus', or 'generators')
include_defaults: Whether to include default values in the responsenetwork_io tool
Perform I/O and network manipulation operations.
Operations:
- export_netcdf: Export network to NetCDF file (requires path)
- export_csv: Export network to CSV folder (requires path)
- import_netcdf: Import network from NetCDF file (requires path), stores as model_id
- import_csv: Import network from CSV folder (requires path), stores as model_id
- merge: Merge another network into this one (requires other_model_id, output_model_id)
- copy: Copy this network (optionally subset by snapshots/buses), stores as output_model_id
- consistency_check: Run consistency check on the networkcreate_energy_model tool
Create a new PyPSA energy model with the given ID.
Args:
model_id: A unique identifier for the model
name: A descriptive name for the model (defaults to model_id if not provided)
override: Whether to override an existing model with the same IDlist_models tool
List all currently available PyPSA models.
delete_model tool
Delete a PyPSA model by ID.
Args:
model_id: The ID of the model to deleteexport_model_summary tool
Export a comprehensive summary of the model.
Args:
model_id: The ID of the model to exportrun_simulation tool
Run a simulation on a PyPSA network.
Supports 8 modes: pf, lpf, optimize, mga, security_constrained,
rolling_horizon, transmission_expansion_iterative, optimize_and_pf.get_statistics tool
Get statistics from a solved PyPSA model.
Args:
model_id: The model to query
metric: Metric name or 'all'. One of: system_cost, capex, opex, fom,
overnight_cost, installed_capacity, optimal_capacity,
expanded_capacity, installed_capex, expanded_capex,
capacity_factor, curtailment, energy_balance, supply,
withdrawal, revenue, market_value, prices, transmission
components: Filter to specific component types
carrier: Filter by carrier name
bus_carrier: Filter by bus carrier
groupby: Aggregation grouping (e.g. 'carrier', 'bus')
aggregate_across_components: Merge component types into one row per carrier
nice_names: Use human-readable carrier names
drop_zero: Omit zero-value rowsconfigure_time tool
Configure time snapshots, investment periods, scenarios, or risk preference.
Args:
model_id: The model to configure
mode: One of 'snapshots', 'investment_periods', 'scenarios', 'risk_preference'
snapshots: ISO datetime strings (mode='snapshots')
weightings: Snapshot weightings dict (mode='snapshots')
periods: Investment years e.g. [2025, 2030] (mode='investment_periods')
scenarios: Scenario definition (mode='scenarios')
alpha: CVaR confidence level (mode='risk_preference')
omega: Weight on CVaR term 0-1 (mode='risk_preference')What we checked
The same checks run on every server. Each line below has one of these marks:
- 8 checks: command injection, argument injection, path traversal, server-side request forgery, SQL injection, code execution, unsafe deserialization, template injectionChecked on every scan. Results in this category are published only after a person has verified them.
- Runs programs the caller choosesNo tool runs a command or program the caller supplies — 22 tool handlers traced
- Executes caller-supplied code1 finding the scanner could not decide; see the findings below
- Reads or writes any file pathNo tool works on a file path the caller supplies without a root check — 22 tool handlers traced
- Requests any addressNo tool sends a request to an address the caller supplies — 22 tool handlers traced
- Runs caller-supplied SQLNo tool executes a query the caller supplies — 22 tool handlers traced
- Tools that start processesNot seen in the traced code of 22 capabilities; 22 more call code the scanner could not follow, where it may happen
- Tools that touch filesNot seen in the traced code of 22 capabilities; 22 more call code the scanner could not follow, where it may happen
- Tools that call the networkNot seen in the traced code of 22 capabilities; 22 more call code the scanner could not follow, where it may happen
Where the code is: 22 handlers in 10 files at commit b771396ec065
src/pypsamcp/tools/clustering.pycluster_networksrc/pypsamcp/tools/components.pyadd_component, update_component, remove_component, query_componentssrc/pypsamcp/tools/convenience.pyadd_bus, add_generator, add_load, add_linesrc/pypsamcp/tools/deprecated.pyset_snapshots, run_powerflow, run_optimizationsrc/pypsamcp/tools/discovery.pylist_component_types, describe_componentsrc/pypsamcp/tools/io.pynetwork_iosrc/pypsamcp/tools/management.pycreate_energy_model, list_models, delete_model, export_model_summarysrc/pypsamcp/tools/simulation.pyrun_simulationsrc/pypsamcp/tools/statistics.pyget_statisticssrc/pypsamcp/tools/time_config.pyconfigure_time
- 5 checks: tool poisoning, instruction override, hidden content, exfiltration requests, metadata integrityChecked on every scan. Results in this category are published only after a person has verified them.
- Dependency manifests1 manifest: pyproject.toml
- Lockfiles checked against OSVNothing could be resolved to exact versions; 1 not resolved: pyproject.toml: dependency ranges declared here were not resolved against a lockfile and were not checked
- MCP SDK versionfastmcp >=2.2.0
- 3 checks: credential harvesting, undeclared credential access, credentials sent over the networkChecked on every scan. Results in this category are published only after a person has verified them.
- Tools that read credentialsNot seen in the traced code of 22 capabilities; 22 more call code the scanner could not follow, where it may happen
- Authentication declaredNot checked: needs the live server's tools/list (a remote server declares how clients authenticate)
- 3 checks: undeclared network access, undeclared file access, undeclared process executionChecked on every scan. Results in this category are published only after a person has verified them.
- Tool descriptions presentEvery tool has a description the model and the user can read
- Statically known namesEvery tool's name could be read from the code
- Input schemasNot checked: needs the live server's tools/list (every tool declares an input schema)
- Destructive tools annotatedNot checked: needs the live server's tools/list (tools that write, delete or run commands carry destructivehint)
Dependencies with known vulnerabilities (0 in production)
Dependency ranges were not resolved against a lockfile, so the score is capped at 7.
No known vulnerabilities in the production dependencies that could be checked.
Past security advisories
Vulnerabilities published for this server itself, from the GitHub Advisory Database.
No security advisories have been published for this server in the GitHub Advisory Database.
How it runs
| Where it runs | On your machine, started by your MCP client from this repository or its package |
|---|---|
| Transport | not stated in the code the scanner read; most local servers talk over stdio |
| Sign-in | not checked needs the live server |
| MCP SDK | fastmcp >=2.2.0 |
| Servers in the code | 1 (pypsa-mcp) |
The project's own security
| Security policy | none no SECURITY.md in the repository: report issues privately through GitHub if it is enabled |
|---|---|
| Past advisories | none in the GitHub Advisory Database |
| Last push | 2026-03-20 |
| Signed releases | not checked yet |
Where it is published
| Listed in | 3 catalogs (github_search, glama, mcp_toplist) |
|---|---|
| License | MIT |
| Created | 2025-04-22 |
Attack map
How the server is built and where its risky tools lead: servers, their tools, what the tools' code can do, and the traced route from a declared risky tool's argument to the operation it reaches. Click a node for details.