RayCrafter 0.0.2__tar.gz → 0.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. {raycrafter-0.0.2 → raycrafter-0.0.4}/CLAUDE.md +13 -1
  2. raycrafter-0.0.4/Changelog.md +34 -0
  3. {raycrafter-0.0.2 → raycrafter-0.0.4}/PKG-INFO +92 -2
  4. raycrafter-0.0.4/README.md +128 -0
  5. {raycrafter-0.0.2 → raycrafter-0.0.4}/RayCrafter.egg-info/PKG-INFO +92 -2
  6. {raycrafter-0.0.2 → raycrafter-0.0.4}/RayCrafter.egg-info/SOURCES.txt +20 -0
  7. {raycrafter-0.0.2 → raycrafter-0.0.4}/RayCrafter.egg-info/entry_points.txt +1 -0
  8. {raycrafter-0.0.2 → raycrafter-0.0.4}/RayCrafter.egg-info/requires.txt +4 -0
  9. {raycrafter-0.0.2 → raycrafter-0.0.4}/RayCrafter.egg-info/scm_file_list.json +33 -0
  10. raycrafter-0.0.4/RayCrafter.egg-info/scm_version.json +8 -0
  11. {raycrafter-0.0.2 → raycrafter-0.0.4}/log.md +107 -0
  12. raycrafter-0.0.4/optiland_fix.md +47 -0
  13. {raycrafter-0.0.2 → raycrafter-0.0.4}/pyproject.toml +5 -0
  14. raycrafter-0.0.4/raycrafter/__init__.py +28 -0
  15. raycrafter-0.0.4/raycrafter/api.py +901 -0
  16. raycrafter-0.0.4/raycrafter/assembly_methods.py +145 -0
  17. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/core/analysis.py +17 -8
  18. raycrafter-0.0.4/raycrafter/core/assemblies.py +144 -0
  19. raycrafter-0.0.4/raycrafter/core/gaps.py +255 -0
  20. raycrafter-0.0.4/raycrafter/core/history.py +156 -0
  21. raycrafter-0.0.4/raycrafter/core/model.py +870 -0
  22. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/core/optic_builder.py +20 -2
  23. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/core/plot_geometry.py +37 -3
  24. raycrafter-0.0.4/raycrafter/core/project_file.py +562 -0
  25. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/core/ray_launch.py +41 -4
  26. raycrafter-0.0.4/raycrafter/core/state.py +366 -0
  27. raycrafter-0.0.4/raycrafter/core/user_parts.py +183 -0
  28. raycrafter-0.0.4/raycrafter/core/zmx_import.py +789 -0
  29. raycrafter-0.0.4/raycrafter/design_files.py +149 -0
  30. raycrafter-0.0.4/raycrafter/gap_methods.py +146 -0
  31. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/about_dialog.py +1 -0
  32. raycrafter-0.0.4/raycrafter/gui/agent_link.py +106 -0
  33. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/app.py +10 -1
  34. raycrafter-0.0.4/raycrafter/gui/bench_viewer.py +270 -0
  35. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/field_editor.py +12 -8
  36. raycrafter-0.0.4/raycrafter/gui/file_actions.py +304 -0
  37. raycrafter-0.0.4/raycrafter/gui/gap_dimensions.py +252 -0
  38. raycrafter-0.0.4/raycrafter/gui/lens_shapes.py +254 -0
  39. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/main_window.py +341 -137
  40. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/side_view.py +370 -276
  41. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/style.py +21 -2
  42. raycrafter-0.0.4/raycrafter/gui/undo_keys.py +37 -0
  43. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/lenscatalog/catalog.py +6 -0
  44. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/lenscatalog/selection.py +64 -1
  45. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/lenscatalog/thorlabs.py +15 -0
  46. raycrafter-0.0.4/raycrafter/mcp_server/__init__.py +6 -0
  47. raycrafter-0.0.4/raycrafter/mcp_server/link.py +195 -0
  48. raycrafter-0.0.4/raycrafter/mcp_server/server.py +120 -0
  49. raycrafter-0.0.4/raycrafter/mcp_server/tools.py +699 -0
  50. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/palette.py +35 -2
  51. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/report/figures.py +75 -22
  52. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/report/html_report.py +16 -6
  53. {raycrafter-0.0.2 → raycrafter-0.0.4}/uv.lock +677 -1
  54. raycrafter-0.0.2/Changelog.md +0 -19
  55. raycrafter-0.0.2/README.md +0 -41
  56. raycrafter-0.0.2/RayCrafter.egg-info/scm_version.json +0 -8
  57. raycrafter-0.0.2/raycrafter/__init__.py +0 -7
  58. raycrafter-0.0.2/raycrafter/core/model.py +0 -493
  59. raycrafter-0.0.2/raycrafter/core/state.py +0 -174
  60. raycrafter-0.0.2/raycrafter/core/zmx_import.py +0 -384
  61. {raycrafter-0.0.2 → raycrafter-0.0.4}/.github/workflows/test_and_deploy.yml +0 -0
  62. {raycrafter-0.0.2 → raycrafter-0.0.4}/.gitignore +0 -0
  63. {raycrafter-0.0.2 → raycrafter-0.0.4}/LICENSE +0 -0
  64. {raycrafter-0.0.2 → raycrafter-0.0.4}/MANIFEST.in +0 -0
  65. {raycrafter-0.0.2 → raycrafter-0.0.4}/RayCrafter.egg-info/dependency_links.txt +0 -0
  66. {raycrafter-0.0.2 → raycrafter-0.0.4}/RayCrafter.egg-info/top_level.txt +0 -0
  67. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/__main__.py +0 -0
  68. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/core/__init__.py +0 -0
  69. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/core/prescription.py +0 -0
  70. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/__init__.py +0 -0
  71. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/analysis_panels.py +0 -0
  72. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/compile_notice.py +0 -0
  73. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/lens_picker.py +0 -0
  74. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/gui/range_slider.py +0 -0
  75. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/lenscatalog/__init__.py +0 -0
  76. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/lenscatalog/data/thorlabs.json.gz +0 -0
  77. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/report/__init__.py +0 -0
  78. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/report/assets/report.css +0 -0
  79. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/report/assets/report.js +0 -0
  80. {raycrafter-0.0.2 → raycrafter-0.0.4}/raycrafter/report/explanations.py +0 -0
  81. {raycrafter-0.0.2 → raycrafter-0.0.4}/scripts/make_thorlabs_catalog.py +0 -0
  82. {raycrafter-0.0.2 → raycrafter-0.0.4}/setup.cfg +0 -0
