Skip to main content
Glama
README.md
# MeshPeek

**Instant interactive 3D mesh viewer (`.glb` / `.gltf` / `.obj` / `.ply` / `.stl`) as an MCP App ([SEP-1865](https://github.com/modelcontextprotocol/ext-apps)) & standalone CLI.**

Built for 3D AI, Graphics, and Embodied AI developers running headless Linux GPU servers over **Antigravity (`agy`) Remote Control**, **Claude Desktop**, **Cursor**, **VS Code**, or **SSH** — stop writing throwaway headless Blender/PyRender scripts just to look at a `.glb`!

![MeshPeek Side-by-Side PBR + Draco Comparison](docs/screenshot.png)

---

## Why MeshPeek?

When working with a CLI coding agent on a headless remote GPU server, inspecting 3D outputs is painful: you can't open a desktop GUI, server-side EGL/Blender scripts constantly break, static PNG renders hide the back side, and `.glb` files are often **20–100 MB**.

**MeshPeek flips the model:**

- **Zero Server GPU / EGL / X11 / Node.js at Runtime**: The remote server runs pure Python (`mcp` + `Pillow`). All 60 FPS PBR rendering (`RoomEnvironment` studio IBL + ACES Filmic tone mapping) runs natively on **your local browser GPU** via Three.js.
- **Zero Port Forwarding over Remote Control**: Uses the official **MCP Apps (`SEP-1865`)** protocol (`@modelcontextprotocol/ext-apps`) to stream meshes straight through the existing MCP bridge into Antigravity's Side Pane (`aux_pane`) or inline card — with `visibility: ["app"]` tools consuming **0 LLM context tokens**.
- **~1-Second Open on Multi-10MB `.glb` Files**:
  - **L1 Fast Preview (default)**: On-the-fly cached glTF 2.0 binary texture transcoder shrinks embedded 2K/4K PNGs into 1024px JPEG/PNG (preserving 4:4:4 `q=92` normal maps and keeping geometry, UVs, skinning, animations, and Draco/Meshopt buffers **bit-for-bit untouched**) + GZIP + 4-way parallel chunked streaming. Real benchmark: `AntiqueCamera.glb` shrinks **17.5 MB → 2.08 MB (-88.2%)**.
  - **L2 1-Click Lossless Original**: Click `Load Original` anytime to stream the untouched raw `.glb` in-place **without resetting your camera angle**.
- **CSP-Safe In-Thread Draco & Meshopt**: Bundles a pure-JS in-thread Draco decoder + `MeshoptDecoder` inside a single self-contained `1.5 MB` HTML file — works under strict `default-src 'none'` sandboxes (no external CDNs, no blocked Web Workers, no `wasm-unsafe-eval`).
- **Built for Daily 3D Iteration**:
  - **Camera-Preserving Live Hot-Reload**: Automatically detects when your script or agent overwrites `output.glb` and refreshes in-place while locking your camera orbit.
  - **Side-by-Side Synced Compare**: Inspect two meshes (`v1.glb` vs `v2.glb`) with bidirectionally locked orbit cameras.
  - **Research Shading Modes**: `PBR` · `Clay` · `Normal` · `Wireframe` · `UV Checker` + embedded glTF animation scrubber + remote folder browser.
  - **Send View to Agent**: Orbit to a broken seam or artifact and click **Send View** — your local browser GPU captures a crisp PBR PNG, saves it on the server, and attaches it to your next agent message via `updateModelContext`.

---

## Quickstart

### 1. Install (Remote Linux GPU Server or Local Machine)

Because the compiled single-file Three.js frontend (`src/meshpeek/static/app.html`) ships pre-bundled inside the Python package, **no Node.js is required at runtime**.

```bash
git clone https://github.com/KevinXu11155/meshpeek.git
cd meshpeek
pip install .
```

### 2. Use as an Antigravity Plugin (Recommended for `agy` Remote Control)

Copy the bundled plugin manifest into Antigravity's plugins directory — it is discovered automatically with zero restart:

```bash
mkdir -p ~/.gemini/config/plugins/meshpeek
cp -R plugin/. ~/.gemini/config/plugins/meshpeek/
chmod +x ~/.gemini/config/plugins/meshpeek/bin/meshpeek-mcp
```

Then ask `agy` directly:
- *"Open `outputs/model.glb` in MeshPeek"*
- *"Compare `v1.glb` and `v2.glb` side by side in MeshPeek"*
- *"Open MeshPeek to browse `./outputs`"*

Or launch **MeshPeek 3D** anytime from the side pane `+` menu or left sidebar.

### 3. Use with Claude Desktop / Cursor / VS Code / Any MCP Host

Add to your MCP config:

```json
{
  "mcpServers": {
    "meshpeek": {
      "command": "meshpeek",
      "args": ["mcp", "--root", "/path/to/your/workspace"]
    }
  }
}
```

### 4. Standalone CLI Viewer (Plain SSH Port Forwarding)

No MCP host? Serve the exact same Three.js UI over HTTP:

```bash
# View a single file
meshpeek serve outputs/car.glb --port 8765

# Compare two meshes side by side
meshpeek serve v1.glb --compare v2.glb --port 8765

# Browse an entire remote folder
meshpeek serve ./outputs/ --port 8765

# Inspect GLB metadata & benchmark preview compression
meshpeek info outputs/car.glb --test-preview /tmp/preview.glb
```

---

## Architecture

```text
Remote Headless Linux Server                     Local Browser (Remote Control / IDE)
┌──────────────────────────────────┐            ┌────────────────────────────────────┐
│  meshpeek mcp (Pure Python)      │            │  ui://meshpeek/app.html (1.5 MB)   │
│  ├─ peek_mesh / open_meshpeek    │◄─ MCP ────►│  ├─ Three.js PBR + RoomEnvironment │
│  ├─ glb_opt.py (Texture Preview) │  JSON-RPC  │  ├─ In-Thread Draco & Meshopt      │
│  ├─ store.py (GZIP 384KB Chunks) │  (4-way    │  ├─ Browser DecompressionStream    │
│  └─ Disk Cache + Snapshots       │  parallel) │  └─ Send View -> updateModelContext│
└──────────────────────────────────┘            └────────────────────────────────────┘
```

### MCP Tools Exposed

| Tool | Visibility | Description |
| :--- | :--- | :--- |
| `peek_mesh` | Model + App | Opens/updates the interactive 3D side pane for one mesh (or two side-by-side). Returns compact `< 3 KB` metadata only. |
| `open_meshpeek` | Model + App | Opens the remote 3D directory browser (`aux_pane` + `global` sidebar entrypoint). |
| `app_list_meshes` | App-only | Scans remote directories for `.glb`/`.gltf`/`.obj`/`.ply`/`.stl` (0 LLM tokens). |
| `app_prepare_mesh` | App-only | Generates/fetches cached preview or original gzipped blob metadata. |
| `app_get_chunk` | App-only | Streams 384 KiB gzip chunks in 4-way parallel bursts. |
| `app_stat_file` | App-only | Lightweight `mtime` check for camera-preserving live hot-reload. |
| `app_save_snapshot` | App-only | Persists browser-rendered PBR PNG snapshots for agent inspection. |

---

## Development

```bash
# Backend tests
pip install -e ".[dev]"
pytest -v

# Rebuild single-file Three.js MCP App frontend -> src/meshpeek/static/app.html
cd web
npm install
npm run build
```

## License

[MIT](LICENSE)