Artificial Intelligence models have rapidly become a prominent tool in every engineer’s toolbox. However, without the correct information, context, or access to software, AI can often provide inaccurate answers or guide users down time consuming debug sessions that don’t necessarily have a successful outcome.
By providing AI with Model Context Protocols (MCP), the outputs, errors, or internal workings of software can be visible to the AI. This dramatically improves the solution quality that the AI model can synthesize.
What is MCP?
Model Context Protocol (MCP) are a standard protocol for AI models that allow them to connect to external tools, data sources, and services. It allows developers to hook apps or services onto standardized integration code. This removes the need to create custom code for every tool, app, or service for connecting to AI models.
For users, adding an MCP will improve an AI model’s capability to interact or utilize the given tool. In Lumerical’s case, it allows AI models to know if objects are placed correctly, perform test cases, and readout detailed errors. The result is a more insightful AI with self-testing abilities.
How to Install Lumerical MCP
Installation can be done through PyPI. First upgrade pip, then directly install the Lumerical MCP:
python -m pip install -U pip
pip install ansys-lumerical-mcpInstructions for different installation methods are available at: Installation — PyLumerical MCP
Using Lumerical MCP
To use the MCP, first launch the MCP in a Windows Command Line using the command:
ansys-lumerical-mcpOnce ready, the MCP should indicate it is running and waiting for a connection:

We can close this for now, as the AI models will automatically run that MCP in the background once properly connected. The next step is to set up the model connection. This process is different for each AI and the easiest way is to prompt the AI for instructions to connect to a MCP. In this demonstration we will use Claude. The process simply requires us to input the folder path to the settings. Of course, the AI can be prompted to perform this task automatically for you.

Once properly configured, you can prompt your AI and ask if the Lumerical MCP is available for it to access. It should confirm it is available and within its toolkit.
Performance
With the MCP, the Sonnet 4.6 model creates reliable model setups. We prompted the model with the following:
AI Prompt: Using Lumerical MCP, build me a 3D simulation for a grating coupler. I want the simulation to be parameterized: List and confirm the parameters to me before proceeding.
Check and let me know if it is possible for you to add user parameters.
The model was then able to produce a full model geometry with user properties. It also generated scripts to connect the user properties to the geometry:

Structure Group User Properties:

