Repository avatar
Other Tools
v0.2.0
active

codev-mcp

io.github.br24563/codev-mcp

Unofficial: drive your licensed CODE V install over COM (Windows only, CODE V required)

Documentation

codev-mcp for CODE V

codev-mcp lets Claude work in CODE V, the optical design program, through your own licensed install. Claude can:

  • open and edit lenses, with every change read back;
  • run analyses: spot size, wavefront, MTF, distortion and field curves;
  • optimize with typed constraints;
  • tolerance with TOR and Monte Carlo;
  • plot the design;
  • search your CODE V manual and glass catalogs.

It runs on your Windows machine and ships no CODE V software or data.

Unofficial. codev-mcp is not made, endorsed or supported by Keysight Technologies, which has owned CODE V since buying it from Synopsys in October 2025, nor by Synopsys. CODE V is a trademark of its owner.

  • What the agent can change, what Claude asks first, how the licence is used and what leaves your machine: SECURITY.md
  • What an agent does with it: the first trial (ten prompts on the Cooke triplet) and the second (a double Gauss through optimization, a glass change and tolerancing)

What you need

  • Windows
  • CODE V installed, with its COM server registered (the CODE V installer does this)
  • A CODE V licence. Each background session takes one seat while it runs.

Install

You useInstallWhat you get
Claude Desktopthe .mcpb extensionThe server. Nothing else to install.
Claude Codethe pluginThe server, four lens-design skills, and an ask-first hook
Another MCP clientthe PyPI packageThe server

Claude Desktop

  1. Download codev-mcp-<version>.mcpb from the latest release.
  2. Open it. If Windows asks which app to use, choose Claude. Or drag it into Claude Desktop, or use Settings → Extensions → Advanced settings → Install Extension….
  3. Review the settings. The defaults suit most installs; leave the folders blank.

Claude Desktop fetches a Python and codev-mcp itself, so the first tool call can take a minute or two.

Claude Desktop asks for your approval the first time a tool is used, then remembers your answer. Unlike the plugin, it does not ask before every call to the risky tools. See SECURITY.md.

Extensions do not update themselves. Install the new .mcpb for each release.

Claude Code

Install uv once; it fetches codev-mcp and a Python for it:

winget install astral-sh.uv

Then, in Claude Code:

/plugin install codev-mcp --marketplace br24563/CodeV-mcp

On older Claude Code versions, run /plugin marketplace add br24563/CodeV-mcp first, then /plugin install codev-mcp@codev-mcp.

The plugin brings:

  • the server, pinned to a released version on PyPI;
  • the settings;
  • four skills: design review, optimization loop, glass substitution and tolerancing. Claude uses them when you ask for that kind of work.

It asks first. The plugin asks you before every call to run_command, start_long_command, save_lens, restore_snapshot and delete_snapshot: the tools that can run any CODE V command, overwrite a file or discard work.

  • It does this with a hook, because a plugin cannot ship permission rules. The prompt therefore appears even where your own rules would allow the tool.
  • If you would rather not be asked, register the server yourself as below and write your own rules.
  • The plugin's tools are named mcp__plugin_codev-mcp_codev__<tool>.

Other MCP clients

codev-mcp is on PyPI and in the MCP Registry as io.github.br24563/codev-mcp. With uv installed, the command is uvx codev-mcp==<version>.

Claude Code without the plugin:

claude mcp add codev -- uvx codev-mcp==0.2.0

Or put this in .mcp.json in your project; Claude Code asks you to approve it the first time:

{
  "mcpServers": {
    "codev": { "type": "stdio", "command": "uvx", "args": ["codev-mcp==0.2.0"] }
  }
}

To be asked before the risky tools, add ask rules to .claude/settings.json:

{
  "permissions": {
    "ask": [
      "mcp__codev__run_command",
      "mcp__codev__start_long_command",
      "mcp__codev__save_lens",
      "mcp__codev__restore_snapshot",
      "mcp__codev__delete_snapshot"
    ]
  }
}

An ask rule still asks in bypassPermissions mode. Setting CODEV_REQUIRE_APPROVAL=1 asks before every call to those tools even in auto mode. In a headless run (claude -p) there is no one to ask, so those calls are denied.

Any client: pass the full environment through to the server. CODE V finds its licence server through environment variables, so a trimmed environment gives "Cannot connect to license server". The Python SDK's stdio_client trims it by default.

