# 3 Real Bugs We Caught When an AI Agent Compiled a 2,849 sq ft House Plan Through Our MCP Server

> Source: <https://dev.to/plumbdraft/3-real-bugs-we-caught-when-an-ai-agent-compiled-a-2849-sq-ft-house-plan-through-our-mcp-server-5emc>
> Published: 2026-11-30 14:39:49+00:00

**Recommendation:** Put a single alias-coercion normalizer in front of every MCP tool that consumes LLM JSON, and compare converted dimensions with a tolerance rather than strict inequality.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

Over the past 48 hours our hosted Streamable HTTP MCP server (`https://www.plumbdraft.com/mcp`) crossed 2,500 tool calls. Most early traffic to a new MCP endpoint is registry health checks and small 1-room test payloads. Then a real residential floor plan hit the server: 2,849 sq ft, 16 rooms, 26 doors, dozens of walls, and full kitchen and bath fixtures.

The compilation succeeded, the agent returned our live 2D/3D preview URL to the user, and the user clicked the link four times.

And our preview page returned a `500 Internal Error`.

Debugging that single real-world payload exposed three subtle edge cases that unit tests against clean internal fixtures never caught. If you are building an MCP server that turns LLM-generated JSON into deterministic files (CAD, PDF, SVG, diagrams, or spreadsheets), these three patterns will probably bite you too.

Our internal TypeScript model expects furniture fixtures with explicit fields:

```
interface FurnitureItem {
  id: string;
  kind: string;        // e.g. "kitchen_island", "bed_queen"
  category: string;
  label: string;
  x: number;
  y: number;
  widthIn: number;
  depthIn: number;
  rotationDeg: number;
}
```

Our MCP `tools/list` schema originally described the `plan` argument as a generic object (`"FloorPlan JSON object containing walls, openings, rooms, furniture."`). Without explicit field names in the parameter description, the calling model did something totally reasonable:

`type: "island"`, `name: "Kitchen Island"`, and `rotation: 90` instead of `kind`, `label`, and `rotationDeg`.`{ type: "door", style: "overhead" }` and `{ type: "opening" }` instead of `door_double` and `cased_opening`.` notes: ["Verify structural headers", "Check local setback"]` as plain strings without `x` or `y` blueprint leader coordinates.
The planar room-detection engine did not care about `furniture.kind`, so `compile_floorplan_geometry` succeeded cleanly and stored the plan in D1. The crash happened downstream when the user opened the rendered SVG preview page, where our architectural symbol renderer ran:

```
if (item.kind.startsWith('bed_')) { ... }
```

`item.kind` was `undefined`. Boom: unhandled `TypeError` and a `500` page.

`tools/list`:` 1 ft = 12 in`) directly inside the tool's `inputSchema` description so agents emit canonical JSON on the first call.`compileFloorPlan()`, we now coerce incoming LLM aliases once before geometry, SVG, DXF, PDF, or Three.js ever see the object:

``` js
const rawKind =
  typeof raw.kind === 'string' && raw.kind.trim()
    ? raw.kind.trim()
    : typeof raw.type === 'string' && raw.type.trim()
      ? raw.type.trim()
      : 'custom';

const label =
  typeof raw.label === 'string' && raw.label.trim()
    ? raw.label.trim()
    : typeof raw.name === 'string' && raw.name.trim()
      ? raw.name.trim()
      : rawKind;

const rotationDeg =
  typeof raw.rotationDeg === 'number' && Number.isFinite(raw.rotationDeg)
    ? raw.rotationDeg
    : typeof raw.rotation === 'number' && Number.isFinite(raw.rotation)
      ? raw.rotation
      : 0;
```

Unpositioned string notes without finite `x` and `y` coordinates are filtered out of spatial leader callouts instead of producing `NaN` in SVG transforms or DXF `TEXT` entities. Every MCP tool (`compile`, `validate`, `takeoff`, `dxf`, `pdf`) now runs through this single normalizer.

`27.996"` vs `28"`)
In US residential architecture, `2'-4"` (`28"`) and `2'-0"` (`24"`) are completely standard interior doors for closets, pantries, laundry rooms, and secondary baths.

The agent built the house plan in decimal feet and converted to inches:

```
2.333 ft * 12 in/ft = 27.996 in
```

Our clearance engine had a strict interior door check:

```
if (op.widthIn < 28) {
  addIssue({
    severity: 'warning',
    code: 'DOOR_WIDTH',
    detail: `Interior door ${op.tag} is ${op.widthIn}" wide...`
  });
}
```

Because `27.996 < 28` by four thousandths of an inch, eight perfectly normal `2'-4"` doors each triggered a `-14` point warning. Worse, the error message printed `"27.996\""` verbatim, and the overall spatial audit score collapsed to `0/100` even though all 22 hinged door swings were completely unobstructed.

We added quarter-inch snapping (`Math.round(n * 4) / 4`) before running clearance comparisons or formatting labels, lowered the hard warning threshold for interior doors to `< 24"` (keeping `24"` to `29.75"` as an advisory `info` note for closets and secondary baths), capped advisory `info` score deductions, and emitted summary `pass` entries when all hinged door swings are clear and habitable doors meet `>= 30"`.

Re-running the exact same 2,849 sq ft plan immediately moved the audit from `0/100 (9 warnings)` to `84/100 (0 warnings, 2 summary passes)` with crisp `28"` and `24"` measurements.

One underrated UX detail of dual-use SaaS (apps built for both humans and AI agents) is the handoff from chat back to a browser UI.

Our MCP server stages every compiled plan as a shareable 2D/3D preview page (`/p/<shareId>`), with a one-click button to open the plan in our 2D CAD studio and unlock clean 1/4"=1'-0" Blueprint PDF and AutoCAD R12 DXF exports (`/studio?shared=<shareId>&unlock=1`).

When we audited that deep-link path today, we noticed the studio loaded the shared plan into reactive state and opened the unlock modal immediately, while `projectId` was still `null`. If a user went straight from an MCP link into checkout without making an edit first, the studio had not persisted a working copy to their browser session or D1 project table yet.

Persisting the shared plan to D1 and `localStorage` inside the `initialSharedId` loader before opening the export modal closed that gap completely.

You can connect Claude Desktop, Cursor, or any Streamable HTTP MCP client directly to PlumbDraft with zero setup and no API key required for the free daily geometry, clearance, and takeoff tools (10 requests/day free):

```
{
  "mcpServers": {
    "plumbdraft": {
      "url": "https://www.plumbdraft.com/mcp"
    }
  }
}
```

If you are shipping an MCP server that outputs structured visual or engineering artifacts, I would love to hear what unexpected payload quirks real LLM clients have sent your way.
