PlumbDraft MCP 伺服器處理 AI Agent 編譯的 2,849 sq ft 樓面圖時發現 3 個實際錯誤
3 Real Bugs We Caught When an AI Agent Compiled a 2,849 sq ft House Plan Through Our MCP Server
PlumbDraft 的 MCP 伺服器處理一份 2,849 sq ft、16 個房間及 26 扇門的樓面圖後,預覽頁出現 500 Internal Error,並揭出三類邊界問題。
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.
1. LLMs invent plausible aliases even when your tool works
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:
- It sent
type: "island",name: "Kitchen Island", androtation: 90instead ofkind,label, androtationDeg. - It sent
{ type: "door", style: "overhead" }and{ type: "opening" }instead ofdoor_doubleandcased_opening. - It sent
notes: ["Verify structural headers", "Check local setback"]as plain strings withoutxoryblueprint 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.
The fix: two layers of defense
-
Be explicit in
tools/list: Put the exact field names, allowed enum strings, and coordinate units (1 ft = 12 in) directly inside the tool'sinputSchemadescription so agents emit canonical JSON on the first call. -
Normalize at the compiler boundary, not in every renderer: Inside
compileFloorPlan(), we now coerce incoming LLM aliases once before geometry, SVG, DXF, PDF, or Three.js ever see the object:
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.
2. Floating-point imperial math broke our clearance audit (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.
The fix: architectural quarter-inch rounding and realistic IRC thresholds
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.
3. Stateless MCP preview links need persistence before studio handoff
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.
Try the hosted CAD MCP server yourself
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"
}
}
}
- Live AutoCAD R12 DXF inspector and setup guide: https://www.plumbdraft.com/developers
- Claude MCP floor plan walkthrough: https://www.plumbdraft.com/tools/claude-mcp-floor-plan-cad
- Open the browser CAD studio directly: https://www.plumbdraft.com/studio
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.
來源:DEV Community · dev.to