Metadata-Version: 2.5
Name: splat-lens-mcp
Version: 0.1.0
Summary: Local-first FastMCP server giving coding agents dual-channel spatial perception (exact 3D geometry + multi-view contact sheets + MuJoCo plausibility + inline WebGL Gaussian Splat viewer) over 3DGS .ply scenes.
Project-URL: Homepage, https://github.com/Nils19/splat-lens-mcp
Project-URL: Repository, https://github.com/Nils19/splat-lens-mcp
Project-URL: Issues, https://github.com/Nils19/splat-lens-mcp/issues
Author: Nils Collins
License: MIT
License-File: LICENSE
Keywords: 3d-gaussian-splatting,3dgs,fastmcp,mcp,mcp-apps,model-context-protocol,mujoco,point-cloud,spatial-ai,webgl
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: fastmcp>=3.0.0
Requires-Dist: matplotlib>=3.8.0
Requires-Dist: numpy>=1.26.0
Requires-Dist: pillow>=10.0.0
Requires-Dist: plyfile>=1.0.3
Requires-Dist: scipy>=1.11.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Provides-Extra: mujoco
Requires-Dist: mujoco>=3.1.0; extra == 'mujoco'
Description-Content-Type: text/markdown

<!-- mcp-name: io.github.Nils19/splat-lens-mcp -->

# Splat Lens MCP

[![PyPI](https://img.shields.io/pypi/v/splat-lens-mcp)](https://pypi.org/project/splat-lens-mcp/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)

A local-first, `uvx`-compatible [FastMCP](https://github.com/jlowin/fastmcp) server giving coding agents **dual-channel spatial perception** over 3D Gaussian Splatting (`.ply`) scenes, point clouds (`.npz`/`.npy`), and MuJoCo rigid-body states — plus an inline interactive **WebGL radial-Gaussian viewer** (`ui://splat-lens/viewer.html`) built on the [MCP Apps](https://github.com/modelcontextprotocol/ext-apps) extension.

<!-- Replace with your 12-second GIF or MP4 capture before launch -->
<!-- ![Splat Lens MCP Demo](docs/demo.gif) -->

## 10-Second Demo (No `.ply` Needed)

Try the bundled tabletop 3DGS scene (a seated cyan mug + a floating amber block) right from your terminal:

```bash
uvx splat-lens-mcp --demo
```

Or connect the MCP server and paste this prompt into Claude Code, Cursor, Claude Desktop, or Antigravity:

> *"Inspect `demo` with `inspect_scene_geometry` and `render_multiview_grid`, point out any floating object, open it in `open_interactive_viewer`, and verify the corrected placement in MuJoCo (`scene_xml_path="demo"`, `body_name="floating_block"`)."*

## Tools

| Tool | What it does |
| --- | --- |
| **`inspect_scene_geometry`** | Parses Gaussian centers, normals, opacities, scales, and RGB/SH DC colors (LRU-cached by `(path, mtime_ns, up_axis)`), estimates the floor plane and elevated support surfaces (tables/shelves), and computes per-cluster AABBs, plan-view OBBs, PCA tilts, support heights, and pairwise 3D clearances. |
| **`render_multiview_grid`** | Pure-CPU headless `2×3` (or `2×2`) multi-view PNG contact-sheet renderer (zero EGL/CUDA dependencies) with world axes, metric scale bars, Okabe-Ito GT/predicted 3D wireframes, 2-sigma uncertainty ellipsoids, and cluster highlighting. Returns both JSON metadata and the PNG directly in vision context. |
| **`check_mujoco_plausibility`** | Places a rigid body at a candidate 7-DoF pose `[x, y, z, qw, qx, qy, qz]` in MuJoCo, checks initial contact penetration (`mjData.contact`), rolls physics forward `sim_steps`, compares resting translation/yaw error against an observed `.ply`, and returns numeric metrics + a Before/After PNG contact sheet. |
| **`open_interactive_viewer`** | Streams packed Float32 positions, Uint8 RGB colors, Gaussian radii, and optional Int32 cluster IDs to an inline WebGL radial-Gaussian (`exp(-3.4 * r^2)`) MCP App (`ui://splat-lens/viewer.html`), with click-to-pick 3D coordinates sent back to the agent via `ui/update-model-context` / `ui/message`, plus a standalone HTML fallback file. |

All 4 tools accept `"demo"` as a shorthand for the bundled tabletop sample scene (`demo_tabletop.ply`, `demo_clusters.npy`, `demo_scene.xml`).

## MCP Client Setup

Core dependencies (`fastmcp`, `numpy`, `plyfile`, `Pillow`, `matplotlib`, `scipy`) install from pre-built wheels with zero C++/CUDA compilation. Add `[mujoco]` for physics rollouts.

### Antigravity / Cursor / Windsurf (`mcp_config.json` / `.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "splat-lens": {
      "command": "uvx",
      "args": ["splat-lens-mcp"]
    }
  }
}
```

With optional MuJoCo plausibility engine:

```json
{
  "mcpServers": {
    "splat-lens": {
      "command": "uvx",
      "args": ["--from", "splat-lens-mcp[mujoco]", "splat-lens-mcp"]
    }
  }
}
```

### Claude Code

```bash
claude mcp add splat-lens -- uvx splat-lens-mcp
# Or with MuJoCo:
claude mcp add splat-lens -- uvx --from "splat-lens-mcp[mujoco]" splat-lens-mcp
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "splat-lens": {
      "command": "uvx",
      "args": ["splat-lens-mcp"]
    }
  }
}
```

### Gemini CLI Extension

```bash
gemini extensions install https://github.com/Nils19/splat-lens-mcp
```

## Coordinate Convention

All tools operate in a **right-handed Z-up** frame by default (`up_axis="z"`). Pass `up_axis="y"` for Y-up meshes/splats or `up_axis="cv"` for OpenCV camera-frame `.ply` exports (`diag(1, -1, -1)` conversion to Z-up).

## Local Development

```bash
git clone https://github.com/Nils19/splat-lens-mcp.git
cd splat-lens-mcp
uv sync --extra dev --extra mujoco
uv run pytest -v
```

## License

[MIT](LICENSE)
