Content
# Tool List
A SolidWorks MCP automatic modeling repository, written from scratch, for connecting Codex / other MCP clients to SolidWorks on local Windows and automatically creating parts, industry templates, exporting files, and performing basic reviews through Python COM / SolidWorks API.
> Note: This repository's code is independently generated and does not replicate any third-party repository code. You can use it as your own GitHub repository's first version and continue to extend.
## Target Architecture
```text
Codex / MCP Client
↓ stdio MCP
solidworks-mcp-pro
↓ Python COM / pywin32
SldWorks.Application
↓
SolidWorks Part / Assembly / Drawing / STEP / PDF / PNG
```
## Current First Version Capabilities
- MCP Server: Exposes SolidWorks tools through `stdio`.
- SolidWorks Session Management: Connect, start, active documents, save, export.
- Secure Output Directory: Defaults to only write to `SW_MCP_OUTPUT_ROOT`.
- Basic Parts: Rectangular prism, cylinder.
- Industry Templates: Flange, simplified tube plate, simplified vertical heat exchanger concept piece.
- JSON Spec Driven: Generate models with structured parameters, reducing natural language ambiguity.
- Basic Review: Active document title, path, type, mass properties, export preview.
- Codex Configuration Example and PowerShell Registration Script.
- Unit Test Skeleton and Windows Integration Test Mark.
## System Requirements
- Windows 10 / 11
- SolidWorks installed
- Python 3.10+
- Codex CLI or other MCP-enabled clients
## Installation
```powershell
cd C:\Projects
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e C:\Projects\solidworks-mcp-pro
```
Alternatively, execute directly in the repository root directory:
```powershell
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e .
```
## Configure Environment Variables
Minimum recommended setting for output directory:
```powershell
setx SW_MCP_OUTPUT_ROOT "C:\SW-MCP-Output"
```
If SolidWorks default templates fail to load, manually set template paths:
```powershell
setx SW_MCP_PART_TEMPLATE "C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2025\templates\Part.prtdot"
setx SW_MCP_ASSEMBLY_TEMPLATE "C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2025\templates\Assembly.asmdot"
setx SW_MCP_DRAWING_TEMPLATE "C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2025\templates\Drawing.drwdot"
```
## Directly Start MCP Server
```powershell
.\.venv\Scripts\Activate.ps1
solidworks-mcp-pro
```
Normally, it will not output regular logs because MCP uses stdio communication.
## Register to Codex
Method 1: Command Registration
```powershell
codex mcp add solidworks-pro -- C:\Projects\solidworks-mcp-pro\.venv\Scripts\python.exe -m sw_mcp_pro.mcp_server.server
```
Method 2: Manually add to Codex configuration, refer to `codex/config.example.toml`.
## Test in Codex
```text
Invoke solidworks-pro's sw_health to check if SolidWorks is connectable.
```
```text
Invoke solidworks-pro to create a flange: outer diameter 200mm, thickness 20mm, center hole 80mm, 6 bolt holes with diameter 12mm, PCD 150mm, save as flange_demo.SLDPRT.
```
## Recommended Workflow
First, use structured spec:
```json
{
"type": "flange",
"name": "DN80_flange",
"params": {
"outer_diameter_mm": 200,
"thickness_mm": 20,
"center_hole_diameter_mm": 80,
"bolt_count": 6,
"bolt_hole_diameter_mm": 12,
"bolt_circle_diameter_mm": 150,
"material": "Plain Carbon Steel"
},
"save_as": "DN80_flange.SLDPRT"
}
```
Then, let Codex invoke:
```text
Invoke sw_create_from_spec_json to create a model using this JSON.
```
## Directory Structure
```text
solidworks-mcp-pro/
├── sw_mcp_pro/
│ ├── mcp_server/ # MCP tool layer
│ ├── sw_api/ # SolidWorks COM wrapper layer
│ ├── templates/ # Parametric industry templates
│ ├── specs/ # JSON spec parsing and validation
│ └── utils/ # Logging, secure paths, JSON tools
├── examples/ # Example specs
├── installers/ # Codex registration scripts
├── codex/ # Codex configuration example
├── docs/ # Documentation
└── tests/ # Tests
```
## Security Boundary
This project does not provide any Python / VBA execution tools by default. All file writes are restricted to `SW_MCP_OUTPUT_ROOT` by default to prevent AI from saving files to uncontrolled directories. If you need to write to arbitrary paths, set:
```powershell
setx SW_MCP_ALLOW_OUTSIDE_ROOT "1"
```
Not recommended for long-term use.
## Development Roadmap
- More complete sketch constraints and dimension system
- Hole wizard / threaded holes / configuration table
- Complex assembly mate templates
- Automatic annotation / BOM / title block for engineering drawings
- Heat exchanger, tube plate, U-tube, support, nozzle, and head templates
- Model verification against spec
- Multi-workstation task queue