Documentation & page contents

Model Context Protocol

MCP

Give an agent access to the same garment operations as the Python SDK. The current local server wraps Client over stdio. Hosted HTTP access with authentication is planned.

No authentication. Local use only. python -m beforewear.mcp or the beforewear-mcp console script.

Run locally

First request SDK access and install the supplied checkout following the installation steps. Configure your MCP client to launch the Python interpreter from that environment:

{
  "mcpServers": {
    "beforewear": {
      "command": "/absolute/path/to/sdk/.venv/bin/python",
      "args": ["-m", "beforewear.mcp"]
    }
  }
}

Replace the interpreter path with your installed environment. This is a local stdio configuration, not a hosted endpoint.

python -m beforewear.mcp

Stdio JSON-RPC. Protocol version 2024-11-05. Methods: initialize, tools/list, tools/call, ping.

Wire format

Use your catalog’s product ID or SKU in place of aop-hoodie.

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "garment.drape",
    "arguments": {
      "product_id": "aop-hoodie",
      "body_id": "body_male_m_native_straight",
      "material_id": "fleece_250gsm",
      "device": "gpu"
    }
  }
}

Success returns structuredContent plus a text JSON dump. garment.drape / compile / arrange accept either a project_id or Product/Pattern + Construction + Body + Material ids (a project is created for you).

Tool catalog

Thirty-seven dotted names. One JSON args sample per tool lives in examples/samples/tools/.

Product

product.list

Library blanks.

product.get

Fetch by SKU or id. Pattern and Construction come with the blank.

Pattern

pattern.import

2D pieces. source is provenance (for example manufacturer files).

pattern.draft

From a sentence. Preflight still applies.

pattern.annotate_sketch

From a drawing.

pattern.from_reference_images

Visual-match inlet from product photos. Not a factory nest.

pattern.get

Fetch a Pattern.

pattern.revise

Measured change to the cut. New Pattern id.

pattern.preflight

2D gate before drape.

pattern.grade

Reference Pattern + size chart → one Pattern per size. No grade knobs.

Construction

construction.propose

Sewing from a Pattern and optional evidence photos. Includes placements.

construction.apply_recipe

folded_band, patch, casing, and family recipes.

construction.preflight

Sewing gate before drape.

construction.get

Fetch Construction.

construction.revise

Change sewing. New Construction id.

Body and material

body.select

sex, size, pose from the library. Custom pose is the same MHR avatar, posed. SMPL / SMPL-X land through NVIDIA SOMA. Not a mesh. See avatars.

material.list / material.get

Library cloth.

material.build

A swatch is a visual reference. Physical properties need a measured profile or reviewed assumptions.

Garment jobs

garment.compile

Inspectable stage.

garment.arrange

Where the factory often refuses. Read the gate; do not drape past it.

garment.drape

Blank Run. device: cpu | gpu. No artwork argument.

garment.finish

Child Run, still a blank.

garment.render

view_set (catalog, turntable, …), body (display, ghost, garment_only). Inspectable catalog views.

mockup.render

Presentation stills. kind: on_avatar | ghost | flat | on_model. Review delivered print fidelity. On-model: generated or photo + photo_uri. No generator knobs. See avatars.

garment.export

Typically glb.

garment.status / garment.get

Poll and fetch a Run.

garment.measure

Points of measure vs the size chart.

uv.audit

Printable placements still have honest UVs after drape.

Stamps

colorway.apply

Dye a finished blank. Child Run.

graphic.apply

artwork map of placement name → uri on an existing garment. Design is not authored here. Child Run.

Manufacturing

techpack.export

Custom-garment handoff from Pattern + Construction. format: pdf | json | dxf. Optional run_id for measured POM. No layout knobs.

Cloth in space

space.simulate

Recorded motion from a draped or presented Run. kind: flatlay | hanger | fold. No solver knobs.

space.video

Encode a recorded Motion to mp4. Does not invent in-between cloth.

Gate on the wire

A refused job is still a JSON-RPC result, not a protocol error. isError: true and structuredContent hold the gate payload.

{
  "ok": false,
  "gate": "cloth_self_intersections",
  "phase": "arrange",
  "counts": {},
  "witnesses": [{"panels": ["right_sleeve", "right_sleeve"], "kind": "self"}],
  "hint": "arrangement refused; revise pattern or construction"
}

Then call pattern.revise / construction.revise. That loop is the harness. Walked example: revise_after_gate.