First steps

  1. Build the reference data. Ask Claude to "build the CODE V reference data".

    • build_reference_data indexes your CODE V help and loads your glass catalogs into the data folder. It takes a few minutes and no licence.
    • Until it is built, manual search and glass lookup say so; everything else works.
    • Rebuild it (rebuild: true) after a CODE V update.
  2. Check the setup. Ask Claude to "run diagnose". It checks:

    • Python and the packages;
    • which CODE V install the COM registration points at, and any stale registrations;
    • whether the folders are visible to CODE V;
    • the reference data;
    • leftover background CODE V sessions;
    • the settings.

    It prints a fix for anything wrong and never starts CODE V. To check that CODE V starts and a licence is free, ask Claude to start a session.

  3. Try it. For example:

    • "Open the Cooke triplet sample (cv_lens:cooke1) and review the design."
    • "Optimize it for RMS spot size, keeping the focal length at 50 mm and every lens at least 2 mm thick at the edge."
    • "The second element's glass is discontinued. Find a substitute with a similar index and dispersion, swap it in and re-optimize."
    • "Tolerance the lens for MTF at 30 lp/mm and predict the yield if 0.4 is the minimum."
    • "Show me the layout and the ray fans."

Settings

The Desktop extension and the plugin offer three settings. Other clients set the same names as environment variables. A blank value means the default.

SettingVariableDefaultMeaning
Idle timeout (minutes)CODEV_IDLE_MINUTES20Stop CODE V and free the licence seat after this long without a tool call; 0 turns it off
Data folderCODEV_MCP_DATA%USERPROFILE%\codev-mcpSnapshots, plots and the reference data
CODE V install folderCODEV_DIRfrom the COM registrationUsed only to build the reference data

Keep the data folder out of %LOCALAPPDATA% and %APPDATA%. Inside the Claude desktop app, Windows redirects new folders there into the app's private store. CODE V, which COM starts outside the app, cannot see them, so it fails to start and snapshots cannot be saved or restored. diagnose and session_status warn about it.

Advanced settings, as environment variables only:

VariableDefaultMeaning
CODEV_PROGIDCodeV.ApplicationCOM ProgID; set it to pick a specific install
CODEV_START_DIR<data folder>\workCODE V's starting directory, where snapshots and plots are kept
CODEV_REQUIRE_APPROVALoff1 marks the five risky tools as needing approval on every call (anthropic/requiresUserInteraction). Claude Code honours it, even in auto mode; Claude Desktop currently does not. The Desktop extension sets it; the plugin uses its hook instead

How it keeps your work safe

Edits are read back. CODE V accepts some edits that it then ignores or turns into something else, with at most a warning. The edit tools guard against this:

  • Every change is read back. One that did not stick is a failure, and later changes in the same call are not applied.
  • A value held by a solve (for example the PIM paraxial image thickness) is refused unless release_solves is true. Without this, varying the PIM thickness quietly deletes the image solve.
  • Variable codes are read from the lens listing (LIS), because the (VAR Ik) database items go stale after a variable is frozen or coupled.
  • Making a glass variable replaces it with a fictitious glass model, and the tool says so.
  • Vignetting factors are stored per field number and do not follow a change of fields, so set_fields recomputes them (SET VIG) unless told otherwise.
  • Object-space settings on an object at infinity (object heights, object NA) are accepted by CODE V but meaningless, so they are refused.

Snapshots. Snapshots are .len files with a fingerprint of each lens: title, EFL, stop, counts, and every surface's radius, thickness and glass. A restore counts as successful only if the restored lens matches its fingerprint. optimize and start_long_command take a snapshot first, so a run that goes wrong can be undone. The newest 20 automatic snapshots are kept.

The licence seat. Any tool that needs CODE V starts a hidden background session, which takes one seat. With a single seat and the CODE V GUI open, those calls fail with a licence error; use your own window instead (below).

The seat is released by stop_session, when the client disconnects, or after the idle timeout. Before an idle release the lens is snapshotted. The next tool call starts CODE V again, restores the lens and says so in a session_notice. A running long command is never interrupted. If the snapshot fails, the seat is kept rather than lose the lens.

Your own CODE V window. attach_to_window drives a CODE V window you have open instead of a hidden session. You see every command and edit happen on its current lens. Give the window's PID UI (eva (pid ui) in its command window), or 0 for the first open window.

  • The window's own version and licence are used. No extra seat is taken, and the idle timeout does not apply.
  • detach_from_window, or stop_session while attached, ends the connection and leaves the window open.
  • Attaching is refused while a background session runs, so its lens is not lost. If you close the window, tools say so instead of quietly starting a hidden session.

Tools

Every tool returns a JSON object with at least these keys. For plot, that is the first content item.

KeyMeaning
oktrue if the call did what was asked
errorsError messages CODE V raised during the call (empty for tools that do not use CODE V)
warningsWarning messages CODE V raised, or setting problems for session_status
error_detailPresent when ok is false: what went wrong, in one message

ok can be true with warnings, since CODE V often accepts a command and only warns. Some failures also carry an older key (error or exception), but error_detail always holds the message.

