Skip to main content

RayCrafter

Python Version PyPI Version License Build Status Code style: Ruff pre-commit codecov

RayCrafter is an early proof of principle for a lens-level optical design tool. You place off-the-shelf lenses on an optical axis, drag them around, and see the spot diagram, through-focus curve, MTF, ray fan, field curvature and distortion update as you go. The ray tracing is done by Optiland.

  • Lenses: the Thorlabs spherical lenses, achromats, air-spaced doublets, triplets and matched pairs, plus ideal (paraxial) lenses.
  • Layout: type the gaps between lenses and lock them; group lenses into assemblies (such as Plossl pairs) and save them as your own parts.
  • Beams: any number, each with its own width, angle, vergence, offset and wavelength.
  • 3D view: View > Show 3D View shows the lenses and rays in a window you can rotate.
  • Files: save designs as RayCrafter project files, import and export Zemax .zmx files, and open a report with a 3D view in your browser, which updates as you change the design and can be saved as one file to send to others.
  • Scripting: drive it from Python, or let an AI agent do so (see below).

Documentation

Status: pre-alpha. Expect anything to change, including the API.

Install and run

pip install raycrafter
raycrafter

Or, with uv: uvx raycrafter.

To run the current development version from the main branch on GitHub, use uv directly (no clone or install step needed):

uvx --from git+https://github.com/raycrafter-optical-design/raycrafter@main raycrafter

The MCP server from main can be run the same way (see below):

uvx --from "raycrafter[mcp] @ git+https://github.com/raycrafter-optical-design/raycrafter@main" raycrafter-mcp

main may contain changes not yet in the PyPI release, so behaviour may differ from pip install raycrafter.

Use it from Python

from raycrafter import Bench

bench = Bench(empty=True)  # or Bench.connect() to drive the open window
bench.add_lens("AC254-100-A")
bench.add_lens("AC254-050-A", front_z_mm=150)
bench.autofocus()
print(bench.summary())
bench.plot("spot_diagram").savefig("spot.png")

Every method is documented, with examples, in raycrafter/api.py.

Use it from an AI agent

RayCrafter includes an MCP server, so an AI agent such as Claude can search for lenses, build and edit a design, and read back the optics.

If a RayCrafter window is open, the agent controls that window: you watch its changes happen, and you can also move lenses yourself and ask the agent about the result. (The window listens only on your own computer, and writes a private file in ~/.raycrafter so the server can find it. Start with raycrafter --no-agent-link to turn this off.) If no window is open, the server works on a design of its own, with no picture. Every result says which one it came from.

1. Install the MCP extra.

  • With pip: pip install "raycrafter[mcp]". This installs the raycrafter-mcp command.
  • With uv: uv tool install "raycrafter[mcp]" installs both raycrafter and raycrafter-mcp. Or install nothing and let uv fetch it on demand; see the uvx setting below.

2. Tell your MCP client where it is. In the Claude desktop app, open Settings, then Developer, then Edit Config. This opens the file claude_desktop_config.json, which is at ~/Library/Application Support/Claude/ on macOS and %APPDATA%\Claude\ on Windows. Add RayCrafter under mcpServers, then quit and reopen the app:

{
  "mcpServers": {
    "raycrafter": {
      "command": "/full/path/to/raycrafter-mcp"
    }
  }
}

The path must be written out in full: the app does not expand ~, and it may not see the same PATH as your terminal. Find the path with which raycrafter-mcp (macOS, Linux) or where raycrafter-mcp (Windows).

If you use uv and installed nothing, run RayCrafter through uvx instead (find its path with which uvx):

{
  "mcpServers": {
    "raycrafter": {
      "command": "/full/path/to/uvx",
      "args": ["--from", "raycrafter[mcp]", "raycrafter-mcp"]
    }
  }
}

Other MCP clients (for example Claude Code: claude mcp add raycrafter -- raycrafter-mcp) take the same command.

An agent-generated project

The code in this repository is written by AI coding agents, working with the project's developers. Due to time constraints, the project is only possible because of agentic coding.

We nonetheless aim for well-designed, readable code that people who use little or no AI can understand and contribute to. The rules the agents follow are in CLAUDE.md, and significant decisions, with their reasons, are recorded in the topic files of agent_docs/. How agents use those notes, and how to run several agents at once, is explained in AGENT_WORKFLOW.md.

Metadata

Release files for RayCrafter 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RayCrafter 0.0.5
File Size Uploaded Provenance Actions
raycrafter-0.0.5.tar.gz 790.1 kB With provenance Details for raycrafter-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for RayCrafter 0.0.5
File Interpreter ABI Platform Actions
raycrafter-0.0.5-py3-none-any.whl Python 3 none any Details for raycrafter-0.0.5-py3-none-any.whl

Total release size: 1.4 MB

Release files / raycrafter-0.0.5.tar.gz

Download URL raycrafter-0.0.5.tar.gz
Size 790.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2144236689d1c225a927780cc48a932ae667d5da867c5f780558c02e5e5f5e34
BLAKE2b-256 checksum
How to use checksums
477c708b622016d149ec1b746420fec0d80317e367380a707487f0e33ba8afa8
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 29, 2026.

Transparency log

Release files / raycrafter-0.0.5-py3-none-any.whl

Download URL raycrafter-0.0.5-py3-none-any.whl
Size 637.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccef1dc452aeb397290521ff6cf0783052d49b2b4cf606ae5917fdbb56bc49c4
BLAKE2b-256 checksum
How to use checksums
746b7ac4f73e1a980948eb9c1f8719841e36ddbc3d42eacdbe49ba5079ae24a0
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 29, 2026.

Transparency log

Security for RayCrafter 0.0.5

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.

Select from 2 files

Attestation for raycrafter-0.0.5.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 29, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page