VisForge
# VisForge
Source: https://github.com/digitizables/VisForge
VisForge is an open-source Python toolkit that gives an MCP host a stable way to model in Plasticity. The host plans in skills and relations. VisForge executes those skills, reads the document when Plasticity is open, and checks the result with geometry and a viewport capture.
The Plasticity server in this repository is new. It does not import or wrap another MCP server.
## The problem
Agents that drive CAD through a large, low-level tool list tend to fail in the same ways:
- A bridge that calls private application internals works on one build and breaks on the next.
- The model is asked for absolute coordinates, so a small numeric mistake lands a feature in the wrong place.
- The model rarely sees the viewport, and it rarely checks whether the solid is closed, has the expected volume, or collides with another part.
Research on agentic 3D systems points at a different split of work. [LL3M](https://arxiv.org/abs/2508.08228) uses specialized agents and visual critique instead of one-shot generation. [Embodied CAD](https://arxiv.org/abs/2606.31252) keeps the model on a skill library and gives fragile bookkeeping to a resolver and the CAD solver. [aDSL](https://arxiv.org/abs/2608.17975) expresses layout with relational operators such as "on" and "align" so the same relation can be executed and checked. VisForge uses that Planner, Actor, Critic shape for Plasticity.
## Architecture
```text
MCP host
Planner -> skills, named parts, relations, checks
Actor -> VisForge tools
Critic -> mesh report, solid overlap, optional screenshot
VisForge Plasticity session
write channel JSON connector, port 9741
read channel Plasticity live link, port 8980
offline mirror analytic solids when neither channel is up
```
Two channels talk to Plasticity:
| Channel | Who speaks it | Role |
| --- | --- | --- |
| VisForge connector | This project | Semantic writes: primitives, booleans, `place_on` |
| Live link | VisForge client of Plasticity's public bridge | Read the open document: handshake, scene list, summaries |
The reference connector stores commands and updates an analytic scene. It does not attach to Plasticity's private API. An add-on that implements the same JSON methods can run the native command and return `executed_in_plasticity: true`. Until that add-on is installed, the session reports that the write stayed on the mirror or the connector scene.
The live-link client is ours. It implements the little-endian handshake and list frames used by Plasticity's bridge server (Preferences, Server, commonly `localhost:8980`). Tool results keep identity, counts, and bounding boxes. They do not dump raw vertex buffers into the model context.
Blender is a later, secondary bridge. This release does not ship one.
The design notes, skill levels, and paper references are in [docs/architecture.md](docs/architecture.md).
## Skills
Levels follow the Embodied CAD split. Level 4 is relational, in the aDSL sense.
| Level | Family | Examples | In this starter |
| --- | --- | --- | --- |
| 0 | Primitives | box, sphere, cylinder | Executed on the mirror and the connector |
| 1 | Curves | rectangle, circle | Catalog only |
| 2 | Booleans | union, subtract, intersect | Analytic when the volumes are known |
| 3 | Features | fillet, shell, hole pattern | Catalog only |
| 4 | Relations | `place_on`, align, offset | `place_on` is executed |
`list_skills` returns the full catalog, including skills that the critic will flag as deferred.
## Requirements
- Python 3.11 or newer
- [uv](https://docs.astral.sh/uv/) or pip
- Plasticity, only when you want a live document. The server and the tests run without it.
Optional extras:
- `vision` installs OpenCV for PNG and JPEG captures
- `geometry` installs trimesh
- `open3d` installs Open3D
Binary P5 PPM images and the built-in mesh samples work with no extras.
## Setup
From this directory:
```powershell
uv sync --extra dev --extra vision --extra geometry
```
Or, with pip:
```powershell
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e ".[dev,vision,geometry]"
```
Run the tests:
```powershell
uv run pytest
```
## Grok Build
Grok Build loads [`.grok/config.toml`](.grok/config.toml) when the session is inside this repository. That file starts the server with `uv run --offline visforge`. Run `uv sync` once before the first session so the environment exists.
On this machine the user config also registers `visforge`, so Grok can start it from any folder:
```toml
[mcp_servers.visforge]
command = 'C:\Users\Paul Beck\Desktop\VisForge\.venv\Scripts\visforge.exe'
enabled = true
startup_timeout_sec = 60
```
After either file changes, a new Grok session picks the server up. `grok mcp doctor visforge` checks that the process starts. Tools are named `visforge__<tool>`, for example `visforge__validate_mesh`.
## Run the server
The MCP server uses stdio. Logs go to stderr.
```powershell
uv run visforge
```
The same entry point is `python -m visforge` inside the virtual environment.
A host configuration is in [examples/mcp.json](examples/mcp.json). Point `--directory` at this checkout. An equivalent pip-based entry is:
```json
{
"mcpServers": {
"visforge": {
"command": "C:\\Users\\Paul Beck\\Desktop\\VisForge\\.venv\\Scripts\\visforge.exe"
}
}
}
```
## Connect to Plasticity
1. In Plasticity, enable the bridge server. The usual location is Preferences, Server, on `localhost` port `8980`.
2. Start the VisForge connector in a second terminal when you want the write channel:
```powershell
uv run visforge-connector
```
The connector listens on `127.0.0.1:9741`.
3. Start the MCP server and call `plasticity_connect`.
`plasticity_connect` tries the connector first and the live link second. If both are down, the backend is `offline-mirror` and modeling tools still return a scene. `plasticity_refresh` fills `remote` from the live link when that socket is open.
Environment variables:
| Variable | Default | Meaning |
| --- | --- | --- |
| `VISFORGE_PLASTICITY_BRIDGE` | `ws://127.0.0.1:8980` | Plasticity live-link URL |
| `VISFORGE_PLASTICITY_CONNECTOR` | `ws://127.0.0.1:9741` | VisForge connector URL |
| `VISFORGE_CONNECT_TIMEOUT` | `2.0` | Seconds to wait for each socket |
| `VISFORGE_DEPTH_WEIGHTS` | empty | Optional weight-file path recorded by the depth tool |
## Example
Ask the host to create a housing, or call the tools directly.
```python
import asyncio
from visforge.agents.loop import run_loop
from visforge.plasticity.session import PlasticitySession
session = PlasticitySession()
result = asyncio.run(run_loop("a box with a cylindrical hole", session=session))
print(result["passed"], result["backend"])
```
Tool calls a host can make:
```json
{"name": "plasticity_create_primitive", "arguments": {"kind": "box", "name": "body", "size_x": 40, "size_y": 24, "size_z": 12}}
{"name": "plasticity_create_primitive", "arguments": {"kind": "cylinder", "name": "cutter", "size_x": 4, "size_z": 12}}
{"name": "plasticity_boolean", "arguments": {"operation": "subtract", "target": "body", "tool": "cutter"}}
{"name": "check_scene", "arguments": {}}
{"name": "validate_mesh", "arguments": {"sample": "unit_cube"}}
{"name": "analyze_screenshot", "arguments": {"synthetic": "centered_block"}}
```
`analyze_screenshot` returns luminance, edge fraction, symmetry, an 8 by 8 grid, and a relative depth summary. `validate_mesh` returns manifold and watertight flags, volume, and proportions. Pass `path` to either vision tool when you have a viewport capture. PNG and JPEG use OpenCV when it is installed.
`estimate_depth` exposes the same relative-depth fields a Depth Anything V2 runner would fill. This starter uses a luminance proxy and sets `model_loaded` to false.
## Tools
| Tool | Purpose |
| --- | --- |
| `plasticity_connect` | Open the connector and the live link |
| `plasticity_status` | Backend, URLs, and the mirror |
| `plasticity_refresh` | Scene summaries from the live link |
| `plasticity_new_scene` | Clear the mirror and the connector |
| `plasticity_create_primitive` | Box, sphere, or cylinder, by volume center |
| `plasticity_center_box` | Manual Center Box, from the base center |
| `plasticity_corner_box` | Manual Corner Box |
| `plasticity_sphere` | Manual Sphere. The Radius field is the radius |
| `plasticity_cylinder` | Manual Cylinder, from the base circle |
| `plasticity_place_on` | Seat one named solid on another |
| `plasticity_boolean` | Union, Difference, or Intersect. Slice and Region are refused |
| `plasticity_move` | Move dialog XYZ offset |
| `plasticity_scale` | Scale dialog XYZ factors about the bounding box |
| `plasticity_duplicate` | Duplicate, then offset |
| `plasticity_mirror` | Mirror across a world plane |
| `plasticity_rectangular_array` | Spacing or extent array |
| `plasticity_hollow` | Closed hollow of a box |
| `plasticity_measure` | Center distance and AABB gap |
| `list_commands` | Plasticity manual command list |
| `describe_command` | One command, its shortcut, and recorded dialog fields |
| `list_skills` | Skill catalog used by the planner |
| `plan_model` | Deterministic baseline plan |
| `run_agent_loop` | One Planner, Actor, Critic pass |
| `check_scene` | Volume and overlap critique |
| `check_intersections` | Pairwise solid overlaps |
| `analyze_screenshot` | Edges, symmetry, coarse grid |
| `estimate_depth` | Relative monocular depth summary |
| `validate_mesh` | Manifold, volume, proportions |
| `reset_model` | New in-memory session, no network |
## Development
```powershell
uv run pytest
uv run visforge-connector --host 127.0.0.1 --port 9741
```
The package layout:
```text
src/visforge/
server.py MCP entry point
plasticity/ connector protocol, live-link codec, session, skills
perception/ screenshots and relative depth
geometry/ mesh validation and solid overlap
agents/ planner, actor, critic
tools/ semantic tool functions
tests/
docs/architecture.md
connectors are the `visforge-connector` console script
```
## License
MIT. Copyright (c) 2026 Paul Beck. See [LICENSE](LICENSE).
TDQS
Scored across 29 tools
Most tools target a distinct resource plus action, but there is real overlap between the generic plasticity_create_primitive and the role-specific plasticity_sphere / plasticity_cylinder / plasticity_center_box / plasticity_corner_box, and between plasticity_new_scene and reset_model (only the description disambiguates them). The cluster of checking tools (check_scene, check_intersections, plasticity_measure, validate_mesh) is separable but requires careful reading, and plan_model vs run_agent_loop border on the same workflow.
All names are snake_case, which is good, but two conventions are mixed: a plasticity_ prefix for live-link operations and bare names for local analytics, and within the prefixed group some names are verb-first (plasticity_create_primitive, plasticity_move) while others are noun-only (plasticity_sphere, plasticity_cylinder, plasticity_mirror). Readable, but not a single predictable verb_noun pattern.
29 tools exceeds the 25+ threshold and the surface spans four loosely related areas (Plasticity live link, manual/skill introspection, agent loop, and vision/mesh validation). Several tools look like thin wrappers (plasticity_sphere, plasticity_cylinder) that could fold into the generic primitive creator.
Creation, transforms, booleans, arrays, measurement, scene reset, and mesh/overlap validation are all present, which covers the core modeling loop. The notable gap is that there is no delete/remove-solid or undo tool, and no export/save path, so agents can build and inspect but cannot clean up or persist results.