ToolPurpose
session_statusIs a session running, the settings in effect, and setting problems (never starts CODE V)
diagnoseCheck the install and say how to fix what is wrong (never starts CODE V)
start_session / stop_sessionTake and release the licence
attach_to_window / detach_from_windowDrive your open CODE V window instead of a background session; detaching leaves it open
run_commandRun command-line text, return the listing
evaluateEvaluate a database item or expression, e.g. (EFL)
open_lens / save_lensRestore or save a lens
get_system_summaryTitle, EFL, f-number, wavelengths, fields
get_surface_tableRadius, thickness, glass, semi-diameter per surface
get_system_dataFields (type, values, weights, vignetting), wavelengths and reference, and the aperture with which of EPD/FNO/NA/NAO is fixed
set_fields / set_wavelengths / set_apertureChange them, confirmed by read-back; vignetting is recomputed when fields change
set_surfaceChange radius, thickness, glass or clear aperture, confirmed by read-back
set_variables / list_variablesVary or freeze radii, thicknesses and glasses; list variables, couplings and solves
insert_surface / delete_surface / set_stopChange the surface sequence and the stop
get_rms_spotRMS spot diameter per field
get_wavefront_errorRMS wavefront error per field, nominal or best focus, with Strehl from the PSF and (where valid) the Maréchal estimate
get_field_aberrationsDistortion, sagittal and tangential field curves and astigmatism every 10% of the field
get_mtfModulation and diffraction limit per field and frequency, azimuths 0 (radial) and 90 (tangential)
plotLayout, ray fans, field curves, spot diagrams, MTF or PSF as images
save_snapshot / restore_snapshotSave the lens under a label; restore it and verify it matches
list_snapshots / delete_snapshotManage saved snapshots
optimize / get_optimization_resultOptimization 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
start_long_command / poll_long_command / stop_long_commandOptimization and other long runs; a snapshot is taken first
list_tolerances / set_tolerances / delete_tolerancesThe 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
tolerance_analysisTOR on RMS wavefront or MTF, in sensitivity mode (the lens's tolerances) or inverse mode (a full budget that set_tolerances accepts). Gives 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
monte_carlo / get_monte_carlo_resultTOLMONTE 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
build_reference_dataBuild the manual and glass reference data from your install, in the background, with no licence
reference_statusWhether the reference data is built, what it holds, and a running build's progress
search_manual / read_manual_pageFull-text search of the CODE V help, then read a page
lookup_glassnd, Vd, CTE, transmission range, properties and availability for a glass
search_glassGlasses near an (nd, Vd) point, nearest first, discontinued left out by default

About the glass data:

  • nd and Vd are computed from each glass's dispersion formula at the d, F and C lines. They are used only where they agree with the catalog's six-digit glass code; otherwise the code's rounded values are used, and index_source says which.
  • CTE is reported in ppm/K for the catalog's stated temperature range.
  • Catalog properties stored as 0 mean "not given" and are left out.

Troubleshooting

  • "Cannot connect to license server": the client started the server with a trimmed environment. Pass the full environment through (see Other MCP clients).
  • Licence error naming a CODE V version: each version needs its own licence feature.
  • The wrong CODE V version runs: which install runs is decided by the COM registration, and a per-user registration overrides the machine-wide one. CODE V points it at the last version installed or the last one run, so starting a version once from its own shortcut makes it the one codev-mcp drives.
    • diagnose shows which install COM resolves to, and start_session reports the version that answered.
    • After switching, rebuild the reference data.
  • CODE V will not start from Claude Desktop, or snapshots go missing: the data folder is probably under AppData; see Settings.
  • Anything else: ask Claude to run diagnose, and open an issue with its output.

Privacy

codev-mcp has no network code: it sends no telemetry and contacts no service. CODE V contacts your licence server as usual. Tool results, including lens data, plots and manual text, go to Claude as part of your conversation, like anything else you send it. The reference data, snapshots and plots stay on your machine. Details: SECURITY.md.

Contributing, roadmap and licence

CONTRIBUTING.md covers installing from source, the tests, and the live CODE V checks. Commits are signed off under the DCO, and vendor material stays out. See ROADMAP.md for where the project is heading.

Licensed under the Apache License 2.0; see LICENSE and NOTICE. The repository contains no CODE V software, documentation or data. Please keep vendor-derived material out of issues and pull requests: manual text, glass catalogs and CODE V lens files.

PYPI
codev-mcp
Install Command
pip install codev-mcp
Runtime: uvx
MCPB
https://github.com/br24563/CodeV-mcp/releases/download/v0.2.0/codev-mcp-0.2.0.mcpb
Install Command
# mcpb: https://github.com/br24563/CodeV-mcp/releases/download/v0.2.0/codev-mcp-0.2.0.mcpb