Skip to main content

codev-mcp

Experimental MCP server that lets a coding agent drive CODE V through its COM API. Code only: it uses your own licensed CODE V install at runtime and ships no vendor data.

For what an agent does with it, see the first trial: ten prompts on the Cooke triplet sample, from glass lookups to an optimization and a four-glass substitution study, and what the trial changed in the tools.

What the agent can change, what Claude asks first, how the licence is used and what leaves your machine: SECURITY.md.

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.

Install as a Claude Code plugin

You need Windows, CODE V installed with its COM server registered (the installer does this), and uv, which fetches codev-mcp and a Python for it. No Python setup is needed. Install uv once:

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, and four skills: design review, optimization loop, glass substitution and tolerancing. Its settings are the idle timeout, the data folder and the CODE V install folder (see Configuration); leave the folders blank for the defaults. Then ask Claude to build the reference data (build_reference_data, a few minutes, no licence) so it can search the CODE V manual and glass catalogs. If something does not work, ask it to run diagnose.

The plugin asks you before 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, so the prompt appears even where your own rules would allow the tool. If you would rather not be asked, register the server yourself (below) and write your own rules. The plugin's tools are named mcp__plugin_codev-mcp_codev__<tool>.

Install in Claude Desktop

On Windows with CODE V installed, download codev-mcp-<version>.mcpb from the latest release and open it (if Windows asks which app to use, choose Claude), or drag it into Claude Desktop. Nothing else is needed: Claude Desktop fetches a Python and codev-mcp itself, so the first tool call can take a minute or two. The extension's settings are the same three as the plugin's. Claude Desktop asks for your approval the first time a tool is used and then remembers it, so, unlike the plugin, it does not ask before every risky call (see SECURITY.md). Desktop extensions do not update themselves: install the new .mcpb for each release.

Install from source

Requirements:

  • Windows with CODE V installed and its COM server registered (the installer does this)
  • Python 3.11+
py -3.12 -m venv .venv
.venv\Scripts\python.exe -m pip install -e .

Build the reference data

.venv\Scripts\codev-mcp-build-data.exe

Indexes your CODE V help for full-text search and loads your glass catalogs into %USERPROFILE%\codev-mcp\reference.db. It finds the install from the COM registration (or pass --codev-dir), starts no CODE V session and uses no licence. It takes a few minutes. Nothing it produces is committed: the data comes from your own licensed install and stays on your machine. Until it is built, the reference tools return an "unavailable" result and everything else works.

Check the setup

.venv\Scripts\codev-mcp-doctor.exe
.venv\Scripts\codev-mcp-doctor.exe --engine

It checks Python and the packages, which CODE V install the COM registration points at (and whether any registration is stale), whether this process's AppData folders are redirected into a packaged app's private store, the data folder, the reference database and leftover background CODE V processes, and prints a fix for anything wrong. --engine also starts CODE V once, which takes a licence seat. --json gives machine-readable output.

Unit tests

.venv\Scripts\python.exe -m pip install -e ".[test]"
.venv\Scripts\python.exe -m pytest tests

These use a fake CODE V (tests/fake_codev.py) and need no licence; CI runs them on every push. The live checks below drive a real CODE V.

Check the install

