Using ClothCount in chat

Technical reference

Build with ClothCount calculations

The MCP source exposes the same deterministic calculation functions as the website, with explicit measurements, fabric roles and purchase rounding.

Catalog
13 tools
Geometry
11 calculator modes
Visual resources
2 resources · 12 visual tools

The tool catalog

Eleven tools cover the website’s calculator modes. Known-length conversion and rectangle reference export bring the total to thirteen.

calculate_rectangle_yardage

Repeated rectangular cut pieces

Mode
yardage
Result surface
ui://clothcount/rectangle.html

export_rectangle_reference_sheet

Rectangle reference text and standalone HTML

Mode
export
Result surface
ui://clothcount/rectangle.html

calculate_quilt_backing

Quilt backing plan

Mode
backing
Result surface
ui://clothcount/plan.html

calculate_quilt_binding

Quilt binding plan

Mode
binding
Result surface
ui://clothcount/plan.html

calculate_quilt_borders

Quilt border plan

Mode
borders
Result surface
ui://clothcount/plan.html

calculate_half_square_triangles

Half-square triangle plan

Mode
hst
Result surface
ui://clothcount/plan.html

calculate_batting_fit

Batting size and fit

Mode
batting
Result surface
ui://clothcount/plan.html

calculate_precut_yield

Precut uniform-grid yield

Mode
precut
Result surface
ui://clothcount/plan.html

calculate_quilt_block_grid

Block grid to quilt size

Mode
grid
Result surface
ui://clothcount/plan.html

calculate_quilt_target_grids

Target to whole-block grids

Mode
target
Result surface
ui://clothcount/plan.html

calculate_flying_geese

Four-at-a-time flying geese

Mode
geese
Result surface
ui://clothcount/plan.html

calculate_hourglass

Two-color hourglass plan

Mode
hourglass
Result surface
ui://clothcount/plan.html

convert_known_length

Convert a known length

Mode
conversion
Result surface
Text and structured data

Two visual resources

Rectangle editor and reference

ui://clothcount/rectangle.html

Used by rectangle yardage calculation and rectangle reference export.

Quilt and fabric plan viewer

ui://clothcount/plan.html

Used by the ten other geometry tools, with the website’s original construction diagrams.

Visual tools advertise _meta.ui.resourceUri. Their responses also include text and strict structuredContent, so the numerical plan and its assumptions can be consumed independently of the visual surface. Known-length conversion uses text and structured data.

Run from a source checkout

Use Node 24 and the project lockfile. Run these commands from the ClothCount source directory:

npm ci
npm run build:mcp-ui
node --experimental-strip-types mcp/stdio.ts

The UI build produces self-contained public/mcp-ui/rectangle.html and public/mcp-ui/plan.html resources. The stdio entrypoint reads those files when a client requests a resource.

Local client process settings

For an MCP client that launches local processes, use its command/arguments configuration and replace the example paths with your source checkout’s absolute path:

{
  "command": "node",
  "args": [
    "--experimental-strip-types",
    "/absolute/path/to/clothcount/mcp/stdio.ts"
  ],
  "cwd": "/absolute/path/to/clothcount"
}

Keep stdout for MCP protocol traffic and diagnostics on stderr. The source server identifies itself as clothcount-preview, version 0.3.0.

Protocol and transports

Initialization negotiation

The installed SDK supports 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05, 2024-10-07. During initialize, the server accepts a requested version from that list; otherwise it responds with the SDK’s latest supported version, 2025-11-25. The client completes negotiation against the returned version.

Stdio

mcp/stdio.ts connects the full catalog to the SDK’s StdioServerTransport. The process communicates over standard input and output.

Prepared Streamable HTTP adapter

mcp/http.ts provides a local POST /mcp implementation bound to 127.0.0.1:4330 when started. mcp/fetch.ts provides the Fetch adapter for an integration’s configured exact HTTPS origins. mcp/cloudflare-entry.ts embeds the two UI artifacts for that runtime.

Both HTTP paths use stateless JSON responses, with a new server/transport per request, no session IDs and no GET/SSE stream. Requests use uncompressed application/json; the adapters bound requests to 64 KiB and eight concurrent operations. The Fetch adapter accepts a single MCP message per request and checks the configured authority and Origin.

The commands and paths here describe the source interfaces and local process setup.

Inputs and result contracts

Geometry tool inputs use numeric physical measurements with an explicit unit of in or cm. Convert typed fractions to numbers before a tool call. Counts remain whole counts; purchase increments remain yards: 0.125, 0.25, 0.5 or 1. Supply the settings relevant to the selected mode, including allowances, direction and rotation permission.

Example tool-call parameters

{
  "name": "calculate_rectangle_yardage",
  "arguments": {
    "unit": "in",
    "pieceWidth": 8.5,
    "pieceHeight": 10.5,
    "count": 20,
    "usable": 42,
    "extra": 0,
    "rotation": false,
    "rounding": 0.125
  }
}

This input requires 20 cut pieces of 8.5 × 10.5 in from 42 in usable width. With rotation off and no extra bolt length, the plan has four pieces across and five rows: 52.5 in required, rounded to 1.5 yd / 54 in to buy.

Rectangle row calculation

  1. Convert physical centimeter inputs to inches by dividing by 2.54.
  2. For each permitted uniform orientation, take whole pieces across the usable width, then round the row count up.
  3. Multiply rows by cut length and add the explicitly chosen extra bolt length.
  4. Round the resulting yard requirement up to the chosen shop increment. Keep that purchase amount separate from the cut sizes.

The shared engine uses its existing scale-aware boundary tolerance. Permitted rotation compares two uniform orientations; it does not mix orientations or repack offcuts. Cut dimensions already contain the user’s seam allowances.

Results and errors

Geometry contracts preserve original inputs, normalized inches, cuts, assumptions, supported alternatives, separate fabric purchases and any qualified next-stage size. New geometry envelopes use schemaVersion: "1.0"; the original rectangle calculation and export keep their rectangle-specific 1.0 schemas. The known-length converter accepts decimal or simple/mixed-fraction raw text for in, ft, yd, mm, cm and m, and keeps optional buy-up separate.

Unknown or inactive fields are rejected. Handle both SDK input-schema rejection and a tool response with isError: true; neither provides a successful plan to reuse. Successful rectangle export recomputes its validated inputs and returns plain text plus escaped standalone HTML reference content.

Tools advertise read-only, non-destructive, idempotent, closed-world behavior. They calculate and return content; they do not buy fabric, save files or send messages.

Inspect the interfaces

Explore example result surfaces in the illustrative developer preview. For project preparation and copyable prompts, return to Use ClothCount with AI.