Stgen DXF Editor
VS Code extension for viewing and editing DXF files with built-in AI (MCP) integration.

Features
- DXF Viewer — Babylon.js WebGL rendering, 2D/3D view, layer visibility control
- 43 CAD Commands — AutoCAD-compatible command-line interface (LINE, CIRCLE, MOVE, TRIM, DIMENSION, etc.)
- 15 Entity Types — LINE, CIRCLE, ARC, POLYLINE, TEXT, MTEXT, DIMENSION, LEADER, ELLIPSE, SPLINE, INSERT, HATCH, SOLID, POINT, ATTRIB
- 10 Object Snap Modes — Endpoint, Midpoint, Center, Quadrant, Intersection, Perpendicular, Nearest, Tangent, Extension, Node
- Undo/Redo — Full undo history with DXF save support
- Export — PNG, SVG file export
- 129 MCP Tools — AI-driven CAD operations via Model Context Protocol
Getting Started
- Install from VS Code Marketplace.
- Open any
.dxf file — the editor activates automatically.
Navigation
| Action |
Input |
| Pan |
Middle-click drag / Right-click drag / Arrow keys |
| Zoom |
Scroll wheel / + - |
| Fit view |
F |
| Select |
Click / Ctrl+Click / Box drag |
Commands
Type command names in the input box at the bottom (e.g. LINE, MOVE, TRIM).
| Category |
Commands |
| Creation |
LINE CIRCLE ARC POLYLINE RECTANGLE POLYGON ELLIPSE SPLINE TEXT DIMENSION LEADER POINT BLOCK |
| Modification |
MOVE COPY ROTATE SCALE MIRROR ERASE OFFSET TRIM EXTEND FILLET CHAMFER BREAK JOIN LENGTHEN PEDIT DIVIDE ALIGN MATCHPROP ORDER OVERKILL GAP |
| Query |
DIST AREA LIST LAYER ZOOM SELECTALL SELLAYER REVERT |
Keyboard Shortcuts
| Key |
Action |
Escape |
Cancel / Deselect |
Delete |
Delete selected |
Ctrl+Z / Ctrl+Y |
Undo / Redo |
Ctrl+S |
Save |
Ctrl+A |
Select all |
F |
Fit view |
MCP Integration (AI)
Built-in MCP server with 129 tools for AI-driven CAD operations. Works with Claude Code, Cursor, Windsurf, and any MCP-compatible client.
Setup
Automatic (Recommended)
- Open a DXF file in VS Code.
Ctrl+Shift+P > Stgen: Setup MCP Configuration
.mcp.json is created in your workspace root automatically.
- Restart your AI client.
The extension also auto-updates .mcp.json on every activation if the server path changes (e.g., after extension update).
Manual — Claude Code / Cursor / Windsurf
Create .mcp.json in your project root:
{
"mcpServers": {
"stgen-dxf-viewer": {
"command": "node",
"args": ["<extension-path>/media/mcp-server.js"],
"env": {
"STGEN_MCP_PORT": "52789"
}
}
}
}
<extension-path> is the actual extension install path. To get it:
- Run
Ctrl+Shift+P > Stgen: Copy MCP Configuration to Clipboard and paste — the path is already filled in.
Typical paths:
| OS | Path |
|----|------|
| Windows | C:\Users\<user>\.vscode\extensions\jeil-structuralengineering-consultants.stgen-<version>\media\mcp-server.js |
| macOS | ~/.vscode/extensions/jeil-structuralengineering-consultants.stgen-<version>/media/mcp-server.js |
| Linux | ~/.vscode/extensions/jeil-structuralengineering-consultants.stgen-<version>/media/mcp-server.js |
Manual — OpenAI Codex CLI
The extension auto-creates ~/.codex/config.toml on activation. To configure manually:
[mcp_servers.stgen-dxf-viewer]
command = "node"
args = ["<extension-path>/media/mcp-server.js"]
[mcp_servers.stgen-dxf-viewer.env]
STGEN_MCP_PORT = "52789"
Manual — Google Gemini CLI (Antigravity)
The extension auto-creates ~/.gemini/antigravity/mcp_config.json on activation. To configure manually:
{
"mcpServers": {
"stgen-dxf-viewer": {
"command": "node",
"args": ["<extension-path>/media/mcp-server.js"],
"env": {
"STGEN_MCP_PORT": "52789"
}
}
}
}
Port Configuration
Default port is 52789. To change:
- VS Code setting:
stgen.mcpServerPort
- Or environment variable in MCP config:
"STGEN_MCP_PORT": "<port>"
Both the VS Code setting and the MCP config env must match.
Verifying Connection
After restarting your AI client, ask: "Use the get_dxf_status tool to check connection."
A successful response confirms the MCP server is connected.
Architecture
AI Client ──stdio──> MCP Server (media/mcp-server.js) ──HTTP:52789──> VS Code Extension ──postMessage──> Webview
| Category |
Count |
Examples |
| Entity Creation |
17 |
create_line, create_circle, create_dimension, create_block |
| Entity Modification |
15 |
move_entities, rotate_entities, trim_extend, array_copy |
| Entity Edit |
11 |
change_entity_layer, join_entities, edit_text, explode_block |
| Query & Analysis |
23 |
get_dxf_summary, find_entities, measure_distance, calculate_area |
| Layer Management |
7 |
create_layer, set_layer_visibility, merge_layers |
| Block Management |
4 |
list_blocks, count_blocks, generate_bom |
| View & Export |
8 |
capture_dxf_view, zoom_extents, save_dxf |
| Region Operations |
8 |
extract_region, clone_region, erase_by_bounds |
| Dimension Tools |
3 |
extract_dimensions, update_dimension_scale |
| Background Image |
2 |
get_background_images, insert_background_image |
| Verification |
2 |
verify_alignment, get_3d_info |
| AI Workflow |
29 |
Transaction, Context, Validation, Repair, Anchor, Workflow Guide |
AI Workflow
The server enforces a structured workflow via automatic hints:
get_dxf_summary → write_drawing_spec → begin_transaction → [create/modify] → end_transaction → run_drawing_checks → capture_dxf_view
Configuration
| Setting |
Default |
Description |
stgen.backgroundColor |
#1e1e1e |
Editor background color |
stgen.antialias |
true |
WebGL antialiasing |
stgen.defaultAnnotationColor |
#ff0000 |
Annotation color |
stgen.autoExportForClaude |
true |
Auto-export entity data for AI |
stgen.mcpServerPort |
52789 |
MCP bridge HTTP port |
VS Code Commands
Ctrl+Shift+P > Stgen:
| Command |
Description |
| Setup MCP Configuration |
Create .mcp.json for AI clients |
| Copy MCP Configuration to Clipboard |
Manual MCP setup |
| Capture DXF View as Image |
Export view as PNG |
| Export as PNG Image / SVG File |
File export |
| Fit View to Content |
Zoom to fit |
| Extract DXF Entity Data |
Entity data to clipboard |
Requirements
- VS Code ^1.60.0
- Node.js 22.x (MCP server runtime)
License
MIT — Jeil Structural Engineering Consultants
| |