@@ -25,7 +25,8 @@ little or no AI. If something would confuse a careful human reader, it is wrong.
25
25
  - **Optiland.** It is pinned to a tested minor version in `pyproject.toml`. Any workaround for an
26
26
  Optiland bug goes in one clearly marked place, with a comment that links to the upstream issue.
27
27
  Delete the workaround once the fix is released. When new versions of Optiland are released:
28
- test them and upgrade as soon as possible.
28
+ test them and upgrade as soon as possible. Every workaround, and every upstream fix we are
29
+ waiting for, is recorded in `optiland_fix.md` (see Releases for the check at each release).
29
30
 
30
31
  Package layout:
31
32
 
@@ -95,6 +96,17 @@ raycrafter/
95
96
 
96
97
  ## Releases
97
98
 
99
+ - **Optiland check, before the code review.** When a release is being prepared, first check
100
+ whether Optiland has a new release (`gh release list --repo optiland/optiland`). If it has:
101
+ 1. Switch to it (update the pin in `pyproject.toml` and `uv.lock`).
102
+ 2. Go through `optiland_fix.md` and remove every workaround the new release makes
103
+ unnecessary. Move its entry to "Retired".
104
+ 3. Re-patch anything that is still broken, and make sure each remaining workaround is in
105
+ `optiland_fix.md` with its upstream issue link (file an issue if there is none; ask Rob
106
+ before filing, and search existing issues first).
107
+ 4. Run the full tests and pre-commit hooks.
108
+ Only then start the adversarial code review below. Update the "last checked" date in
109
+ `optiland_fix.md` even when there is no new release.
98
110
  - When it is time for a new release, you will first conduct an adversarial code review of
99
111
  work down between now and the last release. The main task of the review will be to find
