{"slug": "3-real-bugs-we-caught-when-an-ai-agent-compiled-a-2849-sq-ft-house-plan-through", "title": "3 Real Bugs We Caught When an AI Agent Compiled a 2,849 sq ft House Plan Through Our MCP Server", "summary": "A developer running a hosted Streamable HTTP MCP server for floor-plan compilation reported three edge cases exposed after a real 2,849 sq ft, 16-room residential plan was submitted by an AI agent, causing the SVG preview page to return a 500 error. The failures traced to LLM-generated JSON using aliases like type/name/rotation instead of the schema's kind/label/rotationDeg, which crashed a symbol renderer on an undefined kind, and to unit-conversion drift where 2.333 ft became 27.996 inches, tripping a strict 28-inch interior-door check on eight standard doors. The fix was a single normalizer coercing aliases before geometry, SVG, DXF, PDF or Three.js processing, plus filtering unpositioned notes and documenting units in the tool's inputSchema.", "body_md": "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.\n\nThe compilation succeeded, the agent returned our live 2D/3D preview URL to the user, and the user clicked the link four times.\n\nAnd our preview page returned a `500 Internal Error`.\n\nDebugging 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.\n\nOur internal TypeScript model expects furniture fixtures with explicit fields:\n\n```\ninterface FurnitureItem {\n  id: string;\n  kind: string;        // e.g. \"kitchen_island\", \"bed_queen\"\n  category: string;\n  label: string;\n  x: number;\n  y: number;\n  widthIn: number;\n  depthIn: number;\n  rotationDeg: number;\n}\n```\n\nOur 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:\n\n`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.\nThe 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:\n\n```\nif (item.kind.startsWith('bed_')) { ... }\n```\n\n`item.kind` was `undefined`. Boom: unhandled `TypeError` and a `500` page.\n\n`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:\n\n``` js\nconst rawKind =\n  typeof raw.kind === 'string' && raw.kind.trim()\n    ? raw.kind.trim()\n    : typeof raw.type === 'string' && raw.type.trim()\n      ? raw.type.trim()\n      : 'custom';\n\nconst label =\n  typeof raw.label === 'string' && raw.label.trim()\n    ? raw.label.trim()\n    : typeof raw.name === 'string' && raw.name.trim()\n      ? raw.name.trim()\n      : rawKind;\n\nconst rotationDeg =\n  typeof raw.rotationDeg === 'number' && Number.isFinite(raw.rotationDeg)\n    ? raw.rotationDeg\n    : typeof raw.rotation === 'number' && Number.isFinite(raw.rotation)\n      ? raw.rotation\n      : 0;\n```\n\nUnpositioned 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.\n\n`27.996\"` vs `28\"`)\nIn US residential architecture, `2'-4\"` (`28\"`) and `2'-0\"` (`24\"`) are completely standard interior doors for closets, pantries, laundry rooms, and secondary baths.\n\nThe agent built the house plan in decimal feet and converted to inches:\n\n```\n2.333 ft * 12 in/ft = 27.996 in\n```\n\nOur clearance engine had a strict interior door check:\n\n```\nif (op.widthIn < 28) {\n  addIssue({\n    severity: 'warning',\n    code: 'DOOR_WIDTH',\n    detail: `Interior door ${op.tag} is ${op.widthIn}\" wide...`\n  });\n}\n```\n\nBecause `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.\n\nWe 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\"`.\n\nRe-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.\n\nOne 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.\n\nOur 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`).\n\nWhen 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.\n\nPersisting the shared plan to D1 and `localStorage` inside the `initialSharedId` loader before opening the export modal closed that gap completely.\n\nYou 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):\n\n```\n{\n  \"mcpServers\": {\n    \"plumbdraft\": {\n      \"url\": \"https://www.plumbdraft.com/mcp\"\n    }\n  }\n}\n```\n\nIf 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.", "url": "https://wpnews.pro/news/3-real-bugs-we-caught-when-an-ai-agent-compiled-a-2849-sq-ft-house-plan-through", "canonical_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_at": "2026-11-30 14:39:49+00:00", "updated_at": "2026-11-30 14:46:08.104292+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "developer-tools"], "entities": ["Plumbdraft", "MCP", "D1", "Three.js", "DXF"], "also_reported_by": [], "takeaway": "Normalize LLM-supplied JSON aliases (type→kind, name→label, rotation→rotationDeg) in one coercion layer before any downstream renderer, and use tolerance-based comparisons for unit-converted dimensions, since 2.333 ft × 12 = 27.996 in failed a strict 28-inch door check.", "recommendation": {"advice": "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.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/3-real-bugs-we-caught-when-an-ai-agent-compiled-a-2849-sq-ft-house-plan-through", "markdown": "https://wpnews.pro/news/3-real-bugs-we-caught-when-an-ai-agent-compiled-a-2849-sq-ft-house-plan-through.md", "text": "https://wpnews.pro/news/3-real-bugs-we-caught-when-an-ai-agent-compiled-a-2849-sq-ft-house-plan-through.txt", "jsonld": "https://wpnews.pro/news/3-real-bugs-we-caught-when-an-ai-agent-compiled-a-2849-sq-ft-house-plan-through.jsonld"}}