Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
8b377b8
Isolate legacy experimental execution from sidecar dependencies
xuio Sep 5, 2026
16ea158
Repair NX v2606 sketch and feature API workflows
xuio Sep 5, 2026
c062eeb
Add reference lifecycle, recovery, artifacts and NX2606 integration t…
xuio Sep 5, 2026
adb26ab
Add visible NX UI bridge, native collision checks and viewport images
xuio Sep 5, 2026
0e897bd
Add collision highlighting, sections, appearance and sketch diagnostics
xuio Sep 5, 2026
5f4bc15
Document fork setup, live validation and upstream readiness gaps
xuio Sep 5, 2026
2148867
Repair upstream regressions and add reproducible NX dev3 deployment p…
xuio Sep 5, 2026
ee6c66e
Record dev3 hosted checks, native deployment and rollback verification
xuio Sep 5, 2026
5e4d66e
Cover recovery failure paths and preserve native cleanup outcomes
xuio Sep 5, 2026
6967a44
Record dev4 CI and deployed NX validation
xuio Sep 5, 2026
1dafbc9
Add NX authoring, inspection reports and reversible change previews
xuio Sep 5, 2026
9b89fb5
Return workspace-relative artifact paths for reports and presentations
xuio Sep 5, 2026
8f22895
Record deployed dev5 native and public MCP acceptance
xuio Sep 5, 2026
d9b5a1c
Add exact selection, native assembly patterns and verified sketch rel…
xuio Sep 5, 2026
94615a6
Record dev6 deployment acceptance and upstream review status
xuio Sep 5, 2026
740a034
Support explicit project folders and in-workspace absolute file paths
xuio Sep 5, 2026
3d86a6c
Document deployed project-folder acceptance and reproducible native c…
xuio Sep 5, 2026
d381426
Add native engineering authoring and repair NX 2606 modeling and draf…
xuio Sep 5, 2026
bfca807
Record deployed dev8 acceptance and extend reproducible native regres…
xuio Sep 5, 2026
bc54d38
Add native exploded assembly views and associative drawing support
xuio Sep 5, 2026
4f18ab8
Record deployed NX 2606 explosion acceptance and recovery evidence
xuio Sep 5, 2026
f85dce3
Synchronize response-timeout retry test with server receipt
xuio Sep 5, 2026
80eed43
Add native NX sheet-metal authoring, flat patterns and path sketches
xuio Sep 5, 2026
2f0ff40
Record deployed sheet-metal acceptance and complete the public workfl…
xuio Sep 6, 2026
b2f1acc
Add native freeform, assembly documentation and manufacturing tools
xuio Sep 6, 2026
1dfd2c8
Restore drawing presentation around native PDF exports
xuio Sep 6, 2026
b88c710
Keep drawing restoration regression lint-clean
xuio Sep 6, 2026
9c0d45e
Record deployed dev11 native acceptance and verified scope
xuio Sep 6, 2026
d0c161f
Add editable documentation and native manufacturing workflows
xuio Sep 6, 2026
a901f4d
Keep the service assembly view inside its drawing sheet
xuio Sep 6, 2026
c3bdb52
Refresh native bend tables transactionally after model changes
xuio Sep 6, 2026
db9fb07
Record dev12 native workflow and recovery acceptance
xuio Sep 6, 2026
7556d93
Add native drawing editing, assembly refresh and release acceptance
xuio Sep 6, 2026
7942284
Normalize native receipt artifact paths across platforms
xuio Sep 6, 2026
3d0e479
Record native dev13 acceptance and harden the validation runner
xuio Sep 6, 2026
80ef68e
Consolidate dev14 and fix native lifecycle and recovery findings
xuio Sep 6, 2026
362f80f
Assert analytic nested interference independent of enumeration order
xuio Sep 6, 2026
052a9d3
Improve agent discovery, artifact previews and response contracts
xuio Sep 6, 2026
0023441
Clarify boolean operands, revolve axis and missing-directory errors
xuio Sep 6, 2026
5dcd455
docs: record consolidated dev14 native and agent UX acceptance
xuio Sep 6, 2026
55eebce
Improve agent contracts and add repeatable native release acceptance
xuio Sep 6, 2026
f44ffb3
Handle Windows shared-drive paths in release acceptance
xuio Sep 6, 2026
077f222
Apply native agent workflow feedback to lifecycle and selection guidance
xuio Sep 6, 2026
1b8a181
Record final dev15 native acceptance and independent workflow evidence
xuio Sep 6, 2026
2b56802
Add reference geometry controls and compact typed NX inspections
xuio Sep 6, 2026
e666c8e
Publish verified NX inspection guidance and native UX acceptance fixt…
xuio Sep 6, 2026
e3d4c0a
Allow named NX arguments in the native UX test client
xuio Sep 6, 2026
d68441a
Pass the selected tool profile to native acceptance examples
xuio Sep 6, 2026
c64d67e
Record dev16 deployment and reconciled native validation evidence
xuio Sep 6, 2026
dbb421b
Add compact agent profile with discovery, receipts and artifact resou…
xuio Sep 6, 2026
5f98e55
Record dev17 native acceptance and scoped token measurements
xuio Sep 6, 2026
f91cb2b
Add reviewed agent guidance, stable inspection pages and snapshot ret…
xuio Sep 6, 2026
9254c02
Fix page cardinality and discovery issues found by fresh agents
xuio Sep 6, 2026
a8ef3a2
Document dev18 deployment and fresh-agent validation
xuio Sep 6, 2026
b2584ee
Repair remaining legacy tools and consolidate integration documentation
xuio Sep 6, 2026
d7d5dc3
Record scoped legacy acceptance and correct graphical view metadata
xuio Sep 6, 2026
6d3266c
Document final dev19 native and deployment acceptance
xuio Sep 6, 2026
4ac96b7
Fix manufacturing drawing contracts, import recovery and bounded results
xuio Sep 7, 2026
337b81f
Save only the explicitly selected work part
xuio Sep 7, 2026
2498994
Record deployed manufacturing regression evidence
xuio Sep 7, 2026
e9bb14f
Audit work-part saves and document native follow-up limits
xuio Sep 7, 2026
fc74c9b
Record deployed save audit verification
xuio Sep 7, 2026
4c81522
Fix section curves, shaded PDFs and unloaded assembly prototypes
xuio Sep 7, 2026
6125b7d
Update PDF drafting views without a modeling undo mark
xuio Sep 7, 2026
35f8752
Record deployed A02 regression verification
xuio Sep 7, 2026
3fd33c7
Expose UI activity during native work and clarify input reservation
xuio Sep 7, 2026
bc446b0
Keep interactive health requests independent of the NX queue
xuio Sep 7, 2026
1e26fb2
Keep the control panel above its NX owner window
xuio Sep 7, 2026
6f73a05
Record native UI responsiveness and handoff validation
xuio Sep 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build offline NX release
on:
workflow_dispatch:
permissions:
contents: read
jobs:
package:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install -r requirements-build.txt
- run: python scripts/build_release.py --output dist
- uses: actions/upload-artifact@v4
with:
name: nx-mcp-windows-offline
path: dist/*
13 changes: 13 additions & 0 deletions INTERACTIVE-NX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Interactive NX MCP, v2606

Play `examples/start_nx_interactive.py` once in graphical NX. The journal returns. A pinned Win32 timer callback drains one authenticated bridge request at a time on the registering NX UI thread. The HTTP/MCP process remains separate; it never calls NXOpen. The NX MCP control window shows activity and provides Pause, Resume, and Stop. Long native operations can temporarily block NX; pause/stop take effect between calls.

Agent mode locks NX model editing with `UI.LockAccess`. Pause releases it for manual work. Pausing invalidates agent references and checkpoints: manual changes have no operation receipt and must not be undone by a later agent rollback. Reacquire references after resuming. Closing the control panel stops the bridge and unlocks NX, leaving the application and parts open.

`nx_screenshot` uses `Part.Views.CreateImageExportBuilder` and returns a PNG artifact plus MCP image content. It captures the displayed CAD viewport, never the desktop. White/transparent/original backgrounds and shaded/shaded-with-edges/static-wireframe styles are exposed. Width and height are advisory: the installed graphics driver can use the actual device size, so both requested and actual resolution are returned. These are viewport renderings, not photorealistic ray tracing. Images above 8 MiB use chunked artifact download. `nx_view_info` reports the display-part view axes, NX view origin, absolute origin, scale, and style.

`nx_check_interference` examines the cross-product of two selected bodies/components, including nested body occurrences. `nx_check_clearance` examines every distinct body pair in selected groups or the full assembly. Conservative boxes only prune provably separated pairs; reported distances use native geometry. Native solid intersection distinguishes penetration, contact and separation and measures pairwise overlap volumes in mm³. Temporary interference solids are rolled back explicitly: NX builder Reset alone does not remove them. Body/feature counts are checked afterward. Pairwise overlap volumes are not geometric union volume. Custom reference-set edge cases and general solid-validity certification remain outside the validated scope.

Use a stable operation ID for mutation retry. A queued request that expires before execution is discarded. If execution already began, a transport timeout reports an unknown outcome; query the durable receipt. Do not send simultaneous NXOpen mutations. Save, manual handoff, and part lifecycle changes can invalidate native recovery marks; query checkpoint state.

Validation includes native GUI thread identity, visible sketch/extrusion, pause/resume, native PNGs, cubes with 500 mm³ overlap, contact and 2 mm separation, a 3 mm clearance requirement, and a rotated nested assembly. Saved flags and checkpoints survive collision inspection. The prior eleven batch regression groups remain separate evidence; tool status does not imply every NX feature has been tested.
197 changes: 90 additions & 107 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,138 +1,121 @@
# NX MCP Server

NX MCP is a local Model Context Protocol server for Siemens NX automation. The
`0.2.0.dev0` line replaces the unverified direct-attach design with two explicit
processes:
NX MCP lets an MCP client inspect and edit Siemens NX through an NX-owned bridge.
The sidecar validates requests and manages transport; NXOpen calls run serially
on the NX thread. The sidecar imports without NX installed.

```text
MCP client <--stdio--> Python sidecar <--authenticated loopback JSON-RPC--> NX bridge <--NXOpen--> NX
MCP client Python sidecar authenticated loopback bridge NXOpen / NX
```

The sidecar can start without NX. Tool calls fail with `NX_BRIDGE_UNAVAILABLE`
until an NX journal starts the bridge.
This fork targets **NX 2606 on Windows**. Upstream's NX 2506 batch evidence is
historical and does not establish cross-version compatibility for these additions.
See the [capability matrix](docs/capability-matrix.md) for per-tool evidence and
limits. “Tested” applies to the recorded fixtures, not every option of a builder.

## Current status
## Choose a tool profile

The sidecar, bridge protocol, input/output schemas, workspace confinement, and
core workflow have automated coverage. The Python bridge passed the documented
20-run batch workflow on Siemens NX 2506 (`ugraf` 2506.4021) on 2026-08-21.
It remains opt-in while a non-blocking NX GUI event pump is validated; the
bundled Python Journal runner is intentionally batch-only.
| Profile | Exposure | Configuration |
| --- | --- | --- |
| Default | 16 original core tools | No experimental opt-in |
| Integration | 189 tools | `NX_MCP_ENABLE_EXPERIMENTAL=1` |
| Agent | 13 entry points; discover/invoke integration tools on demand | Integration opt-in plus `NX_MCP_SURFACE=agent` |

The default `tools/list` exposes only these 16 tools:
The legacy environment flag enables the integration profile; it is **not** a
per-tool test status. Use `nx_capabilities` for that distinction. Journal execution
requires a separate `NX_MCP_ENABLE_JOURNAL=1` and is disabled by default.

- Status: `nx_status`
- Files: `nx_create_part`, `nx_open_part`, `nx_save_part`, `nx_close_part`, `nx_export_step`
- Queries: `nx_list_sketches`, `nx_list_bodies`, `nx_list_features`
- Sketch: `nx_create_sketch`, `nx_sketch_line`, `nx_sketch_rectangle`, `nx_finish_sketch`
- Modeling: `nx_extrude`
- Recovery/view: `nx_undo`, `nx_fit_view`
## Start graphical NX

The 34 old tools outside the certified surface remain unverified and hidden by
default. `NX_MCP_ENABLE_EXPERIMENTAL=1` registers them through the bridge;
Journal tools additionally require `NX_MCP_ENABLE_JOURNAL=1`.

## Requirements

- Windows with a local native Siemens NX installation (validated on NX 2506)
- Python 3.10+
- The package installed in the sidecar interpreter
- An NX journal that can import `nx_mcp` (the bundled Journal examples load
the checkout's `src` directory automatically; the NX side has no `mcp` or
`pydantic` dependency)
- A dedicated test/project directory configured as `NX_MCP_WORKSPACE`

Install the sidecar and development dependencies:
Install Python 3.10+ and the package in the external sidecar environment:

```powershell
python -m pip install -e ".[dev]"
```

## Internal feasibility run

1. Set `NX_MCP_WORKSPACE` to a disposable directory.
2. For the target-build feasibility test only, set
`NX_MCP_ALLOW_UNVERIFIED_PYTHON_BRIDGE=1` in the NX environment.
3. Set `NX_MCP_BRIDGE_STOP_FILE` to a new path inside the workspace, then run
`examples/start_nx_bridge.py` with `run_journal.exe -nx`. The journal pumps
requests on NX's main thread and writes an authenticated session descriptor
to `%LOCALAPPDATA%\nx-mcp\bridge.json`.
4. Configure the MCP client to launch the sidecar:

```json
{
"mcpServers": {
"nx-mcp": {
"command": "python",
"args": ["-m", "nx_mcp.server"],
"env": {
"NX_MCP_WORKSPACE": "D:\\NX_MCP_WORKSPACE"
}
}
}
}
```

5. Run the real-NX acceptance loop from an external PowerShell 7 terminal:
1. Set `NX_MCP_WORKSPACE` in the NX environment to a dedicated CAD directory,
such as `D:\NX_MCP_WORKSPACE`.
2. In graphical NX, play `examples/start_nx_interactive.py`. The journal returns;
a retained Win32 timer dispatches queued calls on the NX UI thread.
3. Start the sidecar using the same workspace and the graphical descriptor:

```powershell
python -m nx_mcp.real_smoke --workspace D:\NX_MCP_WORKSPACE --iterations 20 --run-prefix acceptance
$env:NX_MCP_WORKSPACE = 'D:\NX_MCP_WORKSPACE'
$env:NX_MCP_BRIDGE_DESCRIPTOR = Join-Path $env:LOCALAPPDATA 'nx-mcp\interactive-bridge.json'
$env:NX_MCP_ENABLE_EXPERIMENTAL = '1'
$env:NX_MCP_ENABLE_JOURNAL = '0'
$env:NX_MCP_SURFACE = 'agent'
python -m nx_mcp.server
```

6. Create the configured stop file when finished; the journal stops the bridge
cleanly.
Configure the MCP client with that executable, arguments and environment. The NX
journal loads this checkout's `src` directory; the NX-side process does not need
`mcp` or `pydantic`. Do not attach batch and graphical hosts to the same workspace.
See [graphical lifecycle](INTERACTIVE-NX.md) and [setup details](docs/tools.md).

The optional `python -m nx_mcp.http_surface` entrypoint serves `/mcp` and
`/agent/mcp`. It requires separate network access controls; loopback bridge
authentication does not authenticate the HTTP endpoint. Stdio avoids network exposure.

## Workflows

Do not use production parts for this test. The batch bridge is not evidence of
interactive GUI responsiveness; use a non-blocking NX UI scheduler or the
agreed minimal C# NX-side bridge before enabling an interactive pilot.
| Area | Features and contracts |
| --- | --- |
| Files and artifacts | [Nested folders, open/save paths](docs/tools.md), uploads/downloads, checksums, assembly dependency packages and inline PNGs |
| Inspection | [Assembly bounds, distance and interference](docs/tools.md), topology selection, validity and measured properties |
| Sketches and solids | [Curve editing, expressions and previews](docs/tools.md); [dimensions, relations and native patterns](docs/tools.md) |
| Display | [Visibility, color, transparency, collision highlights and sections](docs/tools.md); camera and render controls |
| Assemblies and drawings | [Exploded views](docs/tools.md), trace lines, BOMs, balloons and [editable annotations](docs/tools.md) |
| Sheet metal | [Native operations, flat patterns and bend tables](docs/tools.md); per-operation schemas and tested option scope |
| Freeform and direct editing | [Splines, meshes, bridge/trim/sew/thicken, face edits and sampled analysis](docs/tools.md) |
| Manufacturing | [Native threads, PMI/GD&T and annotation refresh](docs/tools.md) |
| Agent use | [Discovery, compact results, pagination, snapshots and retention](docs/agent-surface.md) |

## Security model
## References, recovery and paths

- IPC binds only to `127.0.0.1` on a random port and requires a random 256-bit
session token.
- Every file argument is relative to `NX_MCP_WORKSPACE`; traversal, absolute
paths, and resolved links outside the workspace are rejected.
- Journal execution and all 34 legacy tools are disabled by default. Both the
sidecar and NX bridge must receive the opt-in environment flags.
- Object IDs are opaque and valid only for the current part session.
Use returned opaque IDs rather than display names. References include owner and
session context and can become stale after close, rollback or manual handoff.
Reacquire them through inspection tools when that happens.

## Local quality gates
Assign a unique `operation_id` to mutations. After uncertain delivery, query
`nx_operation_status` before retrying. Reusing the same ID and arguments can
return the committed receipt without applying the mutation twice. Checkpoints
are session-bound; NX save can expire native undo marks. Recovery does not undo
arbitrary external file writes or survive process restart as a model checkpoint.

The ordinary suite does not require NX. Install the Git hooks once, then use
the same checks as CI:
Paths refer to the NX host. Use explicit project subfolders; relative paths are
resolved from `NX_MCP_WORKSPACE`, and absolute paths must remain inside it.
Traversal, resolved links outside it and internal `.nx-mcp` files are rejected.
See [path semantics](docs/tools.md).

## Validation and limitations

Run the ordinary quality gates without NX:

```powershell
python -m pip install -e ".[dev]"
python -m pre_commit install --install-hooks
python -m pre_commit run --all-files
python -m pytest -q -p no:cacheprovider -m "not real_nx" --basetemp .pytest-tmp
```

The pre-commit hook runs file and style checks. The pre-push hook runs the
non-real-NX pytest suite and the sidecar mypy gate. Tests marked `legacy` cover
the opt-in 0.1 surface; tests marked `fake_nx` do not validate NXOpen itself.
Hosted CI runs the core suite across supported Python and OS combinations,
runs legacy mock-NX tests separately, and enforces at least 78% branch
coverage in its canonical Ubuntu/Python 3.12 coverage job.

Real NX acceptance is intentionally separate. Dispatch
`.github/workflows/real-nx.yml` from a dedicated self-hosted Windows runner
labelled `self-hosted`, `windows`, and `nx`, with `NX_RUN_JOURNAL` set to the
absolute path of `run_journal.exe`.

See [architecture](docs/architecture.md), [0.1 migration](docs/migration-0.2.md),
and [real NX validation](docs/real-nx-validation.md) for implementation and
release gates.

## Star History

<picture>
<source
media="(prefers-color-scheme: dark)"
srcset="https://raw.githubusercontent.com/DreamEnding/NX_MCP/star-history/assets/star-history-dark.svg"
/>
<img
alt="Star History Chart"
src="https://raw.githubusercontent.com/DreamEnding/NX_MCP/star-history/assets/star-history.svg"
/>
</picture>
Hosted CI checks supported OS/Python combinations, sidecar types and branch
coverage. Fake NX tests cover API boundaries; they do not establish geometry
correctness. Native runners under `examples/validate_*.py` use disposable fixtures
and document their environment variables. See [native validation](docs/real-nx-validation.md)
and [release acceptance](docs/real-nx-validation.md).

The [validation guide](docs/real-nx-validation.md) records 918 automated passes
and scoped dev20–dev22 live checks. Historical receipts identify their runtime commits and are
not current-version blanket certification. Current experimental gaps are tracked
in [capability closeout](docs/capability-matrix.md).

NXOpen mutations are serialized. Long native calls can block graphical NX;
cancellation is cooperative between batch children. Sampled surface, thickness
and draft analysis does not establish global extrema or standards compliance.
Individual sheet-metal options retain narrower evidence than their tool family.

## Upstream contribution

[Draft PR #5](https://github.com/DreamEnding/NX_MCP/pull/5) proposes this integration.
The [review outline](docs/tools.md) describes possible extraction
boundaries. The fork retains upstream history and its MIT license; private CAD
and machine provisioning are excluded.
4 changes: 4 additions & 0 deletions constraints-windows.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Versions verified with NX v2606; transitive pins live in requirements-windows.lock.
mcp==1.29.1
pydantic==2.13.5
pywin32==311
Loading