.venv\Scripts\python.exe scripts\reference_test.py
.venv\Scripts\python.exe scripts\smoke_test.py
.venv\Scripts\python.exe scripts\edit_test.py
.venv\Scripts\python.exe scripts\field_test.py
.venv\Scripts\python.exe scripts\idle_test.py
.venv\Scripts\python.exe scripts\coverage_test.py
.venv\Scripts\python.exe scripts\snapshot_test.py
.venv\Scripts\python.exe scripts\plot_test.py
.venv\Scripts\python.exe scripts\mcp_client_test.py
  • reference_test checks the reference data against published glass values and needs no licence.
  • smoke_test drives CODE V directly.
  • edit_test exercises every edit tool on a sample lens, including a short optimization that must move the variables and nothing else.
  • idle_test runs the idle timeout with a 4-second limit: release, restore with edits and variables intact, and no release during a long command.
  • field_test checks distortion and field curves against CODE V's own FIE listing, including the sign convention.
  • snapshot_test saves, wrecks and restores a lens, and checks that a restore that does not match its fingerprint is reported.
  • plot_test renders every plot kind from a deliberately long folder path.
  • coverage_test runs the core tools on nine sample lenses chosen to cover zoom, afocal, finite-object, mirror, aspheric and decentered systems, and checks the results make sense. --sweep runs the read-only tools on every sample lens in the install.
  • attach_test PID_UI drives an open CODE V window through the tools (open, edit, analyse, plot, optimize, snapshot), then checks that detaching leaves it open. Use a window you do not mind being changed.
  • sysdata_test reads and changes fields, wavelengths and the aperture on an infinite-object and a finite-object lens, including the refusals.
  • tolerance_test runs tolerance_analysis on the Cooke triplet (RMS and MTF), a zoom lens and a decentered mirror system, and checks that each field's value with tolerances equals nominal plus probable change, and that repeated runs agree and leave no tolerances behind.
  • monte_carlo_test sets, reads back and deletes tolerances and compensators, compares TOR's sensitivity and inverse modes, and runs monte_carlo on four metrics and a zoom lens, checking that the lens, its variables and its tolerances come back unchanged; on the double Gauss it checks qualifiers, rollback of a failed change, and the inverse budget.
  • optimize_test runs optimize on the Cooke triplet and a zoom lens: constraints met, undo by snapshot, wavefront error function, and a constraint CODE V rejects (it is named, and the run is marked failed). On the double Gauss it checks AUT's stop reason, min_improvement, and that a wavefront call's warnings do not leak into the next tool.
  • version_check OLD_DIR NEW_DIR compares two CODE V installs without a licence: the COM methods the tools call, the manual pages they rely on, sample lenses and glass catalogs. Run it when a new CODE V version arrives.
  • mcp_client_test launches the server over stdio and calls its tools the way an agent would.

All but the first take a licence seat while they run.

How edits are checked

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 fields 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; 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.

Working in your own CODE V window

