ansys/pylumerical-mcp
PyLumerical MCP Server
0d6f3735f9c8ansys-lumerical-mcp0.1.dev0 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
- INFONo published risk: no tool declared to run commands, files, addresses or queries of the caller's choice, no known vulnerability in a production package, no advisory. Code findings appear here only after a person has verified them.
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.
- Give it a narrowly scoped token
Its code reads credentials or environment variables. Use a key limited to what this server needs, not your main one.
- 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 6 tools, 1 prompt, 1 resource. 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.
open_sessionopen_sessionNo tool was seen to: start other programs on the machine; connect to the internet or other hosts; read passwords, tokens or keys; touch sensitive locations.
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.
Not all three are present in the tools the scanner traced.
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 (8: 6 tools, 1 prompt, 1 resource)
Open a row for its full description. Chips show what its code can reach, and which risky capability its own description declares.
pylumerical_system_promptprompt Return the system prompt for the PyLumerical MCP server.
Return the system prompt for the PyLumerical MCP server.
Returns
-------
str
The product-agnostic system prompt text.list_tool_setsresource Toolset definitions consumed by MCP clients and Ansys product UIs.
Toolset definitions consumed by MCP clients and Ansys product UIs.
close_sessiontool Close a Lumerical session and remove it from the registry.
Close a Lumerical session and remove it from the registry.
Bounded by :data:`_CLOSE_SESSION_TIMEOUT_S`. On timeout, returns a
failure envelope with ``timed_out=True`` and ``retained=True`` so the
agent can dispatch ``restart_session`` to recover. The orphaned worker
thread is left to drain on its own (asyncio cannot cancel it).execute_python_codetool Execute Python in the persistent subprocess that hosts all Lumerical sessions.
Execute Python in the persistent subprocess that hosts all Lumerical sessions.
Pre-loaded into the subprocess globals:
- Imports: ``FDTD``, ``MODE``, ``DEVICE``, ``INTERCONNECT`` from ``ansys.lumerical.core``
- Registry: ``_lumerical_sessions: dict[str, Lumerical]`` (live handles)
- Helpers:
* ``_lum_open(name, product, filename=None, hide=False)`` -- prefer
the ``open_session`` MCP tool over calling this helper directly
* ``_lum_close(name)``
* ``_lum_get(name)`` -- returns the live handle for ``name``
* ``_lum_list()``
* ``_lum_print_json(obj, *, max_array_size=200_000, indent=None)``
DATA-RETURN CONTRACT: only ``print()``-ed text leaves the subprocess. For
structured data (numpy arrays, dictionaries, Lumerical results), use
``_lum_print_json(...)``. It handles numpy/complex/dict/list with a
size guard that truncates arrays larger than ``max_array_size`` to
``{shape, dtype, preview}`` so the LLM context window doesn't get blown
up by multi-MB field data.
Example -- run an FDTD simulation and pull a transmission spectrum::
fdtd = _lum_get("fdtd_main")
fdtd.addrect(name="r1", x=0, x_span=1e-6, y=0, y_span=1e-6, z=0, z_span=1e-6)
fdtd.save("foo.fsp")
fdtd.run()
_lum_print_json(fdtd.getresult("T_monitor", "T"))
The call blocks until the snippet finishes. The lock that serializes
subprocess access is held for the duration, so if a snippet hangs
(infinite loop, unterminated multi-line input, license-server stall),
the agent must dispatch a parallel ``restart_session`` tool call to
recover.get_guidelines_fortool Fetch authoritative Lumerical scripting guidelines (markdown) for one topic.
Fetch authoritative Lumerical scripting guidelines (markdown) for one topic.
Call this tool BEFORE writing any Lumerical Python (lumapi) code, once
per topic you need. Always fetch ``"workflow"`` first (the
product-agnostic execution model and do-not-assume rules), then add
the product-specific topics that match the task.
Parameters
----------
content : str
Topic to retrieve. One of:
- ``"workflow"`` -- product-agnostic execution model: chunked
``execute_python_code`` snippets against the persistent
subprocess, the seeded ``_lum_get`` / ``_lum_print_json``
helpers, per-product ``<handle>.run()`` calling conventions,
and the do-not-assume / do-not-invent / do-not-re-run rules.
Applies to FDTD, MODE, DEVICE, INTERCONNECT.
- ``"sweeps"`` -- product-agnostic ``addsweep`` lifecycle
(parameter sweep, optimization, Monte Carlo, S-parameter,
corner sweep), the dict-as-struct payload convention for
``addsweepparameter`` / ``addsweepresult``, the
``deletesweep`` idempotent-rebuild pattern, and result
extraction via ``getsweepresult``. Applies to FDTD, MODE,
INTERCONNECT.
- ``"pic"`` -- shared photonic simulation hygiene for optical
elements: extending continuing guided structures through PML,
giving ports / mode-solver windows enough wavelength-scale
padding around the confined mode, and avoiding accidental
substrate-mode selection. Applies to FDTD, MODE, and FEEM.
- ``"nested_sweeps"`` -- product-agnostic hierarchical sweep
workflow: build the inner sweep first, wrap it with
``insertsweep``, configure the outer sweep, then run the
outer parent sweep to evaluate all parameter combinations.
- ``"materials"`` -- built-in vs. custom material selection,
the ``addmaterial()`` / ``setmaterial()`` handle pattern,
and anisotropic material input (diagonal + grid-attribute
general anisotropy). Shared by FDTD and MODE.
- ``"geometry"`` -- dictionary-based ``addrect`` / ``addX``
syntax for Lumerical layout objects and the ``"x span"``
(not ``"x_span"``) property-naming convention. Shared by
FDTD, MODE, and DEVICE.
- ``"fdtd_workflow"`` -- FDTD-specific build/setup stages,
disambiguation defaults (3D, PML on all open boundaries, SI
units, built-in materials), and the PML boundary-extension
rule. Pair with ``"fdtd_run_and_results"`` for the
run/results half.
- ``"fdtd_workflow_example"`` -- full worked example (straight
silicon waveguide with TE port S-parameter extraction):
pre-flight default-confirmation checklist followed by Steps
1-8 with the exact ``execute_python_code`` snippet for each
chunk.
- ``"fdtd_sources_monitors"`` -- ``setglobalsource`` /
``setglobalmonitor`` usage (and the no-dict-syntax
exception); prefer ``addport()`` over ``addmode()`` for
S-parameter extraction; port direction convention.
- ``"fdtd_run_and_results"`` -- FDTD-specific ``run()``
arguments (solver / resource / GPU / Ansys Cloud Burst), the
``run()``-once + ``switchtolayout`` rule, the
dataset-is-a-dict contract for ``getresult``, mandatory
``_lum_print_json`` inspection before indexing, the per-port
S vs. full S-matrix distinction, and the
``fdtd.eval("<lsf>;")`` escape hatch.
- ``"fdtd_boundary_conditions"`` -- BC decision guide and
the four FDTD BC families: PML profiles (standard /
stabilized / steep angle / custom), symmetric and
anti-symmetric, periodic, and Bloch (plus when to switch
to the BFAST plane-wave source for broadband angled
incidence).
- ``"fdtd_mesh_and_convergence"`` -- ``"mesh accuracy"``
semantics (ppw vs. integer 1-8), conformal-mesh
refinement variants, ``addmesh`` overrides for thin
features and metals, ``simulation time`` / auto-shutoff
interplay, and divergence diagnostics via the FDTD
solver ``STATUS`` result.
- ``"fdtd_source_types"`` -- non-port source catalog with
a decision tree: ``addplane`` / BFAST plane-wave,
``addgaussian``, ``adddipole``, ``addtfsf``, and
``addimportedsource``; gotchas (TFSF interface
crossings, broadband-angle injection, dipole homogeneous
validation).
- ``"fdtd_monitors_and_field_extraction"`` -- monitor type
decision table (DFT power / profile / time / movie /
index / mode-expansion), ``"override global monitor
settings"`` pattern, mode-expansion analysis, and the
``reduce-before-print`` pattern that keeps 3D fields
from blowing through the ``_lum_print_json`` truncation
guard.
- ``"fdtd_far_field_and_grating"`` -- turning near-field
monitor data into ``farfield2d`` / ``farfield3d`` /
``farfieldexact`` projections, grating-order analysis
(``gratingn1`` / ``gratingn2`` / ``grating`` /
``gratingangle`` / ``gratingpolar``), and NA / cone
filtering via ``farfield3dintegrate``.
- ``"s_parameter_sweep"`` -- full N x N S-matrix extraction
via ``addsweep(3)`` / ``runsweep`` /
``getsweepresult("s-parameter sweep", "S matrix")``, with a
Y-branch worked example (auto symmetry) and Touchstone /
INTERCONNECT export. Shared by FDTD and MODE; fetch whenever
the user asks for the full S-matrix of a multi-port device.
- ``"mode_fde_workflow"`` -- MODE FDE-specific build/setup
workflow: safe ``addfde()`` + ``setnamed()`` configuration,
bent-waveguide keys, active-property caveats, and sweep-safe
reuse of clean pre-run setup files.
- ``"mode_fde_results"`` -- MODE FDE solve/result guidance:
when to use ``findmodes()``, common ``getdata()`` fields
such as ``neff`` / ``loss`` / ``TE polarization fraction`` /
``ng``, and robust TE/TM classification across sweeps.
- ``"mode_eme_workflow"`` -- MODE EME-specific build/setup and
analysis workflow: cell-group setup, matrix-style ``group spans`` /
``cells`` payloads, layout-vs-analysis mode rules,
``emepropagate()`` / ``emesweep()``, port hygiene, and
user-S-matrix interpretation.
- ``"mode_varfdtd_workflow"`` -- MODE varFDTD-specific
build/setup workflow: when to use the 2.5D propagator,
effective-index setup, bandwidth choices, supported source /
monitor classes, and validation of generated effective
materials.
- ``"interconnect_workflow"`` -- INTERCONNECT-specific
build/setup workflow: chunked stages for library validation,
element addition and naming, port discovery, connections,
property discovery, and save/run sequencing.
Fetch for any INTERCONNECT photonic circuit task.
- ``"interconnect_simulation"`` -- INTERCONNECT root element
simulation configuration (``"simulation input"`` mode
selector, time-domain property sets, ONA frequency-domain
workflow) and ``getresult`` discovery pattern for analyzers.
Fetch alongside ``"interconnect_workflow"`` for any
simulation setup or result extraction task.
- ``"interconnect_commands"`` -- INTERCONNECT-specific lumapi
command reference: element library, design kits,
measurements, scripted elements, optimization, and export
commands. Fetch when you need the exact command name or
signature for an INTERCONNECT operation.
- ``"device_workflow"`` -- finite-element IDE (DEVICE) workflow
shared by HEAT, CHARGE, FEEM, and DGTD: chunked stages for
model-material creation, geometry, solver addition, simulation-
region linkage, boundary conditions (children of the solver's
``boundary conditions`` object), monitors (children of the
solver object), run, and result collection from both monitors
and the solver object itself.
- ``"device_materials"`` -- model-material creation via
``addmodelmaterial`` / ``addmaterialproperties``, property
families (EM / CT / HT), selection hygiene after each
``addmaterialproperties`` call, and database discovery.
Shared by HEAT, CHARGE, FEEM, and DGTD.
- ``"device_simulation_region"`` -- simulation-region
ownership model (region is separate from the solver object),
per-face boundary types (Open / Closed / Shell), background
material, and linking the region to a solver via
``setnamed(solver, "simulation region", region_name)``.
Shared by HEAT, CHARGE, FEEM, and DGTD.list_sessionstool List currently open Lumerical sessions (metadata only).
List currently open Lumerical sessions (metadata only).
The returned list reflects the MCP server's view of registered sessions.
To verify the live subprocess registry, use ``execute_python_code`` with
``_lum_print_json(_lum_list())``.open_sessiontool Open a Lumerical CAD session and register it under ``name``.FilesEnv vars
Open a Lumerical CAD session and register it under ``name``.
Multiple sessions of any product type may be open concurrently. Each is
addressable by the ``name`` you choose here. Returns a JSON-safe dictionary
envelope (delivered to the client as MCP ``structuredContent``) with
success/failure plus session metadata. Common failures include duplicate
name, invalid product, and license-server errors.
The call blocks until the subprocess finishes the open. If a Lumerical
product wedges (such as a license-server hang), dispatch a parallel
``restart_session`` tool call to recover.restart_sessiontool Restart the persistent Python subprocess that hosts all Lumerical sessions.
Restart the persistent Python subprocess that hosts all Lumerical sessions.
Use this when a previous tool call appears stuck. Typical triggers are
an unterminated multi-line snippet sent to ``execute_python_code``, an
infinite loop in user code, or a license-server/Lumerical handshake
that has wedged. Since :meth:`LumericalPersistentPythonSession.execute`
blocks indefinitely (see :mod:`ansys.lumerical.mcp.persistent_session`),
this tool is the agent-visible recovery path.
Because blocking ``execute`` calls run on worker threads, this coroutine
can run while a previous ``execute_python_code`` is still blocked. The
restart kills the wedged subprocess, so that blocked call also returns
shortly after (with an error envelope, since its subprocess died).
Side effects
------------
- The persistent subprocess is terminated (gracefully if possible,
forcefully otherwise) and a fresh one is spawned. The
``LUMERICAL_STARTUP_CODE`` startup snippet is re-executed in the new
subprocess.
- All live Lumerical handles previously hosted by the subprocess are
destroyed. There is no automatic re-open: the agent must call
:func:`open_session` for any session it still needs.
- The MCP-level ``lifespan_context.sessions`` metadata registry is cleared,
since every entry refers to a Lumerical handle that lived in the now-dead
subprocess. The cleared names are returned in the response envelope
so the agent can re-open them if desired.
Returns
-------
dict[str, Any]
JSON-safe envelope dictionary. On success the ``data`` payload contains
``{"restarted": True, "cleared_sessions": [<names>]}``. On failure
the envelope is the standard ``{"success": False, "error": "..."}``.
FastMCP forwards this dictionary as MCP ``structuredContent`` so MCP
clients see it as a parsed JSON object (no double escaping).Text the model reads (8)
Every tool, prompt and resource description as written in the code: the model sees all of it, the user usually does not.
get_guidelines_for tool
Fetch authoritative Lumerical scripting guidelines (markdown) for one topic.
Call this tool BEFORE writing any Lumerical Python (lumapi) code, once
per topic you need. Always fetch ``"workflow"`` first (the
product-agnostic execution model and do-not-assume rules), then add
the product-specific topics that match the task.
Parameters
----------
content : str
Topic to retrieve. One of:
- ``"workflow"`` -- product-agnostic execution model: chunked
``execute_python_code`` snippets against the persistent
subprocess, the seeded ``_lum_get`` / ``_lum_print_json``
helpers, per-product ``<handle>.run()`` calling conventions,
and the do-not-assume / do-not-invent / do-not-re-run rules.
Applies to FDTD, MODE, DEVICE, INTERCONNECT.
- ``"sweeps"`` -- product-agnostic ``addsweep`` lifecycle
(parameter sweep, optimization, Monte Carlo, S-parameter,
corner sweep), the dict-as-struct payload convention for
``addsweepparameter`` / ``addsweepresult``, the
``deletesweep`` idempotent-rebuild pattern, and result
extraction via ``getsweepresult``. Applies to FDTD, MODE,
INTERCONNECT.
- ``"pic"`` -- shared photonic simulation hygiene for optical
elements: extending continuing guided structures through PML,
giving ports / mode-solver windows enough wavelength-scale
padding around the confined mode, and avoiding accidental
substrate-mode selection. Applies to FDTD, MODE, and FEEM.
- ``"nested_sweeps"`` -- product-agnostic hierarchical sweep
workflow: build the inner sweep first, wrap it with
``insertsweep``, configure the outer sweep, then run the
outer parent sweep to evaluate all parameter combinations.
- ``"materials"`` -- built-in vs. custom material selection,
the ``addmaterial()`` / ``setmaterial()`` handle pattern,
and anisotropic material input (diagonal + grid-attribute
general anisotropy). Shared by FDTD and MODE.
- ``"geometry"`` -- dictionary-based ``addrect`` / ``addX``
syntax for Lumerical layout objects and the ``"x span"``
(not ``"x_span"``) property-naming convention. Shared by
FDTD, MODE, and DEVICE.
- ``"fdtd_workflow"`` -- FDTD-specific build/setup stages,
disambiguation defaults (3D, PML on all open boundaries, SI
units, built-in materials), and the PML boundary-extension
rule. Pair with ``"fdtd_run_and_results"`` for the
run/results half.
- ``"fdtd_workflow_example"`` -- full worked example (straight
silicon waveguide with TE port S-parameter extraction):
pre-flight default-confirmation checklist followed by Steps
1-8 with the exact ``execute_python_code`` snippet for each
chunk.
- ``"fdtd_sources_monitors"`` -- ``setglobalsource`` /
``setglobalmonitor`` usage (and the no-dict-syntax
exception); prefer ``addport()`` over ``addmode()`` for
S-parameter extraction; port direction convention.
- ``"fdtd_run_and_results"`` -- FDTD-specific ``run()``
arguments (solver / resource / GPU / Ansys Cloud Burst), the
``run()``-once + ``switchtolayout`` rule, the
dataset-is-a-dict contract for ``getresult``, mandatory
``_lum_print_json`` inspection before indexing, the per-port
S vs. full S-matrix distinction, and the
``fdtd.eval("<lsf>;")`` escape hatch.
- ``"fdtd_boundary_conditions"`` -- BC decision guide and
the four FDTD BC families: PML profiles (standard /
stabilized / steep angle / custom), symmetric and
anti-symmetric, periodic, and Bloch (plus when to switch
to the BFAST plane-wave source for broadband angled
incidence).
- ``"fdtd_mesh_and_convergence"`` -- ``"mesh accuracy"``
semantics (ppw vs. integer 1-8), conformal-mesh
refinement variants, ``addmesh`` overrides for thin
features and metals, ``simulation time`` / auto-shutoff
interplay, and divergence diagnostics via the FDTD
solver ``STATUS`` result.
- ``"fdtd_source_types"`` -- non-port source catalog with
a decision tree: ``addplane`` / BFAST plane-wave,
``addgaussian``, ``adddipole``, ``addtfsf``, and
``addimportedsource``; gotchas (TFSF interface
crossings, broadband-angle injection, dipole homogeneous
validation).
- ``"fdtd_monitors_and_field_extraction"`` -- monitor type
decision table (DFT power / profile / time / movie /
index / mode-expansion), ``"override global monitor
settings"`` pattern, mode-expansion analysis, and the
``reduce-before-print`` pattern that keeps 3D fields
from blowing through the ``_lum_print_json`` truncation
guard.
- ``"fdtd_far_field_and_grating"`` -- turning near-field
monitor data into ``farfield2d`` / ``farfield3d`` /
``farfieldexact`` projections, grating-order analysis
(``gratingn1`` / ``gratingn2`` / ``grating`` /
``gratingangle`` / ``gratingpolar``), and NA / cone
filtering via ``farfield3dintegrate``.
- ``"s_parameter_sweep"`` -- full N x N S-matrix extraction
via ``addsweep(3)`` / ``runsweep`` /
``getsweepresult("s-parameter sweep", "S matrix")``, with a
Y-branch worked example (auto symmetry) and Touchstone /
INTERCONNECT export. Shared by FDTD and MODE; fetch whenever
the user asks for the full S-matrix of a multi-port device.
- ``"mode_fde_workflow"`` -- MODE FDE-specific build/setup
workflow: safe ``addfde()`` + ``setnamed()`` configuration,
bent-waveguide keys, active-property caveats, and sweep-safe
reuse of clean pre-run setup files.
- ``"mode_fde_results"`` -- MODE FDE solve/result guidance:
when to use ``findmodes()``, common ``getdata()`` fields
such as ``neff`` / ``loss`` / ``TE polarization fraction`` /
``ng``, and robust TE/TM classification across sweeps.
- ``"mode_eme_workflow"`` -- MODE EME-specific build/setup and
analysis workflow: cell-group setup, matrix-style ``group spans`` /
``cells`` payloads, layout-vs-analysis mode rules,
``emepropagate()`` / ``emesweep()``, port hygiene, and
user-S-matrix interpretation.
- ``"mode_varfdtd_workflow"`` -- MODE varFDTD-specific
build/setup workflow: when to use the 2.5D propagator,
effective-index setup, bandwidth choices, supported source /
monitor classes, and validation of generated effective
materials.
- ``"interconnect_workflow"`` -- INTERCONNECT-specific
build/setup workflow: chunked stages for library validation,
element addition and naming, port discovery, connections,
property discovery, and save/run sequencing.
Fetch for any INTERCONNECT photonic circuit task.
- ``"interconnect_simulation"`` -- INTERCONNECT root element
simulation configuration (``"simulation input"`` mode
selector, time-domain property sets, ONA frequency-domain
workflow) and ``getresult`` discovery pattern for analyzers.
Fetch alongside ``"interconnect_workflow"`` for any
simulation setup or result extraction task.
- ``"interconnect_commands"`` -- INTERCONNECT-specific lumapi
command reference: element library, design kits,
measurements, scripted elements, optimization, and export
commands. Fetch when you need the exact command name or
signature for an INTERCONNECT operation.
- ``"device_workflow"`` -- finite-element IDE (DEVICE) workflow
shared by HEAT, CHARGE, FEEM, and DGTD: chunked stages for
model-material creation, geometry, solver addition, simulation-
region linkage, boundary conditions (children of the solver's
``boundary conditions`` object), monitors (children of the
solver object), run, and result collection from both monitors
and the solver object itself.
- ``"device_materials"`` -- model-material creation via
``addmodelmaterial`` / ``addmaterialproperties``, property
families (EM / CT / HT), selection hygiene after each
``addmaterialproperties`` call, and database discovery.
Shared by HEAT, CHARGE, FEEM, and DGTD.
- ``"device_simulation_region"`` -- simulation-region
ownership model (region is separate from the solver object),
per-face boundary types (Open / Closed / Shell), background
material, and linking the region to a solver via
``setnamed(solver, "simulation region", region_name)``.
Shared by HEAT, CHARGE, FEEM, and DGTD.open_session tool
Open a Lumerical CAD session and register it under ``name``.
Multiple sessions of any product type may be open concurrently. Each is
addressable by the ``name`` you choose here. Returns a JSON-safe dictionary
envelope (delivered to the client as MCP ``structuredContent``) with
success/failure plus session metadata. Common failures include duplicate
name, invalid product, and license-server errors.
The call blocks until the subprocess finishes the open. If a Lumerical
product wedges (such as a license-server hang), dispatch a parallel
``restart_session`` tool call to recover.close_session tool
Close a Lumerical session and remove it from the registry.
Bounded by :data:`_CLOSE_SESSION_TIMEOUT_S`. On timeout, returns a
failure envelope with ``timed_out=True`` and ``retained=True`` so the
agent can dispatch ``restart_session`` to recover. The orphaned worker
thread is left to drain on its own (asyncio cannot cancel it).list_sessions tool
List currently open Lumerical sessions (metadata only).
The returned list reflects the MCP server's view of registered sessions.
To verify the live subprocess registry, use ``execute_python_code`` with
``_lum_print_json(_lum_list())``.execute_python_code tool
Execute Python in the persistent subprocess that hosts all Lumerical sessions.
Pre-loaded into the subprocess globals:
- Imports: ``FDTD``, ``MODE``, ``DEVICE``, ``INTERCONNECT`` from ``ansys.lumerical.core``
- Registry: ``_lumerical_sessions: dict[str, Lumerical]`` (live handles)
- Helpers:
* ``_lum_open(name, product, filename=None, hide=False)`` -- prefer
the ``open_session`` MCP tool over calling this helper directly
* ``_lum_close(name)``
* ``_lum_get(name)`` -- returns the live handle for ``name``
* ``_lum_list()``
* ``_lum_print_json(obj, *, max_array_size=200_000, indent=None)``
DATA-RETURN CONTRACT: only ``print()``-ed text leaves the subprocess. For
structured data (numpy arrays, dictionaries, Lumerical results), use
``_lum_print_json(...)``. It handles numpy/complex/dict/list with a
size guard that truncates arrays larger than ``max_array_size`` to
``{shape, dtype, preview}`` so the LLM context window doesn't get blown
up by multi-MB field data.
Example -- run an FDTD simulation and pull a transmission spectrum::
fdtd = _lum_get("fdtd_main")
fdtd.addrect(name="r1", x=0, x_span=1e-6, y=0, y_span=1e-6, z=0, z_span=1e-6)
fdtd.save("foo.fsp")
fdtd.run()
_lum_print_json(fdtd.getresult("T_monitor", "T"))
The call blocks until the snippet finishes. The lock that serializes
subprocess access is held for the duration, so if a snippet hangs
(infinite loop, unterminated multi-line input, license-server stall),
the agent must dispatch a parallel ``restart_session`` tool call to
recover.restart_session tool
Restart the persistent Python subprocess that hosts all Lumerical sessions.
Use this when a previous tool call appears stuck. Typical triggers are
an unterminated multi-line snippet sent to ``execute_python_code``, an
infinite loop in user code, or a license-server/Lumerical handshake
that has wedged. Since :meth:`LumericalPersistentPythonSession.execute`
blocks indefinitely (see :mod:`ansys.lumerical.mcp.persistent_session`),
this tool is the agent-visible recovery path.
Because blocking ``execute`` calls run on worker threads, this coroutine
can run while a previous ``execute_python_code`` is still blocked. The
restart kills the wedged subprocess, so that blocked call also returns
shortly after (with an error envelope, since its subprocess died).
Side effects
------------
- The persistent subprocess is terminated (gracefully if possible,
forcefully otherwise) and a fresh one is spawned. The
``LUMERICAL_STARTUP_CODE`` startup snippet is re-executed in the new
subprocess.
- All live Lumerical handles previously hosted by the subprocess are
destroyed. There is no automatic re-open: the agent must call
:func:`open_session` for any session it still needs.
- The MCP-level ``lifespan_context.sessions`` metadata registry is cleared,
since every entry refers to a Lumerical handle that lived in the now-dead
subprocess. The cleared names are returned in the response envelope
so the agent can re-open them if desired.
Returns
-------
dict[str, Any]
JSON-safe envelope dictionary. On success the ``data`` payload contains
``{"restarted": True, "cleared_sessions": [<names>]}``. On failure
the envelope is the standard ``{"success": False, "error": "..."}``.
FastMCP forwards this dictionary as MCP ``structuredContent`` so MCP
clients see it as a parsed JSON object (no double escaping).pylumerical_system_prompt prompt
Return the system prompt for the PyLumerical MCP server.
Returns
-------
str
The product-agnostic system prompt text.list_tool_sets resource
Toolset definitions consumed by MCP clients and Ansys product UIs.
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 — 8 tool handlers traced
- Executes caller-supplied codeNo tool evaluates code the caller supplies — 8 tool handlers traced
- Reads or writes any file pathNo tool works on a file path the caller supplies without a root check — 8 tool handlers traced
- Requests any addressNo tool sends a request to an address the caller supplies — 8 tool handlers traced
- Runs caller-supplied SQLNo tool executes a query the caller supplies — 8 tool handlers traced
- Tools that start processesNot seen in the traced code of 8 capabilities; 6 more call code the scanner could not follow, where it may happen
- Tools that touch files1 of 8 capabilities touch files; 5 more call code the scanner could not follow, where it may happen
- Tools that call the networkNot seen in the traced code of 8 capabilities; 6 more call code the scanner could not follow, where it may happen
Where the code is: 8 handlers in 3 files at commit 0d6f3735f9c8
- 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 versionNo MCP SDK declared in a manifest
- 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 8 capabilities; 6 more call code the scanner could not follow, where it may happen
- Environment variables1 capability reads environment variables (often API keys)
- 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 |
The project's own security
| Security policy | yes SECURITY.md |
|---|---|
| Private reporting | the policy does not name a private channel |
| Past advisories | none in the GitHub Advisory Database |
| Last push | 2026-11-10 |
| Signed releases | not checked yet |
Where it is published
| Listed in | 1 catalog (github_search) |
|---|---|
| License | Apache-2.0 |
| Created | 2026-06-30 |
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.