codev-mcp 0.1.0__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.
- codev_mcp-0.1.0/.gitignore +16 -0
- codev_mcp-0.1.0/LICENSE +202 -0
- codev_mcp-0.1.0/NOTICE +12 -0
- codev_mcp-0.1.0/PKG-INFO +371 -0
- codev_mcp-0.1.0/README.md +343 -0
- codev_mcp-0.1.0/ROADMAP.md +143 -0
- codev_mcp-0.1.0/pyproject.toml +52 -0
- codev_mcp-0.1.0/scripts/attach_test.py +93 -0
- codev_mcp-0.1.0/scripts/coverage_test.py +175 -0
- codev_mcp-0.1.0/scripts/edit_test.py +147 -0
- codev_mcp-0.1.0/scripts/field_test.py +89 -0
- codev_mcp-0.1.0/scripts/idle_test.py +131 -0
- codev_mcp-0.1.0/scripts/mcp_client_test.py +129 -0
- codev_mcp-0.1.0/scripts/monte_carlo_test.py +169 -0
- codev_mcp-0.1.0/scripts/optimize_test.py +134 -0
- codev_mcp-0.1.0/scripts/plot_test.py +77 -0
- codev_mcp-0.1.0/scripts/reference_test.py +78 -0
- codev_mcp-0.1.0/scripts/smoke_test.py +66 -0
- codev_mcp-0.1.0/scripts/snapshot_test.py +98 -0
- codev_mcp-0.1.0/scripts/sysdata_test.py +103 -0
- codev_mcp-0.1.0/scripts/tolerance_test.py +100 -0
- codev_mcp-0.1.0/scripts/version_check.py +171 -0
- codev_mcp-0.1.0/src/codev_mcp/__init__.py +3 -0
- codev_mcp-0.1.0/src/codev_mcp/__main__.py +4 -0
- codev_mcp-0.1.0/src/codev_mcp/analyses.py +277 -0
- codev_mcp-0.1.0/src/codev_mcp/build_data.py +369 -0
- codev_mcp-0.1.0/src/codev_mcp/doctor.py +308 -0
- codev_mcp-0.1.0/src/codev_mcp/edits.py +410 -0
- codev_mcp-0.1.0/src/codev_mcp/engine.py +693 -0
- codev_mcp-0.1.0/src/codev_mcp/montecarlo.py +278 -0
- codev_mcp-0.1.0/src/codev_mcp/optimize.py +279 -0
- codev_mcp-0.1.0/src/codev_mcp/paths.py +35 -0
- codev_mcp-0.1.0/src/codev_mcp/plots.py +142 -0
- codev_mcp-0.1.0/src/codev_mcp/procs.py +73 -0
- codev_mcp-0.1.0/src/codev_mcp/reference.py +315 -0
- codev_mcp-0.1.0/src/codev_mcp/server.py +966 -0
- codev_mcp-0.1.0/src/codev_mcp/settings.py +100 -0
- codev_mcp-0.1.0/src/codev_mcp/snapshots.py +199 -0
- codev_mcp-0.1.0/src/codev_mcp/sysdata.py +262 -0
- codev_mcp-0.1.0/src/codev_mcp/toldata.py +339 -0
- codev_mcp-0.1.0/src/codev_mcp/tolerance.py +363 -0
- codev_mcp-0.1.0/tests/conftest.py +28 -0
- codev_mcp-0.1.0/tests/fake_codev.py +317 -0
- codev_mcp-0.1.0/tests/test_attach.py +120 -0
- codev_mcp-0.1.0/tests/test_doctor.py +79 -0
- codev_mcp-0.1.0/tests/test_engine.py +169 -0
- codev_mcp-0.1.0/tests/test_montecarlo.py +156 -0
- codev_mcp-0.1.0/tests/test_optimize.py +165 -0
- codev_mcp-0.1.0/tests/test_parsers.py +137 -0
- codev_mcp-0.1.0/tests/test_refbuild.py +79 -0
- codev_mcp-0.1.0/tests/test_reference.py +77 -0
- codev_mcp-0.1.0/tests/test_server.py +49 -0
- codev_mcp-0.1.0/tests/test_settings.py +80 -0
- codev_mcp-0.1.0/tests/test_sysdata.py +114 -0
- codev_mcp-0.1.0/tests/test_toldata.py +158 -0
- codev_mcp-0.1.0/tests/test_tolerance.py +208 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.venv/
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.pyc
|
|
4
|
+
*.egg-info/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
|
|
8
|
+
# CODE V session files
|
|
9
|
+
*.rec
|
|
10
|
+
*.lis
|
|
11
|
+
|
|
12
|
+
# Machine-specific MCP registration (absolute paths)
|
|
13
|
+
.mcp.json
|
|
14
|
+
|
|
15
|
+
# Lens files: CODE V binary, often derived from vendor sample lenses
|
|
16
|
+
lenses/
|
codev_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
codev_mcp-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
CodeV-mcp
|
|
2
|
+
Copyright 2026 The CodeV-mcp Authors
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
CodeV-mcp is an independent project. It is not affiliated with, endorsed by,
|
|
7
|
+
or sponsored by Synopsys, Inc. CODE V is a trademark of Synopsys, Inc.
|
|
8
|
+
|
|
9
|
+
This project contains no CODE V software, documentation or data. It drives a
|
|
10
|
+
separately licensed CODE V installation at run time, and the reference data it
|
|
11
|
+
builds (manual index and glass tables) is generated locally from the user's own
|
|
12
|
+
installation and is not distributed.
|
codev_mcp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: codev-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: codev-mcp for CODE V: an unofficial MCP server that drives your licensed CODE V install over COM
|
|
5
|
+
Project-URL: Homepage, https://github.com/br24563/CodeV-mcp
|
|
6
|
+
Project-URL: Issues, https://github.com/br24563/CodeV-mcp/issues
|
|
7
|
+
Project-URL: Roadmap, https://github.com/br24563/CodeV-mcp/blob/main/ROADMAP.md
|
|
8
|
+
Author: The CodeV-mcp Authors
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: claude,code-v,lens-design,mcp,model-context-protocol,optical-design
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: mcp<3,>=2.3
|
|
23
|
+
Requires-Dist: pillow>=10
|
|
24
|
+
Requires-Dist: pywin32>=306; sys_platform == 'win32'
|
|
25
|
+
Provides-Extra: test
|
|
26
|
+
Requires-Dist: pytest>=8; extra == 'test'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# codev-mcp
|
|
30
|
+
|
|
31
|
+
<!-- mcp-name: io.github.br24563/codev-mcp -->
|
|
32
|
+
|
|
33
|
+
Experimental MCP server that lets a coding agent drive CODE V through its COM
|
|
34
|
+
API. Code only: it uses your own licensed CODE V install at runtime and ships
|
|
35
|
+
no vendor data.
|
|
36
|
+
|
|
37
|
+
For what an agent does with it, see [the first trial](demos/cooke1-trial.md):
|
|
38
|
+
ten prompts on the Cooke triplet sample, from glass lookups to an optimization
|
|
39
|
+
and a four-glass substitution study, and what the trial changed in the tools.
|
|
40
|
+
|
|
41
|
+
What the agent can change, what Claude asks first, how the licence is used
|
|
42
|
+
and what leaves your machine: [SECURITY.md](SECURITY.md).
|
|
43
|
+
|
|
44
|
+
## Requirements
|
|
45
|
+
|
|
46
|
+
- Windows with CODE V installed and its COM server registered (the installer does this)
|
|
47
|
+
- Python 3.11+
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
py -3.12 -m venv .venv
|
|
53
|
+
.venv\Scripts\python.exe -m pip install -e .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Build the reference data
|
|
57
|
+
|
|
58
|
+
```powershell
|
|
59
|
+
.venv\Scripts\codev-mcp-build-data.exe
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Indexes your CODE V help for full-text search and loads your glass catalogs
|
|
63
|
+
into `%USERPROFILE%\codev-mcp\reference.db`. It finds the install from the
|
|
64
|
+
COM registration (or pass `--codev-dir`), starts no CODE V session and uses no
|
|
65
|
+
licence. It takes a few minutes. Nothing it produces is committed: the data
|
|
66
|
+
comes from your own licensed install and stays on your machine. Until it is
|
|
67
|
+
built, the reference tools return an "unavailable" result and everything else
|
|
68
|
+
works.
|
|
69
|
+
|
|
70
|
+
## Check the setup
|
|
71
|
+
|
|
72
|
+
```powershell
|
|
73
|
+
.venv\Scripts\codev-mcp-doctor.exe
|
|
74
|
+
.venv\Scripts\codev-mcp-doctor.exe --engine
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
It checks Python and the packages, which CODE V install the COM registration
|
|
78
|
+
points at (and whether any registration is stale), whether this process's
|
|
79
|
+
AppData folders are redirected into a packaged app's private store, the data
|
|
80
|
+
folder, the reference database and leftover background CODE V processes, and
|
|
81
|
+
prints a fix for anything wrong. `--engine` also starts CODE V once, which
|
|
82
|
+
takes a licence seat. `--json` gives machine-readable output.
|
|
83
|
+
|
|
84
|
+
## Unit tests
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
.venv\Scripts\python.exe -m pip install -e ".[test]"
|
|
88
|
+
.venv\Scripts\python.exe -m pytest tests
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
These use a fake CODE V (`tests/fake_codev.py`) and need no licence; CI runs
|
|
92
|
+
them on every push. The live checks below drive a real CODE V.
|
|
93
|
+
|
|
94
|
+
## Check the install
|
|
95
|
+
|
|
96
|
+
```powershell
|
|
97
|
+
.venv\Scripts\python.exe scripts\reference_test.py
|
|
98
|
+
.venv\Scripts\python.exe scripts\smoke_test.py
|
|
99
|
+
.venv\Scripts\python.exe scripts\edit_test.py
|
|
100
|
+
.venv\Scripts\python.exe scripts\field_test.py
|
|
101
|
+
.venv\Scripts\python.exe scripts\idle_test.py
|
|
102
|
+
.venv\Scripts\python.exe scripts\coverage_test.py
|
|
103
|
+
.venv\Scripts\python.exe scripts\snapshot_test.py
|
|
104
|
+
.venv\Scripts\python.exe scripts\plot_test.py
|
|
105
|
+
.venv\Scripts\python.exe scripts\mcp_client_test.py
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- `reference_test` checks the reference data against published glass values
|
|
109
|
+
and needs no licence.
|
|
110
|
+
- `smoke_test` drives CODE V directly.
|
|
111
|
+
- `edit_test` exercises every edit tool on a sample lens, including a short
|
|
112
|
+
optimization that must move the variables and nothing else.
|
|
113
|
+
- `idle_test` runs the idle timeout with a 4-second limit: release, restore
|
|
114
|
+
with edits and variables intact, and no release during a long command.
|
|
115
|
+
- `field_test` checks distortion and field curves against CODE V's own FIE
|
|
116
|
+
listing, including the sign convention.
|
|
117
|
+
- `snapshot_test` saves, wrecks and restores a lens, and checks that a
|
|
118
|
+
restore that does not match its fingerprint is reported.
|
|
119
|
+
- `plot_test` renders every plot kind from a deliberately long folder path.
|
|
120
|
+
- `coverage_test` runs the core tools on nine sample lenses chosen to cover
|
|
121
|
+
zoom, afocal, finite-object, mirror, aspheric and decentered systems, and
|
|
122
|
+
checks the results make sense. `--sweep` runs the read-only tools on every
|
|
123
|
+
sample lens in the install.
|
|
124
|
+
- `attach_test PID_UI` drives an open CODE V window through the tools (open,
|
|
125
|
+
edit, analyse, plot, optimize, snapshot), then checks that detaching leaves
|
|
126
|
+
it open. Use a window you do not mind being changed.
|
|
127
|
+
- `sysdata_test` reads and changes fields, wavelengths and the aperture on
|
|
128
|
+
an infinite-object and a finite-object lens, including the refusals.
|
|
129
|
+
- `tolerance_test` runs `tolerance_analysis` on the Cooke triplet (RMS and
|
|
130
|
+
MTF), a zoom lens and a decentered mirror system, and checks that each
|
|
131
|
+
field's value with tolerances equals nominal plus probable change, and that
|
|
132
|
+
repeated runs agree and leave no tolerances behind.
|
|
133
|
+
- `monte_carlo_test` sets, reads back and deletes tolerances and
|
|
134
|
+
compensators, compares TOR's sensitivity and inverse modes, and runs
|
|
135
|
+
`monte_carlo` on four metrics and a zoom lens, checking that the lens, its
|
|
136
|
+
variables and its tolerances come back unchanged; on the double Gauss it
|
|
137
|
+
checks qualifiers, rollback of a failed change, and the inverse budget.
|
|
138
|
+
- `optimize_test` runs `optimize` on the Cooke triplet and a zoom lens:
|
|
139
|
+
constraints met, undo by snapshot, wavefront error function, and a
|
|
140
|
+
constraint CODE V rejects (it is named, and the run is marked failed). On
|
|
141
|
+
the double Gauss it checks AUT's stop reason, `min_improvement`, and that a
|
|
142
|
+
wavefront call's warnings do not leak into the next tool.
|
|
143
|
+
- `version_check OLD_DIR NEW_DIR` compares two CODE V installs without a
|
|
144
|
+
licence: the COM methods the tools call, the manual pages they rely on,
|
|
145
|
+
sample lenses and glass catalogs. Run it when a new CODE V version arrives.
|
|
146
|
+
- `mcp_client_test` launches the server over stdio and calls its tools the
|
|
147
|
+
way an agent would.
|
|
148
|
+
|
|
149
|
+
All but the first take a licence seat while they run.
|
|
150
|
+
|
|
151
|
+
## How edits are checked
|
|
152
|
+
|
|
153
|
+
CODE V accepts some edits that it then ignores or turns into something else,
|
|
154
|
+
with at most a warning. The edit tools guard against this:
|
|
155
|
+
|
|
156
|
+
- Every change is read back; one that did not stick is a failure, and later
|
|
157
|
+
fields in the same call are not applied.
|
|
158
|
+
- A value held by a solve (for example the PIM paraxial image thickness) is
|
|
159
|
+
refused unless `release_solves` is true. Without this, varying the PIM
|
|
160
|
+
thickness quietly deletes the image solve.
|
|
161
|
+
- Variable codes are read from the lens listing (`LIS`), because the
|
|
162
|
+
`(VAR Ik)` database items go stale after a variable is frozen or coupled.
|
|
163
|
+
- Making a glass variable replaces it with a fictitious glass model; the tool
|
|
164
|
+
says so.
|
|
165
|
+
- Vignetting factors are stored per field number and do not follow a change of
|
|
166
|
+
fields, so `set_fields` recomputes them (`SET VIG`) unless told otherwise.
|
|
167
|
+
- Object-space settings on an object at infinity (object heights, object NA)
|
|
168
|
+
are accepted by CODE V but meaningless, so they are refused.
|
|
169
|
+
|
|
170
|
+
## Working in your own CODE V window
|
|
171
|
+
|
|
172
|
+
By default the server runs its own hidden CODE V session. `attach_to_window`
|
|
173
|
+
connects it to a CODE V window you have open instead, through CODE V's
|
|
174
|
+
interactive COM (CVLocator), so you watch every command and edit happen in
|
|
175
|
+
that window, on its current lens. Give the window's PID UI (`eva (pid ui)` in
|
|
176
|
+
its command window), or 0 for the first open window.
|
|
177
|
+
|
|
178
|
+
- The window's own CODE V version and licence are used, and the server takes
|
|
179
|
+
no extra licence seat; the idle timeout does not apply.
|
|
180
|
+
- `detach_from_window`, or `stop_session` while attached, ends the connection
|
|
181
|
+
and leaves the window open (in this mode `StopCodeV` only disconnects, as
|
|
182
|
+
CODE V's interactive-COM examples rely on).
|
|
183
|
+
- Attaching is refused while a background session is running, so its lens is
|
|
184
|
+
not lost silently. If you close the window, tools say so instead of
|
|
185
|
+
starting a hidden session.
|
|
186
|
+
|
|
187
|
+
## Snapshots and plots
|
|
188
|
+
|
|
189
|
+
Snapshots are `.len` files in `<starting directory>\snapshots` with an
|
|
190
|
+
`index.json` holding a fingerprint of each lens (title, EFL, stop, counts and
|
|
191
|
+
every surface's radius, thickness and glass). A restore is reported as
|
|
192
|
+
successful only if the restored lens matches that fingerprint.
|
|
193
|
+
`start_long_command` takes an `auto-` snapshot first, and the newest 20 of
|
|
194
|
+
those are kept.
|
|
195
|
+
|
|
196
|
+
Plots are written to `<starting directory>\plots` at full size, and the agent
|
|
197
|
+
gets a copy scaled to `max_pixels` (1600 by default). Legacy plots (layout, ray
|
|
198
|
+
fan, field curves, spot) go through `GRA` and `GCV`; charts (MTF, PSF) through
|
|
199
|
+
`WGF`. CODE V truncates `GRA` file names beyond about 80 characters, so plot
|
|
200
|
+
paths are kept short and relative to the starting directory.
|
|
201
|
+
|
|
202
|
+
## Register with Claude Code
|
|
203
|
+
|
|
204
|
+
```powershell
|
|
205
|
+
claude mcp add codev -- C:\full\path\to\.venv\Scripts\python.exe -m codev_mcp
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
By default this registers the server for the current project only.
|
|
209
|
+
|
|
210
|
+
Without the `claude` command (the desktop app does not put one on PATH),
|
|
211
|
+
create `.mcp.json` in the project root instead; Claude Code asks you to
|
|
212
|
+
approve it the first time it starts there:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"mcpServers": {
|
|
217
|
+
"codev": {
|
|
218
|
+
"type": "stdio",
|
|
219
|
+
"command": "C:\\full\\path\\to\\.venv\\Scripts\\python.exe",
|
|
220
|
+
"args": ["-m", "codev_mcp"]
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
This repository ignores `.mcp.json`, because it holds a machine-specific path.
|
|
227
|
+
|
|
228
|
+
Any tool that needs CODE V starts its own background session and takes a
|
|
229
|
+
licence seat. If you have one seat and the CODE V GUI open, those calls will
|
|
230
|
+
fail with a licence error.
|
|
231
|
+
|
|
232
|
+
The seat is released by `stop_session`, when the client disconnects, or after
|
|
233
|
+
20 minutes without a tool call (`CODEV_IDLE_MINUTES`; 0 turns this off). On an
|
|
234
|
+
idle release the lens is snapshotted first (`auto-idle-…`), and the next tool
|
|
235
|
+
call restarts CODE V, restores it and adds a `session_notice` to its result.
|
|
236
|
+
A running long command is never interrupted, and if the snapshot fails the
|
|
237
|
+
seat is kept rather than lose the lens.
|
|
238
|
+
|
|
239
|
+
To be asked before the tools that run arbitrary commands, write files or
|
|
240
|
+
replace the current lens, add ask rules to the project's
|
|
241
|
+
`.claude/settings.json`:
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"permissions": {
|
|
246
|
+
"ask": [
|
|
247
|
+
"mcp__codev__run_command",
|
|
248
|
+
"mcp__codev__save_lens",
|
|
249
|
+
"mcp__codev__start_long_command",
|
|
250
|
+
"mcp__codev__restore_snapshot",
|
|
251
|
+
"mcp__codev__delete_snapshot"
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
An ask rule still asks under `bypassPermissions`. In a headless run
|
|
258
|
+
(`claude -p`) there is no one to ask, so those calls are denied.
|
|
259
|
+
|
|
260
|
+
## Tools
|
|
261
|
+
|
|
262
|
+
| Tool | Purpose |
|
|
263
|
+
|---|---|
|
|
264
|
+
| `attach_to_window` / `detach_from_window` | Drive your open CODE V window instead of a background session; detaching leaves it open |
|
|
265
|
+
| `session_status` | Is a session running (never starts one) |
|
|
266
|
+
| `start_session` / `stop_session` | Take and release the licence |
|
|
267
|
+
| `run_command` | Run command-line text, return the listing |
|
|
268
|
+
| `evaluate` | Evaluate a database item or expression, e.g. `(EFL)` |
|
|
269
|
+
| `open_lens` / `save_lens` | Restore or save a lens |
|
|
270
|
+
| `get_system_summary` | Title, EFL, f-number, wavelengths, fields |
|
|
271
|
+
| `get_surface_table` | Radius, thickness, glass, semi-diameter per surface |
|
|
272
|
+
| `get_system_data` | Fields (type, values, weights, vignetting), wavelengths and reference, and the aperture with which of EPD/FNO/NA/NAO is fixed |
|
|
273
|
+
| `set_fields` / `set_wavelengths` / `set_aperture` | Change them, confirmed by read-back; vignetting is recomputed when fields change |
|
|
274
|
+
| `set_surface` | Change radius, thickness, glass or clear aperture, confirmed by read-back |
|
|
275
|
+
| `set_variables` / `list_variables` | Vary or freeze radii, thicknesses and glasses; list variables, couplings and solves |
|
|
276
|
+
| `insert_surface` / `delete_surface` / `set_stop` | Change the surface sequence and the stop |
|
|
277
|
+
| `get_rms_spot` | RMS spot diameter per field |
|
|
278
|
+
| `get_wavefront_error` | RMS wavefront error per field, nominal or best focus, with Strehl from the PSF and (where valid) the Maréchal estimate |
|
|
279
|
+
| `get_field_aberrations` | Distortion, sagittal and tangential field curves and astigmatism every 10% of the field |
|
|
280
|
+
| `get_mtf` | Modulation and diffraction limit per field and frequency, azimuths 0 (radial) and 90 (tangential) |
|
|
281
|
+
| `plot` | Layout, ray fans, field curves, spot diagrams, MTF or PSF as images |
|
|
282
|
+
| `save_snapshot` / `restore_snapshot` | Save the lens under a label; restore it and verify it matches |
|
|
283
|
+
| `list_snapshots` / `delete_snapshot` | Manage saved snapshots |
|
|
284
|
+
| `list_tolerances` / `set_tolerances` / `delete_tolerances` | The lens's tolerances and compensators, with units and qualifiers (e.g. `R` on cemented rolls): CODE V's default set, single entries, deletions; confirmed by read-back, all or nothing |
|
|
285
|
+
| `tolerance_analysis` | TOR on RMS wavefront or MTF, in sensitivity mode (the lens's tolerances) or inverse mode (TOR sizes each tolerance for a degradation step, returned as a full budget that `set_tolerances` accepts): per-field expected performance with tolerances (97.7%), cumulative probabilities, compensator range, and the tolerances that matter most. Leaves the lens's tolerances as they were |
|
|
286
|
+
| `monte_carlo` / `get_monte_carlo_result` | TOLMONTE on spot size, MTF, Strehl or encircled energy: per-field spread over random builds, and yield against a threshold, compensated on the back focus or chosen variables; runs on a copy of the lens |
|
|
287
|
+
| `optimize` / `get_optimization_result` | Optimization from structured constraints, thickness limits and field weights; reports the error function, per-cycle history, variables before and after, whether each constraint was met, why AUT stopped, and thickness-limit violations |
|
|
288
|
+
| `start_long_command` / `poll_long_command` / `stop_long_command` | Optimization and other long runs; a snapshot is taken first |
|
|
289
|
+
| `reference_status` | Whether the reference data is built and what it holds |
|
|
290
|
+
| `search_manual` / `read_manual_page` | Full-text search of the CODE V help, then read a page |
|
|
291
|
+
| `lookup_glass` | nd, Vd, CTE, transmission range, properties and availability for a glass |
|
|
292
|
+
| `search_glass` | Glasses near an (nd, Vd) point, nearest first, discontinued left out by default |
|
|
293
|
+
|
|
294
|
+
The reference tools never start CODE V.
|
|
295
|
+
|
|
296
|
+
Every tool returns an envelope with `ok`, `errors`, `warnings` and `plots`,
|
|
297
|
+
filled from CODE V's COM events, so the agent can tell "ran" from "ran cleanly".
|
|
298
|
+
|
|
299
|
+
CODE V is started on the first tool call that needs it, not when the server starts.
|
|
300
|
+
|
|
301
|
+
## Configuration
|
|
302
|
+
|
|
303
|
+
| Variable | Default | Meaning |
|
|
304
|
+
|---|---|---|
|
|
305
|
+
| `CODEV_PROGID` | `CodeV.Application` | COM ProgID; set to pick a specific install |
|
|
306
|
+
| `CODEV_START_DIR` | `<data folder>\work` | CODE V starting directory; snapshots and plots are kept under it. Snapshots from the earlier `%TEMP%\codev-mcp` default are copied here on first use |
|
|
307
|
+
| `CODEV_DIR` | from the COM registration | CODE V install folder used by the reference build |
|
|
308
|
+
| `CODEV_IDLE_MINUTES` | `20` | Release the licence seat after this long without a tool call; `0` turns it off |
|
|
309
|
+
| `CODEV_MCP_DATA` | `%USERPROFILE%\codev-mcp` | The data folder: reference database and the default working folder. A database built under the earlier `%LOCALAPPDATA%\codev-mcp` default is still read if none exists here |
|
|
310
|
+
|
|
311
|
+
Avoid pointing either folder into `%LOCALAPPDATA%` or `%APPDATA%`. When the
|
|
312
|
+
server runs inside a packaged Windows app, such as the Claude desktop app,
|
|
313
|
+
Windows redirects new folders there into the app's private store. CODE V,
|
|
314
|
+
which COM starts outside the app, then cannot see them: `StartCodeV` fails and
|
|
315
|
+
snapshots cannot be saved or restored.
|
|
316
|
+
|
|
317
|
+
## Licensing note
|
|
318
|
+
|
|
319
|
+
CODE V finds its licence server through the environment. An MCP client that
|
|
320
|
+
launches the server with a trimmed environment (the Python SDK's
|
|
321
|
+
`stdio_client` does by default) produces "Cannot connect to license server";
|
|
322
|
+
pass the full environment through.
|
|
323
|
+
|
|
324
|
+
Which install runs is decided by the COM registration of the ProgID, and a
|
|
325
|
+
per-user registration (HKCU) overrides the machine-wide one. With several
|
|
326
|
+
versions installed, CODE V points it at the last version installed or the last
|
|
327
|
+
one run, so starting a version from its own shortcut once makes it the one
|
|
328
|
+
the server drives. `codev-mcp-doctor` shows which install COM resolves to, and
|
|
329
|
+
`start_session` reports the version that actually answered. A version needs
|
|
330
|
+
its own licence feature: CODE V names the version in the licence error.
|
|
331
|
+
|
|
332
|
+
## Layout
|
|
333
|
+
|
|
334
|
+
- `src/codev_mcp/engine.py` — COM wrapper; one worker thread owns the COM object
|
|
335
|
+
- `src/codev_mcp/edits.py` — lens edits with read-back checks
|
|
336
|
+
- `src/codev_mcp/snapshots.py` — named, fingerprinted lens snapshots
|
|
337
|
+
- `src/codev_mcp/plots.py` — plots rendered to PNG
|
|
338
|
+
- `src/codev_mcp/analyses.py` — typed analyses (RMSSPOT, RMS_1FLD, PSF_1FLD, MTF_1FLD, FIE)
|
|
339
|
+
- `src/codev_mcp/build_data.py` — builds the local reference database
|
|
340
|
+
- `src/codev_mcp/reference.py` — manual search and glass lookup over that database
|
|
341
|
+
- `src/codev_mcp/toldata.py` — tolerances and compensators in the lens, with read-back
|
|
342
|
+
- `src/codev_mcp/tolerance.py` — TOR sensitivity analysis (listing parser)
|
|
343
|
+
- `src/codev_mcp/montecarlo.py` — TOLMONTE runs, statistics and yield
|
|
344
|
+
- `src/codev_mcp/server.py` — MCP tool definitions
|
|
345
|
+
- `skills/` — workflow skills: design review, optimization loop, glass substitution, tolerancing
|
|
346
|
+
- `scripts/` — reference, connection and end-to-end tests
|
|
347
|
+
|
|
348
|
+
## Glass data notes
|
|
349
|
+
|
|
350
|
+
- nd and Vd are computed from each glass's dispersion formula at the d, F and
|
|
351
|
+
C lines and accepted only where they agree with the catalog's six-digit
|
|
352
|
+
glass code. Otherwise the glass code's rounded values are used, and
|
|
353
|
+
`index_source` says which.
|
|
354
|
+
- CTE is reported in ppm/K for the catalog's stated temperature range.
|
|
355
|
+
- Catalog properties stored as 0 mean "not given" and are left out.
|
|
356
|
+
|
|
357
|
+
## Contributing and roadmap
|
|
358
|
+
|
|
359
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) (commits are signed off under the DCO,
|
|
360
|
+
and vendor material stays out) and [ROADMAP.md](ROADMAP.md).
|
|
361
|
+
|
|
362
|
+
## Licence
|
|
363
|
+
|
|
364
|
+
Apache License 2.0; see [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
365
|
+
|
|
366
|
+
This is an independent project, not affiliated with or endorsed by Synopsys.
|
|
367
|
+
CODE V is a trademark of Synopsys, Inc. The repository contains no CODE V
|
|
368
|
+
software, documentation or data: the server drives your own licensed install,
|
|
369
|
+
and the reference data it builds stays on your machine. Please keep
|
|
370
|
+
vendor-derived material (manual text, glass catalogues, CODE V lens files) out
|
|
371
|
+
of issues and pull requests.
|