ZayMCP
An MCP server for Ansys Zemax OpticStudio 2024 R2.
Unofficial project. ZayMCP is an independent project. It is not developed, maintained, endorsed, or affiliated with Ansys or Zemax, and it does not represent Ansys Zemax OpticStudio or its publisher. “Ansys”, “Zemax”, and “OpticStudio” are trademarks of their respective owners, used here only to identify the product this server connects to.
Requirements
- Windows
- Ansys Zemax OpticStudio 2024 R2
- Python 3.12 or newer
- uv
Quick start
Configure the MCP server
Register the server with the host. OPTICSTUDIO_DIRECTORY is the directory that contains OpticStudio.exe. The server uses it when Zemax's helper cannot find the installation.
{
"mcpServers": {
"zaymcp": {
"command": "uvx",
"args": ["zaymcp"],
"env": {
"OPTICSTUDIO_DIRECTORY": "<path-to-OpticStudio>"
}
}
}
}
Open Interactive Extension
In OpticStudio, open Programming → ZOS-API.NET Applications → Interactive Extension. A dialog opens and OpticStudio waits for this server. Only one external program can be connected at a time. Leave the dialog open before the host starts the server.
Example
examples/001-simple-singlet.md is a complete task: design a positive N-BK7 singlet, from a new lens through local optimization.
Tools
Each tool's arguments and return fields travel with the tool schema the host receives.
Session
| Tool | Description |
|---|---|
get_opticstudio_version |
Return the product version, license, and connection details. |
File
| Tool | Description |
|---|---|
new_lens |
Replace the open lens with a new lens. Unsaved changes stay unless you discard them. |
get_lens_metadata |
Return the lens path, title, mode, and whether the window has unsaved changes. |
save_lens |
Save the current file, or save it to a new path. |
Setup
| Tool | Description |
|---|---|
get_system_settings |
Read one System Explorer group: units, aperture, fields, wavelengths, environment, polarization, or ray aiming. |
set_system_settings |
Change keys in one of those groups. |
set_system_rows |
Change, add, or remove a field point or wavelength, or choose the primary wavelength. |
get_lens_data |
Read the Lens Data Editor, or one surface. |
set_lens_rows |
Change, insert, or remove one surface. |
get_multi_configuration |
Read the Multi-Configuration Editor, or one operand. |
set_multi_configuration_rows |
Change an operand or a configuration, including which configuration is current. |
Optimize
| Tool | Description |
|---|---|
get_merit_function |
Read the Merit Function Editor, or one operand. |
set_merit_rows |
Change, insert, or remove one operand. |
calculate_merit_function |
Calculate the merit function. |
apply_optimization_wizard |
Apply the Optimization Wizard and return the operands it creates. |
run_local_optimization |
Run local optimization and return the merit function before and after. |
Analyze
| Tool | Description |
|---|---|
get_first_order |
Return effective focal length, entrance pupil diameter, F-numbers, and total length. |
get_single_ray_trace |
Trace one ray and return the Single Ray Trace table. |
Connection
A host launches this server against the OpticStudio window that is waiting on Interactive Extension. The tools work on the lens open in that window, and the window stays on screen. The connection lasts for the life of the server process.
When OpticStudio cannot answer a call, the server closes the connection. The next call opens a new one, which needs the Interactive Extension dialog to be waiting again. Auto Close on Disconnect is on by default, so the dialog closes when the connection ends. Open Interactive Extension again before the next session. Stopping the host closes the connection the same way.
Development
Clone the repository and create the environment:
git clone https://github.com/GjQAQ/ZayMCP.git
cd ZayMCP
uv sync
To run this checkout instead of the published package, point the host at it:
{
"mcpServers": {
"zaymcp-dev": {
"command": "uv",
"args": [
"run",
"--project",
"<path-to-checkout>",
"zaymcp"
],
"env": {
"OPTICSTUDIO_DIRECTORY": "<path-to-OpticStudio>"
}
}
}
}
Development conventions are in CONTRIBUTING.md. Lasting decisions are recorded in docs/adr.
License
MIT © 2026 Jiaqi Guo
Metadata
Release files for zaymcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zaymcp-0.1.0.tar.gz | 50.2 kB | With provenance | Details for zaymcp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zaymcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for zaymcp-0.1.0-py3-none-any.whl |
Total release size: 114.7 kB
Release files / zaymcp-0.1.0.tar.gz
| Download URL | zaymcp-0.1.0.tar.gz |
|---|---|
| Size | 50.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f970d0e0f484f966f6e54856533073016c99e2ab25d5b434570fea5e29755d59
|
|
BLAKE2b-256 checksum How to use checksums |
ddd1719591ac757ddfadbf3c901fb7ace01063ee3afc3fb1ee4e5042990583f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / zaymcp-0.1.0-py3-none-any.whl
| Download URL | zaymcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 64.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e89e7b9c76986bea9fcbd321ec0af7f5351b16b0198dc9c5d04611fc91b2cca1
|
|
BLAKE2b-256 checksum How to use checksums |
e49afa3fd066e17aafdd3e16bfb7da10c8d159e09c9f0476cb22a7467f95014b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logSecurity for zaymcp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for zaymcp-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.