100
112
  bugs that may have been introduced. However, you should also verify that the changes made
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+
3
+ Each release also has a release message on
4
+ [GitHub](https://github.com/raycrafter-optical-design/raycrafter/releases).
5
+
6
+
7
+ ## [0.0.4](https://github.com/raycrafter-optical-design/raycrafter/releases/tag/v0.0.4) (2026-11-26)
8
+
9
+ Version 0.0.3 was skipped.
10
+
11
+ - Project files (`.raycrafter`) keep the whole design, and the Zemax file it was imported from ([#40](https://github.com/raycrafter-optical-design/raycrafter/issues/40)).
12
+ - Undo and redo ([#37](https://github.com/raycrafter-optical-design/raycrafter/issues/37)).
13
+ - Gaps between lenses are shown, can be typed and locked ([#35](https://github.com/raycrafter-optical-design/raycrafter/issues/35), [#36](https://github.com/raycrafter-optical-design/raycrafter/issues/36)).
14
+ - Assemblies: group lenses, flip them as one, save them as user parts. Plossl pairs are assemblies ([#43](https://github.com/raycrafter-optical-design/raycrafter/issues/43)).
15
+ - Fields are defined at a source plane with its own position ([#41](https://github.com/raycrafter-optical-design/raycrafter/issues/41)).
16
+ - Python scripting API, `raycrafter.Bench` ([#31](https://github.com/raycrafter-optical-design/raycrafter/issues/31)).
17
+ - MCP server for AI agents, which can also drive the open window ([#26](https://github.com/raycrafter-optical-design/raycrafter/issues/26), [#28](https://github.com/raycrafter-optical-design/raycrafter/issues/28)).
18
+ - Bench viewer and part metadata ([#34](https://github.com/raycrafter-optical-design/raycrafter/issues/34), [#42](https://github.com/raycrafter-optical-design/raycrafter/issues/42)).
19
+ - Zemax import aims fields through the stop and reads apertures properly; the side view fits the design ([#17](https://github.com/raycrafter-optical-design/raycrafter/issues/17)–[#21](https://github.com/raycrafter-optical-design/raycrafter/issues/21)).
20
+
21
+
22
+ ## [0.0.2](https://github.com/raycrafter-optical-design/raycrafter/releases/tag/v0.0.2) (2026-11-24)
23
+
24
+ - Lens picker dialog and the full Thorlabs catalogue ([#1](https://github.com/raycrafter-optical-design/raycrafter/issues/1)).
25
+ - Rays outside a lens's clear aperture are blocked; slow analyses wait until a drag ends ([#3](https://github.com/raycrafter-optical-design/raycrafter/issues/3)).
26
+ - Paraxial (ideal thin) lenses ([#6](https://github.com/raycrafter-optical-design/raycrafter/issues/6)).
27
+ - Several fields (beams), edited live in a field window ([#7](https://github.com/raycrafter-optical-design/raycrafter/issues/7)).
28
+ - File menu: new, save and load Zemax `.zmx` files ([#8](https://github.com/raycrafter-optical-design/raycrafter/issues/8)).
29
+ - Requires Python 3.12+ and PyQt6 6.8+.
30
+
31
+
32
+ ## 0.0.1 (2026-11-23)
33
+
34
+ First preview release.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: RayCrafter
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Raytracing GUI for simple optical systems using off-the-shelf lenses and Optiland
5
5
  Author-email: Rob Campbell <git@raacampbell.com>
6
6
  License-Expression: MIT
@@ -22,7 +22,10 @@ Requires-Dist: scipy
22
22
  Requires-Dist: matplotlib
23
23
  Requires-Dist: PyQt6>=6.8
24
24
  Requires-Dist: pyqtgraph>=0.14
25
+ Provides-Extra: mcp
26
+ Requires-Dist: mcp<2.4,>=2.3; extra == "mcp"
25
27
  Provides-Extra: dev
28
+ Requires-Dist: mcp<2.4,>=2.3; extra == "dev"
26
29
  Requires-Dist: pytest; extra == "dev"
27
30
  Requires-Dist: pytest-cov; extra == "dev"
28
31
  Requires-Dist: coverage; extra == "dev"
@@ -39,9 +42,9 @@ Dynamic: license-file
39
42
  [![PyPI Version](https://img.shields.io/pypi/v/raycrafter.svg)](https://pypi.org/project/raycrafter)
40
43
  [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/raycrafter-optical-design/raycrafter/blob/main/LICENSE)
41
44
  [![Build Status](https://img.shields.io/github/actions/workflow/status/raycrafter-optical-design/raycrafter/test_and_deploy.yml?branch=main&label=CI)](https://github.com/raycrafter-optical-design/raycrafter/actions/workflows/test_and_deploy.yml)
42
- [![codecov](https://codecov.io/gh/raycrafter-optical-design/raycrafter/branch/main/graph/badge.svg)](https://codecov.io/gh/raycrafter-optical-design/raycrafter)
43
45
  [![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
44
46
  [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
47
+ [![codecov](https://codecov.io/gh/raycrafter-optical-design/raycrafter/branch/main/graph/badge.svg)](https://codecov.io/gh/raycrafter-optical-design/raycrafter)
45
48
 
46
49
  RayCrafter is an early proof of principle for a lens-level optical design tool. You place
47
50
  off-the-shelf lenses on an optical axis, drag them around, and see the spot diagram,
@@ -64,6 +67,93 @@ raycrafter
64
67
 
65
68
  Or, with [uv](https://docs.astral.sh/uv/): `uvx raycrafter`.
66
69
 
70
+ To run the current development version from the `main` branch on GitHub, use uv directly
71
+ (no clone or install step needed):
72
+
73
+ ```
74
+ uvx --from git+https://github.com/raycrafter-optical-design/raycrafter@main raycrafter
75
+ ```
76
+
77
+ The MCP server from `main` can be run the same way (see below):
78
+
79
+ ```
80
+ uvx --from "raycrafter[mcp] @ git+https://github.com/raycrafter-optical-design/raycrafter@main" raycrafter-mcp
81
+ ```
82
+
83
+ `main` may contain changes not yet in the PyPI release, so behaviour may differ from
84
+ `pip install raycrafter`.
85
+
86
+
87
+ ## Use it from Python
88
+
89
+ ```python
90
+ from raycrafter import Bench
91
+
92
+ bench = Bench(empty=True) # or Bench.connect() to drive the open window
93
+ bench.add_lens("AC254-100-A")
94
+ bench.add_lens("AC254-050-A", front_z_mm=150)
95
+ bench.autofocus()
96
+ print(bench.summary())
97
+ bench.plot("spot_diagram").savefig("spot.png")
98
+ ```
99
+
100
+ Every method is documented, with examples, in `raycrafter/api.py`.
101
+
102
+
103
+ ## Use it from an AI agent
104
+
105
+ RayCrafter includes an [MCP](https://modelcontextprotocol.io) server, so an AI agent such as
106
+ Claude can search for lenses, build and edit a design, and read back the optics.
107
+
108
+ If a RayCrafter window is open, the agent controls that window: you watch its changes happen,
109
+ and you can also move lenses yourself and ask the agent about the result. (The window listens
110
+ only on your own computer, and writes a private file in `~/.raycrafter` so the server can find
111
+ it. Start with `raycrafter --no-agent-link` to turn this off.) If no window is open, the server
112
+ works on a design of its own, with no picture. Every result says which one it came from.
113
+
114
+ **1. Install the MCP extra.**
115
+
116
+ - With pip: `pip install "raycrafter[mcp]"`. This installs the `raycrafter-mcp` command.
117
+ - With [uv](https://docs.astral.sh/uv/): `uv tool install "raycrafter[mcp]"` installs both
118
+ `raycrafter` and `raycrafter-mcp`. Or install nothing and let uv fetch it on demand; see the
119
+ `uvx` setting below.
120
+
121
+ **2. Tell your MCP client where it is.** In the Claude desktop app, open Settings, then
122
+ Developer, then Edit Config. This opens the file `claude_desktop_config.json`, which is at
123
+ `~/Library/Application Support/Claude/` on macOS and `%APPDATA%\Claude\` on Windows. Add
124
+ RayCrafter under `mcpServers`, then quit and reopen the app:
125
+
126
+ ```json
127
+ {
128
+ "mcpServers": {
129
+ "raycrafter": {
130
+ "command": "/full/path/to/raycrafter-mcp"
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ The path must be written out in full: the app does not expand `~`, and it may not see the same
137
+ `PATH` as your terminal. Find the path with `which raycrafter-mcp` (macOS, Linux) or
138
+ `where raycrafter-mcp` (Windows).
139
+
140
+ If you use uv and installed nothing, run RayCrafter through `uvx` instead (find its path with
141
+ `which uvx`):
142
+
143
+ ```json
144
+ {
145
+ "mcpServers": {
146
+ "raycrafter": {
147
+ "command": "/full/path/to/uvx",
148
+ "args": ["--from", "raycrafter[mcp]", "raycrafter-mcp"]
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ Other MCP clients (for example Claude Code: `claude mcp add raycrafter -- raycrafter-mcp`) take
155
+ the same command.
156
+
67
157
 
68
158
  ## An agent-generated project
69
159
 
@@ -0,0 +1,128 @@
1
+ # RayCrafter
2
+
3
+ [![Python Version](https://img.shields.io/pypi/pyversions/raycrafter.svg)](https://pypi.org/project/raycrafter)
4
+ [![PyPI Version](https://img.shields.io/pypi/v/raycrafter.svg)](https://pypi.org/project/raycrafter)
5
+ [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/raycrafter-optical-design/raycrafter/blob/main/LICENSE)
6
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/raycrafter-optical-design/raycrafter/test_and_deploy.yml?branch=main&label=CI)](https://github.com/raycrafter-optical-design/raycrafter/actions/workflows/test_and_deploy.yml)
7
+ [![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
8
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
9
+ [![codecov](https://codecov.io/gh/raycrafter-optical-design/raycrafter/branch/main/graph/badge.svg)](https://codecov.io/gh/raycrafter-optical-design/raycrafter)
10
+
11
+ RayCrafter is an early proof of principle for a lens-level optical design tool. You place
12
+ off-the-shelf lenses on an optical axis, drag them around, and see the spot diagram,
13
+ through-focus curve, MTF, ray fan and field curvature update as you go. The ray tracing is
14
+ done by [Optiland](https://github.com/HarrisonKramer/optiland).
15
+
16
+ At present it offers the Thorlabs spherical lenses and ideal (paraxial) lenses, and any number
17
+ of beams, each with its own width, angle, vergence, offset and wavelength. It can export the
18
+ system as a Zemax `.zmx` file and write an HTML report.
19
+
20
+ **Status:** pre-alpha. Expect anything to change, including the API.
21
+
22
+
23
+ ## Install and run
24
+
25
+ ```
26
+ pip install raycrafter
27
+ raycrafter
28
+ ```
29
+
30
+ Or, with [uv](https://docs.astral.sh/uv/): `uvx raycrafter`.
31
+
32
+ To run the current development version from the `main` branch on GitHub, use uv directly
33
+ (no clone or install step needed):
34
+
35
+ ```
36
+ uvx --from git+https://github.com/raycrafter-optical-design/raycrafter@main raycrafter
37
+ ```
38
+
39
+ The MCP server from `main` can be run the same way (see below):
40
+
41
+ ```
42
+ uvx --from "raycrafter[mcp] @ git+https://github.com/raycrafter-optical-design/raycrafter@main" raycrafter-mcp
43
+ ```
44
+
45
+ `main` may contain changes not yet in the PyPI release, so behaviour may differ from
46
+ `pip install raycrafter`.
47
+
48
+
49
+ ## Use it from Python
50
+
51
+ ```python
52
+ from raycrafter import Bench
53
+
54
+ bench = Bench(empty=True) # or Bench.connect() to drive the open window
55
+ bench.add_lens("AC254-100-A")
56
+ bench.add_lens("AC254-050-A", front_z_mm=150)
57
+ bench.autofocus()
58
+ print(bench.summary())
59
+ bench.plot("spot_diagram").savefig("spot.png")
60
+ ```
61
+
62
+ Every method is documented, with examples, in `raycrafter/api.py`.
63
+
64
+
65
+ ## Use it from an AI agent
66
+
67
+ RayCrafter includes an [MCP](https://modelcontextprotocol.io) server, so an AI agent such as
68
+ Claude can search for lenses, build and edit a design, and read back the optics.
69
+
70
+ If a RayCrafter window is open, the agent controls that window: you watch its changes happen,
71
+ and you can also move lenses yourself and ask the agent about the result. (The window listens
72
+ only on your own computer, and writes a private file in `~/.raycrafter` so the server can find
73
+ it. Start with `raycrafter --no-agent-link` to turn this off.) If no window is open, the server
74
+ works on a design of its own, with no picture. Every result says which one it came from.
75
+
76
+ **1. Install the MCP extra.**
77
+
78
+ - With pip: `pip install "raycrafter[mcp]"`. This installs the `raycrafter-mcp` command.
79
+ - With [uv](https://docs.astral.sh/uv/): `uv tool install "raycrafter[mcp]"` installs both
80
+ `raycrafter` and `raycrafter-mcp`. Or install nothing and let uv fetch it on demand; see the
81
+ `uvx` setting below.
82
+
83
+ **2. Tell your MCP client where it is.** In the Claude desktop app, open Settings, then
84
+ Developer, then Edit Config. This opens the file `claude_desktop_config.json`, which is at
85
+ `~/Library/Application Support/Claude/` on macOS and `%APPDATA%\Claude\` on Windows. Add
86
+ RayCrafter under `mcpServers`, then quit and reopen the app:
87
+
88
+ ```json
89
+ {
90
+ "mcpServers": {
91
+ "raycrafter": {
92
+ "command": "/full/path/to/raycrafter-mcp"
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ The path must be written out in full: the app does not expand `~`, and it may not see the same
99
+ `PATH` as your terminal. Find the path with `which raycrafter-mcp` (macOS, Linux) or
100
+ `where raycrafter-mcp` (Windows).
101
+
102
+ If you use uv and installed nothing, run RayCrafter through `uvx` instead (find its path with
103
+ `which uvx`):
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "raycrafter": {
109
+ "command": "/full/path/to/uvx",
110
+ "args": ["--from", "raycrafter[mcp]", "raycrafter-mcp"]
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ Other MCP clients (for example Claude Code: `claude mcp add raycrafter -- raycrafter-mcp`) take
117
+ the same command.
118
+
119
+
120
+ ## An agent-generated project
121
+
122
+ The code in this repository is written by AI coding agents, working with the project's
123
+ developers. Due to time constraints, the project is only possible because of agentic
124
+ coding.
125
+
126
+ We nonetheless aim for well-designed, readable code that people who use little or no AI can
127
+ understand and contribute to. The rules the agents follow are in [CLAUDE.md](CLAUDE.md), and
128
+ significant decisions, with their reasons, are recorded in [log.md](log.md).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: RayCrafter
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Raytracing GUI for simple optical systems using off-the-shelf lenses and Optiland
5
5
  Author-email: Rob Campbell <git@raacampbell.com>
6
6
  License-Expression: MIT
@@ -22,7 +22,10 @@ Requires-Dist: scipy
22
22
  Requires-Dist: matplotlib
23
23
  Requires-Dist: PyQt6>=6.8
24
24
  Requires-Dist: pyqtgraph>=0.14
25
+ Provides-Extra: mcp
26
+ Requires-Dist: mcp<2.4,>=2.3; extra == "mcp"
25
27
  Provides-Extra: dev
28
+ Requires-Dist: mcp<2.4,>=2.3; extra == "dev"
26
29
  Requires-Dist: pytest; extra == "dev"
27
30
  Requires-Dist: pytest-cov; extra == "dev"
28
31
  Requires-Dist: coverage; extra == "dev"
@@ -39,9 +42,9 @@ Dynamic: license-file
39
42
  [![PyPI Version](https://img.shields.io/pypi/v/raycrafter.svg)](https://pypi.org/project/raycrafter)
40
43
  [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/raycrafter-optical-design/raycrafter/blob/main/LICENSE)
41
44
  [![Build Status](https://img.shields.io/github/actions/workflow/status/raycrafter-optical-design/raycrafter/test_and_deploy.yml?branch=main&label=CI)](https://github.com/raycrafter-optical-design/raycrafter/actions/workflows/test_and_deploy.yml)
42
- [![codecov](https://codecov.io/gh/raycrafter-optical-design/raycrafter/branch/main/graph/badge.svg)](https://codecov.io/gh/raycrafter-optical-design/raycrafter)
43
45
  [![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
44
46
  [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
47
+ [![codecov](https://codecov.io/gh/raycrafter-optical-design/raycrafter/branch/main/graph/badge.svg)](https://codecov.io/gh/raycrafter-optical-design/raycrafter)
45
48
 
46
49
  RayCrafter is an early proof of principle for a lens-level optical design tool. You place
47
50
  off-the-shelf lenses on an optical axis, drag them around, and see the spot diagram,
@@ -64,6 +67,93 @@ raycrafter
64
67
 
65
68
  Or, with [uv](https://docs.astral.sh/uv/): `uvx raycrafter`.
66
69
 
70
+ To run the current development version from the `main` branch on GitHub, use uv directly
71
+ (no clone or install step needed):
72
+
73
+ ```
74
+ uvx --from git+https://github.com/raycrafter-optical-design/raycrafter@main raycrafter
75
+ ```
76
+
77
+ The MCP server from `main` can be run the same way (see below):
78
+
79
+ ```
80
+ uvx --from "raycrafter[mcp] @ git+https://github.com/raycrafter-optical-design/raycrafter@main" raycrafter-mcp
81
+ ```
82
+
83
+ `main` may contain changes not yet in the PyPI release, so behaviour may differ from
84
+ `pip install raycrafter`.
85
+
86
+
87
+ ## Use it from Python
88
+
89
+ ```python
90
+ from raycrafter import Bench
91
+
92
+ bench = Bench(empty=True) # or Bench.connect() to drive the open window
93
+ bench.add_lens("AC254-100-A")
94
+ bench.add_lens("AC254-050-A", front_z_mm=150)
95
+ bench.autofocus()
96
+ print(bench.summary())
97
+ bench.plot("spot_diagram").savefig("spot.png")
98
+ ```
99
+
100
+ Every method is documented, with examples, in `raycrafter/api.py`.
101
+
102
+
103
+ ## Use it from an AI agent
104
+
105
+ RayCrafter includes an [MCP](https://modelcontextprotocol.io) server, so an AI agent such as
106
+ Claude can search for lenses, build and edit a design, and read back the optics.
107
+
108
+ If a RayCrafter window is open, the agent controls that window: you watch its changes happen,
109
+ and you can also move lenses yourself and ask the agent about the result. (The window listens
110
+ only on your own computer, and writes a private file in `~/.raycrafter` so the server can find
111
+ it. Start with `raycrafter --no-agent-link` to turn this off.) If no window is open, the server
112
+ works on a design of its own, with no picture. Every result says which one it came from.
113
+
114
+ **1. Install the MCP extra.**
115
+
116
+ - With pip: `pip install "raycrafter[mcp]"`. This installs the `raycrafter-mcp` command.
117
+ - With [uv](https://docs.astral.sh/uv/): `uv tool install "raycrafter[mcp]"` installs both
118
+ `raycrafter` and `raycrafter-mcp`. Or install nothing and let uv fetch it on demand; see the
119
+ `uvx` setting below.
120
+
121
+ **2. Tell your MCP client where it is.** In the Claude desktop app, open Settings, then
122
+ Developer, then Edit Config. This opens the file `claude_desktop_config.json`, which is at
123
+ `~/Library/Application Support/Claude/` on macOS and `%APPDATA%\Claude\` on Windows. Add
124
+ RayCrafter under `mcpServers`, then quit and reopen the app:
125
+
126
+ ```json
127
+ {
128
+ "mcpServers": {
129
+ "raycrafter": {
130
+ "command": "/full/path/to/raycrafter-mcp"
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ The path must be written out in full: the app does not expand `~`, and it may not see the same
137
+ `PATH` as your terminal. Find the path with `which raycrafter-mcp` (macOS, Linux) or
138
+ `where raycrafter-mcp` (Windows).
139
+
140
+ If you use uv and installed nothing, run RayCrafter through `uvx` instead (find its path with
141
+ `which uvx`):
142
+
143
+ ```json
144
+ {
145
+ "mcpServers": {
146
+ "raycrafter": {
147
+ "command": "/full/path/to/uvx",
148
+ "args": ["--from", "raycrafter[mcp]", "raycrafter-mcp"]
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ Other MCP clients (for example Claude Code: `claude mcp add raycrafter -- raycrafter-mcp`) take
155
+ the same command.
156
+
67
157
 
68
158
  ## An agent-generated project
69
159
 
@@ -5,6 +5,7 @@ LICENSE
5
5
  MANIFEST.in
6
6
  README.md
7
7
  log.md
8
+ optiland_fix.md
8
9
  pyproject.toml
9
10
  uv.lock
10
11
  .github/workflows/test_and_deploy.yml
@@ -18,32 +19,51 @@ RayCrafter.egg-info/scm_version.json
18
19
  RayCrafter.egg-info/top_level.txt
19
20
  raycrafter/__init__.py
20
21
  raycrafter/__main__.py
22
+ raycrafter/api.py
23
+ raycrafter/assembly_methods.py
24
+ raycrafter/design_files.py
25
+ raycrafter/gap_methods.py
21
26
  raycrafter/palette.py
22
27
  raycrafter/core/__init__.py
23
28
  raycrafter/core/analysis.py
29
+ raycrafter/core/assemblies.py
30
+ raycrafter/core/gaps.py
31
+ raycrafter/core/history.py
24
32
  raycrafter/core/model.py
25
33
  raycrafter/core/optic_builder.py
26
34
  raycrafter/core/plot_geometry.py
27
35
  raycrafter/core/prescription.py
36
+ raycrafter/core/project_file.py
28
37
  raycrafter/core/ray_launch.py
29
38
  raycrafter/core/state.py
39
+ raycrafter/core/user_parts.py
30
40
  raycrafter/core/zmx_import.py
31
41
  raycrafter/gui/__init__.py
32
42
  raycrafter/gui/about_dialog.py
43
+ raycrafter/gui/agent_link.py
33
44
  raycrafter/gui/analysis_panels.py
34
45
  raycrafter/gui/app.py
46
+ raycrafter/gui/bench_viewer.py
35
47
  raycrafter/gui/compile_notice.py
36
48
  raycrafter/gui/field_editor.py
49
+ raycrafter/gui/file_actions.py
50
+ raycrafter/gui/gap_dimensions.py
37
51
  raycrafter/gui/lens_picker.py
52
+ raycrafter/gui/lens_shapes.py
38
53
  raycrafter/gui/main_window.py
39
54
  raycrafter/gui/range_slider.py
40
55
  raycrafter/gui/side_view.py
41
56
  raycrafter/gui/style.py
57
+ raycrafter/gui/undo_keys.py
42
58
  raycrafter/lenscatalog/__init__.py
43
59
  raycrafter/lenscatalog/catalog.py
44
60
  raycrafter/lenscatalog/selection.py
45
61
  raycrafter/lenscatalog/thorlabs.py
46
62
  raycrafter/lenscatalog/data/thorlabs.json.gz
63
+ raycrafter/mcp_server/__init__.py
64
+ raycrafter/mcp_server/link.py
65
+ raycrafter/mcp_server/server.py
66
+ raycrafter/mcp_server/tools.py
47
67
  raycrafter/report/__init__.py
48
68
  raycrafter/report/explanations.py
49
69
  raycrafter/report/figures.py
@@ -1,2 +1,3 @@
1
1
  [console_scripts]
2
2
  raycrafter = raycrafter.gui.app:main
3
+ raycrafter-mcp = raycrafter.mcp_server.server:main
@@ -6,6 +6,7 @@ PyQt6>=6.8
6
6
  pyqtgraph>=0.14
7
7
 
8
8
  [dev]
9
+ mcp<2.4,>=2.3
9
10
  pytest
10
11
  pytest-cov
11
12
  coverage
@@ -14,3 +15,6 @@ mypy
14
15
  pre-commit
15
16
  ruff
16
17
  setuptools-scm
18
+
19
+ [mcp]
20
+ mcp<2.4,>=2.3
@@ -9,34 +9,54 @@
9
9
  "MANIFEST.in",
10
10
  "README.md",
11
11
  "log.md",
12
+ "optiland_fix.md",
12
13
  "pyproject.toml",
13
14
  "raycrafter/__init__.py",
14
15
  "raycrafter/__main__.py",
16
+ "raycrafter/api.py",
17
+ "raycrafter/assembly_methods.py",
15
18
  "raycrafter/core/__init__.py",
16
19
  "raycrafter/core/analysis.py",
20
+ "raycrafter/core/assemblies.py",
21
+ "raycrafter/core/gaps.py",
22
+ "raycrafter/core/history.py",
17
23
  "raycrafter/core/model.py",
18
24
  "raycrafter/core/optic_builder.py",
19
25
  "raycrafter/core/plot_geometry.py",
20
26
  "raycrafter/core/prescription.py",
27
+ "raycrafter/core/project_file.py",
21
28
  "raycrafter/core/ray_launch.py",
22
29
  "raycrafter/core/state.py",
30
+ "raycrafter/core/user_parts.py",
23
31
  "raycrafter/core/zmx_import.py",
32
+ "raycrafter/design_files.py",
33
+ "raycrafter/gap_methods.py",
24
34
  "raycrafter/gui/__init__.py",
25
35
  "raycrafter/gui/about_dialog.py",
36
+ "raycrafter/gui/agent_link.py",
26
37
  "raycrafter/gui/analysis_panels.py",
27
38
  "raycrafter/gui/app.py",
39
+ "raycrafter/gui/bench_viewer.py",
28
40
  "raycrafter/gui/compile_notice.py",
29
41
  "raycrafter/gui/field_editor.py",
42
+ "raycrafter/gui/file_actions.py",
43
+ "raycrafter/gui/gap_dimensions.py",
30
44
  "raycrafter/gui/lens_picker.py",
45
+ "raycrafter/gui/lens_shapes.py",
31
46
  "raycrafter/gui/main_window.py",
32
47
  "raycrafter/gui/range_slider.py",
33
48
  "raycrafter/gui/side_view.py",
34
49
  "raycrafter/gui/style.py",
50
+ "raycrafter/gui/undo_keys.py",
35
51
  "raycrafter/lenscatalog/__init__.py",
36
52
  "raycrafter/lenscatalog/catalog.py",
37
53
  "raycrafter/lenscatalog/data/thorlabs.json.gz",
38
54
  "raycrafter/lenscatalog/selection.py",
39
55
  "raycrafter/lenscatalog/thorlabs.py",
56
+ "raycrafter/mcp_server/__init__.py",
57
+ "raycrafter/mcp_server/link.py",
58
+ "raycrafter/mcp_server/server.py",
59
+ "raycrafter/mcp_server/tools.py",
40
60
  "raycrafter/palette.py",
41
61
  "raycrafter/report/__init__.py",
42
62
  "raycrafter/report/assets/report.css",
@@ -51,14 +71,27 @@
51
71
  "tests/test_integration/test_gui.py",
52
72
  "tests/test_integration/test_report.py",
53
73
  "tests/test_unit/__init__.py",
74
+ "tests/test_unit/test_agent_link.py",
75
+ "tests/test_unit/test_api.py",
76
+ "tests/test_unit/test_assemblies.py",
54
77
  "tests/test_unit/test_bench_editing.py",
55
78
  "tests/test_unit/test_compile_notice.py",
56
79
  "tests/test_unit/test_fields.py",
80
+ "tests/test_unit/test_gap_locks.py",
81
+ "tests/test_unit/test_gaps.py",
57
82
  "tests/test_unit/test_lens_selection.py",
58
83
  "tests/test_unit/test_lenscatalog.py",
84
+ "tests/test_unit/test_mcp_server.py",
85
+ "tests/test_unit/test_mcp_tools.py",
59
86
  "tests/test_unit/test_paraxial_lens.py",
87
+ "tests/test_unit/test_part_metadata.py",
60
88
  "tests/test_unit/test_physics.py",
89
+ "tests/test_unit/test_plot_geometry.py",
61
90
  "tests/test_unit/test_prescription.py",
91
+ "tests/test_unit/test_project_file.py",
92
+ "tests/test_unit/test_source_plane.py",
93
+ "tests/test_unit/test_undo.py",
94
+ "tests/test_unit/test_unsaved_changes.py",
62
95
  "tests/test_unit/test_zmx_import.py",
63
96
  "uv.lock"
64
97
  ]
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "0.0.4",
3
+ "distance": 0,
4
+ "node": "gcfe60260b41f2a6f1b667a8b960a8ca1466e82d1",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-11-26"
8
+ }