By default the server runs its own hidden CODE V session. attach_to_window connects it to a CODE V window you have open instead, through CODE V's interactive COM (CVLocator), so you watch every command and edit happen in that window, 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 CODE V version and licence are used, and the server takes no extra licence seat; the idle timeout does not apply.
  • detach_from_window, or stop_session while attached, ends the connection and leaves the window open (in this mode StopCodeV only disconnects, as CODE V's interactive-COM examples rely on).
  • Attaching is refused while a background session is running, so its lens is not lost silently. If you close the window, tools say so instead of starting a hidden session.

Snapshots and plots

Snapshots are .len files in <starting directory>\snapshots with an index.json holding a fingerprint of each lens (title, EFL, stop, counts and every surface's radius, thickness and glass). A restore is reported as successful only if the restored lens matches that fingerprint. start_long_command takes an auto- snapshot first, and the newest 20 of those are kept.

Plots are written to <starting directory>\plots at full size, and the agent gets a copy scaled to max_pixels (1600 by default). Legacy plots (layout, ray fan, field curves, spot) go through GRA and GCV; charts (MTF, PSF) through WGF. CODE V truncates GRA file names beyond about 80 characters, so plot paths are kept short and relative to the starting directory.

Register with Claude Code

Without the plugin, register the published package (needs uv):

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

or a source checkout:

claude mcp add codev -- C:\full\path\to\.venv\Scripts\python.exe -m codev_mcp

By default this registers the server for the current project only.

Without the claude command (the desktop app does not put one on PATH), create .mcp.json in the project root instead; Claude Code asks you to approve it the first time it starts there:

{
  "mcpServers": {
    "codev": {
      "type": "stdio",
      "command": "C:\\full\\path\\to\\.venv\\Scripts\\python.exe",
      "args": ["-m", "codev_mcp"]
    }
  }
}

This repository ignores .mcp.json, because it holds a machine-specific path.

Any tool that needs CODE V starts its own background session and takes a licence seat. If you have one seat and the CODE V GUI open, those calls will fail with a licence error.

The seat is released by stop_session, when the client disconnects, or after 20 minutes without a tool call (CODEV_IDLE_MINUTES; 0 turns this off). On an idle release the lens is snapshotted first (auto-idle-…), and the next tool call restarts CODE V, restores it and adds a session_notice to its result. A running long command is never interrupted, and if the snapshot fails the seat is kept rather than lose the lens.

To be asked before the tools that run arbitrary commands, write files or replace the current lens, add ask rules to the project's .claude/settings.json:

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

An ask rule still asks under bypassPermissions. In a headless run (claude -p) there is no one to ask, so those calls are denied.

Tools

Every tool returns a JSON object (for plot, the first content item) with at least these keys:

Key Meaning
ok true if the call did what was asked
errors Error messages CODE V raised during the call (empty for tools that do not use CODE V)
warnings Warning messages CODE V raised, or setting problems for session_status
error_detail Present 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); error_detail always holds the message, so read that one.

Tool Purpose
attach_to_window / detach_from_window Drive your open CODE V window instead of a background session; detaching leaves it open
session_status Is a session running (never starts one)
start_session / stop_session Take and release the licence
run_command Run command-line text, return the listing
evaluate Evaluate a database item or expression, e.g. (EFL)
open_lens / save_lens Restore or save a lens
get_system_summary Title, EFL, f-number, wavelengths, fields
get_surface_table Radius, thickness, glass, semi-diameter per surface
get_system_data Fields (type, values, weights, vignetting), wavelengths and reference, and the aperture with which of EPD/FNO/NA/NAO is fixed
set_fields / set_wavelengths / set_aperture Change them, confirmed by read-back; vignetting is recomputed when fields change
set_surface Change radius, thickness, glass or clear aperture, confirmed by read-back
set_variables / list_variables Vary or freeze radii, thicknesses and glasses; list variables, couplings and solves
insert_surface / delete_surface / set_stop Change the surface sequence and the stop
get_rms_spot RMS spot diameter per field
get_wavefront_error RMS wavefront error per field, nominal or best focus, with Strehl from the PSF and (where valid) the Maréchal estimate
get_field_aberrations Distortion, sagittal and tangential field curves and astigmatism every 10% of the field
get_mtf Modulation and diffraction limit per field and frequency, azimuths 0 (radial) and 90 (tangential)
plot Layout, ray fans, field curves, spot diagrams, MTF or PSF as images
save_snapshot / restore_snapshot Save the lens under a label; restore it and verify it matches
list_snapshots / delete_snapshot Manage saved snapshots
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
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
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
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
start_long_command / poll_long_command / stop_long_command Optimization and other long runs; a snapshot is taken first
reference_status Whether the reference data is built and what it holds
search_manual / read_manual_page Full-text search of the CODE V help, then read a page
lookup_glass nd, Vd, CTE, transmission range, properties and availability for a glass
search_glass Glasses near an (nd, Vd) point, nearest first, discontinued left out by default

The reference tools never start CODE V.

In tools that use CODE V, errors and warnings (and plots, the plot files written) come from CODE V's COM events, so the agent can tell "ran" from "ran cleanly".

CODE V is started on the first tool call that needs it, not when the server starts.

Configuration

Variable Default Meaning
CODEV_PROGID CodeV.Application COM ProgID; set to pick a specific install
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
CODEV_DIR from the COM registration CODE V install folder used by the reference build
CODEV_IDLE_MINUTES 20 Release the licence seat after this long without a tool call; 0 turns it off
CODEV_REQUIRE_APPROVAL off 1 marks run_command, start_long_command, save_lens, restore_snapshot and delete_snapshot as needing the user's 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 ask hook instead
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

Avoid pointing either folder into %LOCALAPPDATA% or %APPDATA%. When the server runs inside a packaged Windows app, such as the Claude desktop app, Windows redirects new folders there into the app's private store. CODE V, which COM starts outside the app, then cannot see them: StartCodeV fails and snapshots cannot be saved or restored.

Licensing note

CODE V finds its licence server through the environment. An MCP client that launches the server with a trimmed environment (the Python SDK's stdio_client does by default) produces "Cannot connect to license server"; pass the full environment through.

Which install runs is decided by the COM registration of the ProgID, and a per-user registration (HKCU) overrides the machine-wide one. With several versions installed, CODE V points it at the last version installed or the last one run, so starting a version from its own shortcut once makes it the one the server drives. codev-mcp-doctor shows which install COM resolves to, and start_session reports the version that actually answered. A version needs its own licence feature: CODE V names the version in the licence error.

Layout

  • src/codev_mcp/engine.py — COM wrapper; one worker thread owns the COM object
  • src/codev_mcp/edits.py — lens edits with read-back checks
  • src/codev_mcp/snapshots.py — named, fingerprinted lens snapshots
  • src/codev_mcp/plots.py — plots rendered to PNG
  • src/codev_mcp/analyses.py — typed analyses (RMSSPOT, RMS_1FLD, PSF_1FLD, MTF_1FLD, FIE)
  • src/codev_mcp/build_data.py — builds the local reference database
  • src/codev_mcp/reference.py — manual search and glass lookup over that database
  • src/codev_mcp/toldata.py — tolerances and compensators in the lens, with read-back
  • src/codev_mcp/tolerance.py — TOR sensitivity analysis (listing parser)
  • src/codev_mcp/montecarlo.py — TOLMONTE runs, statistics and yield
  • src/codev_mcp/server.py — MCP tool definitions
  • skills/ — workflow skills: design review, optimization loop, glass substitution, tolerancing
  • scripts/ — reference, connection and end-to-end tests

Glass data notes

  • nd and Vd are computed from each glass's dispersion formula at the d, F and C lines and accepted only where they agree with the catalog's six-digit glass code. Otherwise the glass 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.

Contributing and roadmap

See CONTRIBUTING.md (commits are signed off under the DCO, and vendor material stays out) and ROADMAP.md.

Licence

Apache License 2.0; see LICENSE and NOTICE.

This is an independent project, not affiliated with or endorsed by Keysight Technologies (CODE V's owner since October 2025) or Synopsys (its previous owner). CODE V is a trademark of its owner. The repository contains no CODE V software, documentation or data: the server drives your own licensed install, and the reference data it builds stays on your machine. Please keep vendor-derived material (manual text, glass catalogues, CODE V lens files) out of issues and pull requests.

Metadata

Release files for codev-mcp 0.2.0

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

Source distribution (sdist)

Source distribution for codev-mcp 0.2.0
File Size Uploaded Provenance Actions
codev_mcp-0.2.0.tar.gz 140.9 kB With provenance Details for codev_mcp-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codev-mcp 0.2.0
File Interpreter ABI Platform Actions
codev_mcp-0.2.0-py3-none-any.whl Python 3 none any Details for codev_mcp-0.2.0-py3-none-any.whl

Total release size: 237.4 kB

Release files / codev_mcp-0.2.0.tar.gz

Download URL codev_mcp-0.2.0.tar.gz
Size 140.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8943501a3c610a149aeb87ed27124543d35f3d2de1b43e6ea0043149e8d0d617
BLAKE2b-256 checksum
How to use checksums
dc5167896847aecbc83e3ffd449021173c33dfcf1f2b989a996316bd9e810030
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 Dec 5, 2026.

Transparency log

Release files / codev_mcp-0.2.0-py3-none-any.whl

Download URL codev_mcp-0.2.0-py3-none-any.whl
Size 96.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a15463390939bf3e8d665de273509adb2d79180c2e65bbcac221adef19a4166d
BLAKE2b-256 checksum
How to use checksums
690720020ec6b55ff64f87d558f413997d5a0f1828f159b6b1380dda593d7f79
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 Dec 5, 2026.

Transparency log

Security for codev-mcp 0.2.0

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 codev_mcp-0.2.0.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 Dec 5, 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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