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 and field curvature update as you go. The ray tracing is done by Optiland.

At present it offers the Thorlabs spherical lenses and ideal (paraxial) lenses, and any number of beams, each with its own width, angle, vergence, offset and wavelength. It can export the system as a Zemax .zmx file and write an HTML report.

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 log.md.

Metadata

Release files for RayCrafter 0.0.4

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.4
File Size Uploaded Provenance Actions
raycrafter-0.0.4.tar.gz 452.7 kB With provenance Details for raycrafter-0.0.4.tar.gz

Built distribution (wheel)

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

Total release size: 747.6 kB

Release files / raycrafter-0.0.4.tar.gz

Download URL raycrafter-0.0.4.tar.gz
Size 452.7 kB
Tags Source
SHA-256 checksum
How to use checksums
247e8af46cf987c142d9a51904f1fdccdcb254c32946aaaf764c4f13090cfd6a
BLAKE2b-256 checksum
How to use checksums
20d53c2148587ea8df77c906e597b3e4d4e3a552bd64d8df2e0a47628d09800a
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 26, 2026.

Transparency log

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

Download URL raycrafter-0.0.4-py3-none-any.whl
Size 294.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a02f4ac8bc43e93bbdab4b629e49a81a44c31b8bf3bd0be857a396157d33bfa3
BLAKE2b-256 checksum
How to use checksums
ca831da6a701c77b3c0f316e4f344e7686e264721aaaeb3914126516097b7ea7
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 26, 2026.

Transparency log

Security for RayCrafter 0.0.4

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.4.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 26, 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