Structure Group Script:
deleteall;
# Read user parameters from structure group properties
period = grating_period;
dc = duty_cycle;
depth = etch_depth;
N = round(num_teeth);
width = grating_width;
# Fixed (SOI standard)
si_t = 220e-9;
# Derived
tooth_w = period * dc;
gap_w = period * (1 - dc);
# --- Full Si slab (grating region base) ---
addrect;
set("name", "grating_slab");
set("x min", 0);
set("x max", N * period);
set("y", 0);
set("y span", width);
set("z min", 0);
set("z max", si_t);
set("material", "Si (Silicon) - Palik");
# --- Partial-etch trenches (SiO2-filled), one per period ---
for(i = 0; i < N; i = i + 1) {
x_center = i*period + tooth_w + gap_w/2;
addrect;
set("name", "etch_" + num2str(i));
set("x", x_center);
set("x span", gap_w);
set("y", 0);
set("y span", width);
set("z min", si_t - depth);
set("z max", si_t);
set("material", "SiO2 (Glass) - Palik");
}
Another useful task that Lumerical and AI can perform is transforming existing simulation into setup scripts. We prompted our Sonnet 4.6 with the following:
AI Prompt: Using Lumerical MCP, make me a setup LSF script of the grating_couper.fsp. Make sure to include the user properties and script for the gratings section.
This is useful for transferring designs between different Lumerical tools (FDE, FDTD, Multiphysics) while still maintaining scripts for structure groups.
Below is the generated setup LSF script:
Script Details
# =============================================================================
# 3D SOI Grating Coupler - Setup LSF Script
# Reference: build_grating_coupler_fsp.py
#
# Structure:
# - Si substrate / SiO2 BOX (2 um) / Si 220 nm device layer / SiO2 cladding
# - Linear taper: 500 nm -> 10 um (SMF-28 fiber MFD match)
# - Partial-etch grating (70 nm etch, 150 nm Si remaining) in structure group
# - Angled Gaussian fiber source (8 deg, SMF-28 waist 5.2 um)
# - TE mode source at waveguide input
# - Sweeps: grating_period (2 pts) x duty_cycle (5 pts)
# =============================================================================
newproject;
# ============================================================================
# DESIGN PARAMETERS
# ============================================================================
um = 1e-6;
nm = 1e-9;
# SOI layer stack
SI_THICKNESS = 220 * nm;
BOX_THICKNESS = 2 * um;
CLAD_THICKNESS = 2.2 * um;
SUBS_THICKNESS = 1 * um;
# Grating (nominal) — Bragg: p = lambda/(n_eff - n_SiO2*sin(theta)) ~ 630 nm
GRATING_PERIOD = 630 * nm;
DUTY_CYCLE = 0.50;
ETCH_DEPTH = 70 * nm;
NUM_TEETH = 20;
# Waveguide / taper
WG_WIDTH = 500 * nm;
GRATING_WIDTH = 10 * um;
TAPER_LENGTH = 20 * um;
# Fiber (Gaussian source, SMF-28)
FIBER_ANGLE = 8.0;
FIBER_WAIST = 5.2 * um;
# Optical
WL_CENTER = 1550 * nm;
WL_SPAN = 200 * nm;
WL_START = WL_CENTER - WL_SPAN / 2;
WL_STOP = WL_CENTER + WL_SPAN / 2;
# Simulation
MESH_ACCURACY = 2;
# Derived geometry
GRATING_LENGTH = NUM_TEETH * GRATING_PERIOD;
TAPER_X0 = 0.0;
GRATING_X0 = TAPER_LENGTH;
GRATING_X1 = GRATING_X0 + GRATING_LENGTH;
FIBER_X = GRATING_X0 + GRATING_LENGTH / 2;
# Parameter sweep ranges
PERIOD_START = 550 * nm;
PERIOD_STOP = 700 * nm;
PERIOD_POINTS = 2;
DC_START = 0.40;
DC_STOP = 0.60;
DC_POINTS = 5;
# ============================================================================
# 1. LAYER STACK (background materials)
# ============================================================================
addrect;
set("name", "si_substrate");
set("x min", -6 * um); set("x max", GRATING_X1 + 3 * um);
set("y", 0); set("y span", GRATING_WIDTH + 10 * um);
set("z min", -(BOX_THICKNESS + SUBS_THICKNESS));
set("z max", -BOX_THICKNESS);
set("material", "Si (Silicon) - Palik");
addrect;
set("name", "box_layer");
set("x min", -6 * um); set("x max", GRATING_X1 + 3 * um);
set("y", 0); set("y span", GRATING_WIDTH + 10 * um);
set("z min", -BOX_THICKNESS);
set("z max", 0);
set("material", "SiO2 (Glass) - Palik");
addrect;
set("name", "top_cladding");
set("x min", -6 * um); set("x max", GRATING_X1 + 3 * um);
set("y", 0); set("y span", GRATING_WIDTH + 10 * um);
set("z min", 0);
set("z max", SI_THICKNESS + CLAD_THICKNESS);
set("material", "SiO2 (Glass) - Palik");
# ============================================================================
# 2. WAVEGUIDE + TAPER
# ============================================================================
# Straight input waveguide (500 nm wide)
addrect;
set("name", "input_waveguide");
set("x min", -5 * um); set("x max", TAPER_X0);
set("y", 0); set("y span", WG_WIDTH);
set("z min", 0);
set("z max", SI_THICKNESS);
set("material", "Si (Silicon) - Palik");
# Linear taper: 500 nm -> 10 um (trapezoid polygon, vertices as [x, y] rows)
V = [TAPER_X0, -WG_WIDTH / 2;
TAPER_X0, WG_WIDTH / 2;
TAPER_X0 + TAPER_LENGTH, GRATING_WIDTH / 2;
TAPER_X0 + TAPER_LENGTH, -GRATING_WIDTH / 2];
addpoly;
set("name", "input_taper");
set("vertices", V);
set("z min", 0);
set("z max", SI_THICKNESS);
set("material", "Si (Silicon) - Palik");
# ============================================================================
# 3. GRATING STRUCTURE GROUP
# User properties are visible in the Objects Tree and targeted by sweeps.
# The setup script rebuilds ALL grating teeth whenever a parameter changes.
# ============================================================================
addstructuregroup;
set("name", "grating_coupler");
set("x", GRATING_X0); # group origin = start of grating region
set("y", 0);
set("z", 0);
# --- User-defined parameters ---
# adduserprop(name, type, default_value)
# type 0 = dimensionless number
# type 2 = length (meters, displayed with unit conversion in GUI)
adduserprop("grating_period", 2, GRATING_PERIOD);
adduserprop("duty_cycle", 0, DUTY_CYCLE);
adduserprop("etch_depth", 2, ETCH_DEPTH);
adduserprop("num_teeth", 0, NUM_TEETH);
adduserprop("grating_width", 2, GRATING_WIDTH);
# --- Setup script ---
# Lumerical re-executes this script every time any user parameter changes,
# rebuilding the entire grating geometry from scratch (deleteall first).
# Inner set() calls use single quotes to avoid conflict with the outer string.
setup_script =
"deleteall;
# Read user parameters from structure group properties
period = grating_period;
dc = duty_cycle;
depth = etch_depth;
N = round(num_teeth);
width = grating_width;
# Fixed (SOI standard 220 nm platform)
si_t = 220e-9;
# Derived tooth/gap widths
tooth_w = period * dc;
gap_w = period * (1 - dc);
# --- Full Si slab (grating region base, partial-etch platform) ---
addrect;
set('name', 'grating_slab');
set('x min', 0);
set('x max', N * period);
set('y', 0);
set('y span', width);
set('z min', 0);
set('z max', si_t);
set('material', 'Si (Silicon) - Palik');
# --- Partial-etch trenches (SiO2-filled), one per grating period ---
for(i = 0; i < N; i = i + 1) {
x_center = i*period + tooth_w + gap_w/2;
addrect;
set('name', 'etch_' + num2str(i));
set('x', x_center);
set('x span', gap_w);
set('y', 0);
set('y span', width);
set('z min', si_t - depth);
set('z max', si_t);
set('material', 'SiO2 (Glass) - Palik');
}
";
set("script", setup_script);
# ============================================================================
# 4. FDTD SIMULATION REGION
# ============================================================================
addfdtd;
set("x min", -4 * um); set("x max", GRATING_X1 + 1 * um);
set("y", 0); set("y span", GRATING_WIDTH + 4 * um);
set("z min", -(BOX_THICKNESS + 0.5 * um));
set("z max", SI_THICKNESS + 2.5 * um);
set("mesh accuracy", MESH_ACCURACY);
set("simulation time", 5000e-15);
set("background material", "SiO2 (Glass) - Palik");
# ============================================================================
# 5. SOURCES
# ============================================================================
# TE mode source at waveguide input
addmode;
set("name", "waveguide_port");
set("injection axis", "x-axis");
set("direction", "Forward");
set("x", -3 * um);
set("y", 0); set("y span", WG_WIDTH + 1 * um);
set("z", SI_THICKNESS / 2); set("z span", SI_THICKNESS + 1 * um);
set("wavelength start", WL_START);
set("wavelength stop", WL_STOP);
set("mode selection", "fundamental TE mode");
# Angled Gaussian fiber source (SMF-28, 8 deg tilt from vertical, pointing down)
addgaussian;
set("name", "fiber_source");
set("injection axis", "z-axis");
set("direction", "Backward");
set("x", FIBER_X); set("x span", GRATING_LENGTH + 4 * um);
set("y", 0); set("y span", GRATING_WIDTH + 4 * um);
set("z", SI_THICKNESS + 2 * um);
set("wavelength start", WL_START);
set("wavelength stop", WL_STOP);
set("angle theta", FIBER_ANGLE);
set("angle phi", 0.0);
set("waist radius w0", FIBER_WAIST);
# ============================================================================
# 6. MONITORS
# ============================================================================
# Power monitor above grating — captures diffracted power toward fiber
addpower;
set("name", "fiber_port");
set("monitor type", "2D Z-normal");
set("x", FIBER_X); set("x span", GRATING_LENGTH + 2 * um);
set("y", 0); set("y span", GRATING_WIDTH + 2 * um);
set("z", SI_THICKNESS + 1.8 * um);
set("override global monitor settings", true);
set("frequency points", 50);
# Mode expansion monitor at waveguide — coupling efficiency into guided TE mode
addmodeexpansion;
set("name", "waveguide_transmission");
set("monitor type", "2D X-normal");
set("x", -3 * um);
set("y", 0); set("y span", WG_WIDTH + 1 * um);
set("z", SI_THICKNESS / 2); set("z span", SI_THICKNESS + 1 * um);
set("override global monitor settings", true);
set("frequency points", 50);
# E-field profile in xz plane (y=0 cross-section through grating center)
addprofile;
set("name", "field_xz");
set("monitor type", "2D Y-normal");
set("x min", -4 * um); set("x max", GRATING_X1 + 1 * um);
set("y", 0);
set("z min", -BOX_THICKNESS); set("z max", SI_THICKNESS + 2 * um);
set("override global monitor settings", true);
set("frequency points", 3);
# ============================================================================
# 7. PARAMETER SWEEPS
# Both sweeps target structure group user params so the setup script
# reruns and ALL grating teeth rebuild correctly for every sweep point.
#
# period_sweep: grating_period 550-700 nm, 2 pts
# dutycycle_sweep: duty_cycle 0.40-0.60, 5 pts
# Total: 10 simulations
# ============================================================================
# --- Period sweep ---
addsweep(0);
setsweep("sweep", "name", "period_sweep");
setsweep("period_sweep", "type", "Ranges");
setsweep("period_sweep", "number of points", PERIOD_POINTS);
param_period = struct;
param_period.parameter = "::model::grating_coupler::grating_period";
param_period.type = "Length";
param_period.start = PERIOD_START;
param_period.stop = PERIOD_STOP;
addsweepparameter("period_sweep", param_period);
addsweepresult("period_sweep", "fiber_port");
# --- Duty-cycle sweep ---
addsweep(0);
setsweep("sweep", "name", "dutycycle_sweep");
setsweep("dutycycle_sweep", "type", "Ranges");
setsweep("dutycycle_sweep", "number of points", DC_POINTS);
param_dc = struct;
param_dc.parameter = "::model::grating_coupler::duty_cycle";
param_dc.type = "Number";
param_dc.start = DC_START;
param_dc.stop = DC_STOP;
addsweepparameter("dutycycle_sweep", param_dc);
addsweepresult("dutycycle_sweep", "fiber_port");
# ============================================================================
# 8. SAVE
# ============================================================================
save("grating_coupler.fsp");
Conclusion: Streamlining Photonic Simulation with AI
Integrating AI assistants with Ansys Lumerical through MCP opens new opportunities to simplify photonic simulation workflows. As demonstrated in this grating coupler example, AI can assist with creating parameterized simulation models, generating setup scripts, and translating existing designs into reusable workflows.
While engineering review and simulation validation remain essential, Ansys Lumerical MCP can reduce repetitive setup tasks and help engineers spend more time evaluating and refining their designs.
Explore AI-Assisted Photonic Simulation Workflows
Looking to streamline your photonic simulation and scripting workflows? SimuTech Group’s photonics engineering experts can help you optimize Lumerical models, develop automated workflows, and improve simulation efficiency.
Explore Our Photonics Consulting Services to learn how we can support your next project.







