opentakeoff-mcp 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,6 +20,17 @@ No clone, no build — point your MCP client at the published package:
20
20
 
21
21
  Works with Claude Code (`claude mcp add opentakeoff -- npx -y opentakeoff-mcp`), Claude Desktop, Cursor, or any stdio MCP client. Node 20+.
22
22
 
23
+ ## One-click install (Claude Desktop)
24
+
25
+ No Node, no npm: download **`opentakeoff-mcp.mcpb`** from the
26
+ [latest release](https://github.com/Kentucky-ai/opentakeoff/releases) and
27
+ double-click it — Claude Desktop installs the server with its dependencies
28
+ bundled. Built by `npm run mcpb` and attached automatically to every `mcp-v*`
29
+ release. The bundle is platform-neutral on purpose: it excludes the optional
30
+ native canvas, so every tool and the text/metadata resources work everywhere,
31
+ and the sheet-image resource says exactly what's missing where rendering isn't
32
+ available.
33
+
23
34
 
24
35
  The takeoff engine — One-Click Area, the scale model, conditions, totals — on
25
36
  **stdio for your MCP client**. An agent can open a plan, read the title block,
@@ -104,8 +115,11 @@ includes document text, shape vertices, or result payload content.
104
115
  | `delete_shape` | Remove a committed shape by id. |
105
116
  | `read_sheet_text` | Positioned page text (image px), optionally restricted to a region — title blocks, room labels, finish schedules. |
106
117
 
107
- Every reply is one compact JSON text item. Failures come back as
108
- `isError: true` with `{"error": "..."}` never a dropped connection.
118
+ Every tool declares an **`outputSchema`**, and every reply carries the payload
119
+ as **`structuredContent`** typed, machine-validated on every call alongside
120
+ the same compact JSON in a single text item for clients that predate structured
121
+ output. Failures come back as `isError: true` with `{"error": "..."}` — never a
122
+ dropped connection.
109
123
 
110
124
  ## Resources — browse before you measure
111
125
 
@@ -199,6 +199,7 @@ function positionedText(ph) {
199
199
  var UserError = class extends Error {
200
200
  };
201
201
  var ok = (payload) => ({
202
+ structuredContent: payload,
202
203
  content: [{ type: "text", text: JSON.stringify(payload) }]
203
204
  });
204
205
  var fail = (err) => ({
@@ -1176,7 +1177,7 @@ var Session = class {
1176
1177
  };
1177
1178
 
1178
1179
  // src/tools.ts
1179
- import { z } from "zod";
1180
+ import { z as z2 } from "zod";
1180
1181
 
1181
1182
  // src/trace.ts
1182
1183
  var TRACE_ENV = "OPENTAKEOFF_MCP_TRACE";
@@ -1197,10 +1198,136 @@ function traceToolCall(tool, args, startedAt, reply) {
1197
1198
  `);
1198
1199
  }
1199
1200
 
1201
+ // src/outputs.ts
1202
+ import { z } from "zod";
1203
+ var point = z.tuple([z.number(), z.number()]);
1204
+ var sheetSummary2 = {
1205
+ sheet: z.string().describe('Sheet key: page 1 is the bare file name ("plan.pdf"), pages 2+ are "plan.pdf#2"'),
1206
+ page: z.number().int().describe("1-based page number"),
1207
+ width_pt: z.number(),
1208
+ height_pt: z.number(),
1209
+ width_px: z.number().describe("Image px at render scale 2.0 \u2014 the coordinate space every tool speaks"),
1210
+ height_px: z.number(),
1211
+ sheet_number: z.string().optional().describe('Title-block sheet number ("A-101") where detected'),
1212
+ detected_scale: z.string().optional().describe("Drawn scale note read off the sheet \u2014 a suggestion, never auto-applied")
1213
+ };
1214
+ var loadPlanOutput = {
1215
+ file: z.string(),
1216
+ page_count: z.number().int(),
1217
+ sheets: z.array(z.object(sheetSummary2)),
1218
+ note: z.string()
1219
+ };
1220
+ var sheetInfoOutput = {
1221
+ ...sheetSummary2,
1222
+ seg_count: z.number().int().describe("Vector segment count"),
1223
+ has_vector_linework: z.boolean().describe("one_click needs vector linework"),
1224
+ scale_set: z.boolean(),
1225
+ upp: z.number().optional().describe("Real feet per image px at render scale 2.0 \u2014 present once the scale is set"),
1226
+ shape_count: z.number().int().describe("Committed shapes on this sheet")
1227
+ };
1228
+ var setScaleOutput = {
1229
+ sheet: z.string(),
1230
+ upp: z.number().describe("Real feet per image px at render scale 2.0"),
1231
+ label: z.string().optional().describe("The standard scale label, when set by label or detected note"),
1232
+ source: z.enum(["label", "upp", "calibrate", "detected"])
1233
+ };
1234
+ var oneClickOutput = {
1235
+ status: z.literal("ok"),
1236
+ nverts: z.number().int().describe("Vertex count of the traced polygon"),
1237
+ hatch_filtered: z.literal(true).optional().describe("Present when hatch/pattern linework was classified out of the boundary"),
1238
+ verts: z.array(point).optional().describe("Traced polygon vertices (image px), when return_verts was set"),
1239
+ area_sf: z.number().optional().describe("Scaled mode: traced area in SF"),
1240
+ perimeter_lf: z.number().optional().describe("Scaled mode: traced perimeter in LF"),
1241
+ shape_id: z.string().optional().describe("Scaled mode: id of the committed shape, when condition was passed"),
1242
+ area_px2: z.number().optional().describe("Preview mode (no scale): raw area in px\xB2"),
1243
+ perimeter_px: z.number().optional().describe("Preview mode (no scale): raw perimeter in px"),
1244
+ warning: z.string().optional().describe("Preview mode (no scale): why quantities are unavailable and what to do")
1245
+ };
1246
+ var measurePolygonOutput = {
1247
+ area_sf: z.number(),
1248
+ perimeter_lf: z.number(),
1249
+ nverts: z.number().int(),
1250
+ shape_id: z.string().optional().describe("Present when condition was passed and the shape committed")
1251
+ };
1252
+ var measureLineOutput = {
1253
+ length_lf: z.number(),
1254
+ npts: z.number().int(),
1255
+ shape_id: z.string().optional().describe("Present when condition was passed and the shape committed")
1256
+ };
1257
+ var summaryRow = z.object({
1258
+ id: z.string(),
1259
+ finish_tag: z.string(),
1260
+ multiplier: z.number(),
1261
+ waste_pct: z.number(),
1262
+ shape_count: z.number().int(),
1263
+ floor_sf: z.number(),
1264
+ wall_sf: z.number(),
1265
+ border_sf: z.number(),
1266
+ lf: z.number(),
1267
+ ea: z.number(),
1268
+ total_sf: z.number(),
1269
+ floor_sf_net: z.number(),
1270
+ wall_sf_net: z.number(),
1271
+ border_sf_net: z.number(),
1272
+ lf_net: z.number(),
1273
+ total_sf_net: z.number(),
1274
+ sy_net: z.number()
1275
+ }).passthrough();
1276
+ var takeoffSummaryOutput = {
1277
+ conditions: z.array(summaryRow),
1278
+ totals: z.object({
1279
+ total_sf: z.number(),
1280
+ total_sf_net: z.number(),
1281
+ lf: z.number(),
1282
+ lf_net: z.number(),
1283
+ ea: z.number(),
1284
+ sy_net: z.number()
1285
+ }).passthrough()
1286
+ };
1287
+ var exportTakeoffOutput = {
1288
+ schema: z.string(),
1289
+ project_name: z.string(),
1290
+ units: z.string(),
1291
+ sheets: z.array(z.object({ sheet_id: z.string(), units_per_px: z.number() })),
1292
+ conditions: z.array(z.object({
1293
+ id: z.string(),
1294
+ finish_tag: z.string(),
1295
+ color: z.string(),
1296
+ fill: z.string(),
1297
+ hatch: z.string(),
1298
+ multiplier: z.number(),
1299
+ waste_pct: z.number(),
1300
+ materials: z.array(z.unknown())
1301
+ }).passthrough()),
1302
+ shapes: z.array(z.object({
1303
+ id: z.string(),
1304
+ sheet_id: z.string(),
1305
+ condition_id: z.string(),
1306
+ measure_role: z.enum(["floor_area", "deduct", "linear"]),
1307
+ verts_norm: z.array(point).describe("Vertices normalized to sheet dims (0\u20131)"),
1308
+ computed: z.object({ area_sf: z.number(), perimeter_lf: z.number() }).passthrough(),
1309
+ origin: z.object({}).passthrough().optional().describe("Provenance for one-click traces")
1310
+ }).passthrough()),
1311
+ markups: z.array(z.unknown()),
1312
+ sheet_group: z.array(z.unknown()),
1313
+ last_group: z.array(z.unknown()),
1314
+ sheet_tabs: z.array(z.unknown()),
1315
+ sheet_levels: z.object({}).passthrough()
1316
+ };
1317
+ var deleteShapeOutput = {
1318
+ deleted: z.string().describe("The removed shape's id"),
1319
+ shape_count: z.number().int().describe("Committed shapes remaining")
1320
+ };
1321
+ var readSheetTextOutput = {
1322
+ sheet: z.string(),
1323
+ items: z.array(z.object({ str: z.string(), x: z.number(), y: z.number() })).describe("Positioned text items (image px)"),
1324
+ text: z.string().describe("The items joined with spaces")
1325
+ };
1326
+
1200
1327
  // src/tools.ts
1201
1328
  var COORDS = "Coordinates are image px at render scale 2.0: PDF pt \xD7 2, origin top-left, y down (the browser canvas's native space). Sheet payloads carry dims in both px and pt.";
1202
- var pointSchema = z.tuple([z.number(), z.number()]);
1203
- var roleSchema = z.enum(["floor_area", "deduct"]).default("floor_area");
1329
+ var pointSchema = z2.tuple([z2.number(), z2.number()]);
1330
+ var roleSchema = z2.enum(["floor_area", "deduct"]).default("floor_area");
1204
1331
  var run = (tool, fn) => async (args) => {
1205
1332
  const startedAt = process.hrtime.bigint();
1206
1333
  let reply;
@@ -1215,7 +1342,8 @@ var run = (tool, fn) => async (args) => {
1215
1342
  function registerTools(server, session) {
1216
1343
  server.registerTool("load_plan", {
1217
1344
  description: `Open a plan PDF from disk and replace the whole session (previous document, scales, conditions, and shapes are cleared). Returns file, page_count, and one entry per sheet: dims, title-block sheet_number, and the detected drawn scale where present. The loaded sheets also become browsable resources (takeoff://sheets). ${COORDS}`,
1218
- inputSchema: { path: z.string().describe("Path to a plan PDF on disk") }
1345
+ inputSchema: { path: z2.string().describe("Path to a plan PDF on disk") },
1346
+ outputSchema: loadPlanOutput
1219
1347
  }, run("load_plan", async ({ path: path3 }) => {
1220
1348
  const loaded = await session.loadPlan(path3);
1221
1349
  server.sendResourceListChanged();
@@ -1223,17 +1351,19 @@ function registerTools(server, session) {
1223
1351
  }));
1224
1352
  server.registerTool("sheet_info", {
1225
1353
  description: `Sheet detail: dims (px and pt), vector segment count, whether the sheet has vector linework (one_click needs it), scale status, the detected scale suggestion, and this sheet's committed shape count. ${COORDS}`,
1226
- inputSchema: { sheet: z.string().describe('Sheet key ("plan.pdf", "plan.pdf#2") or title-block number ("A-101")') }
1354
+ inputSchema: { sheet: z2.string().describe('Sheet key ("plan.pdf", "plan.pdf#2") or title-block number ("A-101")') },
1355
+ outputSchema: sheetInfoOutput
1227
1356
  }, run("sheet_info", ({ sheet }) => session.sheetInfo(sheet)));
1228
1357
  server.registerTool("set_scale", {
1229
1358
  description: `Set a sheet's scale \u2014 exactly ONE of: label (a standard scale, e.g. '1/4" = 1'-0"'), upp (real feet per image px), calibrate (two points along a known dimension plus its real feet), or use_detected (adopt the drawn scale note read off the sheet). The detected scale is never applied automatically \u2014 setting it is always this explicit call. ${COORDS}`,
1230
1359
  inputSchema: {
1231
- sheet: z.string(),
1232
- label: z.string().optional().describe("A standard scale label, exactly as listed in the error on a miss"),
1233
- upp: z.number().optional().describe("Real feet per image px at render scale 2.0"),
1234
- calibrate: z.object({ p1: pointSchema, p2: pointSchema, feet: z.number() }).optional().describe("Two points (image px) a known real distance apart, and that distance in feet"),
1235
- use_detected: z.boolean().optional().describe("true = adopt the sheet's detected scale")
1236
- }
1360
+ sheet: z2.string(),
1361
+ label: z2.string().optional().describe("A standard scale label, exactly as listed in the error on a miss"),
1362
+ upp: z2.number().optional().describe("Real feet per image px at render scale 2.0"),
1363
+ calibrate: z2.object({ p1: pointSchema, p2: pointSchema, feet: z2.number() }).optional().describe("Two points (image px) a known real distance apart, and that distance in feet"),
1364
+ use_detected: z2.boolean().optional().describe("true = adopt the sheet's detected scale")
1365
+ },
1366
+ outputSchema: setScaleOutput
1237
1367
  }, run("set_scale", (a) => {
1238
1368
  const given = [a.label !== void 0, a.upp !== void 0, a.calibrate !== void 0, a.use_detected !== void 0].filter(Boolean).length;
1239
1369
  if (given !== 1) throw new UserError("Provide exactly one of: label, upp, calibrate, use_detected.");
@@ -1242,38 +1372,43 @@ function registerTools(server, session) {
1242
1372
  server.registerTool("one_click", {
1243
1373
  description: `One-Click Area: click inside a room (image px) and the plan's vector linework bounds it \u2014 flood fill, contour trace, vertices snapped to true PDF endpoints. With the sheet's scale set, returns area_sf / perimeter_lf; pass condition (a finish tag, e.g. "CPT-1") to commit the traced shape to the takeoff. Without a scale it returns px-only quantities with a warning and commits nothing. role "deduct" makes the committed shape subtract. ${COORDS}`,
1244
1374
  inputSchema: {
1245
- sheet: z.string(),
1246
- x: z.number(),
1247
- y: z.number(),
1248
- condition: z.string().optional().describe("Finish tag to commit under (minted on first use)"),
1375
+ sheet: z2.string(),
1376
+ x: z2.number(),
1377
+ y: z2.number(),
1378
+ condition: z2.string().optional().describe("Finish tag to commit under (minted on first use)"),
1249
1379
  role: roleSchema,
1250
- return_verts: z.boolean().default(false).describe("Include the traced polygon's vertices (image px)")
1251
- }
1380
+ return_verts: z2.boolean().default(false).describe("Include the traced polygon's vertices (image px)")
1381
+ },
1382
+ outputSchema: oneClickOutput
1252
1383
  }, run("one_click", (a) => session.oneClick(a.sheet, a.x, a.y, { condition: a.condition, role: a.role, returnVerts: a.return_verts })));
1253
1384
  server.registerTool("measure_polygon", {
1254
1385
  description: `Measure a closed polygon you supply (min 3 vertices, image px): area_sf and perimeter_lf at the sheet's scale. Requires the scale to be set. Pass condition to commit it; role "deduct" subtracts. ${COORDS}`,
1255
1386
  inputSchema: {
1256
- sheet: z.string(),
1257
- verts: z.array(pointSchema).min(3),
1258
- condition: z.string().optional(),
1387
+ sheet: z2.string(),
1388
+ verts: z2.array(pointSchema).min(3),
1389
+ condition: z2.string().optional(),
1259
1390
  role: roleSchema
1260
- }
1391
+ },
1392
+ outputSchema: measurePolygonOutput
1261
1393
  }, run("measure_polygon", (a) => session.measurePolygon(a.sheet, a.verts, { condition: a.condition, role: a.role })));
1262
1394
  server.registerTool("measure_line", {
1263
1395
  description: `Measure an open polyline (min 2 points, image px): length_lf at the sheet's scale. Requires the scale to be set. Pass condition to commit it as a linear shape (base, transitions, feature strips). ${COORDS}`,
1264
1396
  inputSchema: {
1265
- sheet: z.string(),
1266
- pts: z.array(pointSchema).min(2),
1267
- condition: z.string().optional()
1268
- }
1397
+ sheet: z2.string(),
1398
+ pts: z2.array(pointSchema).min(2),
1399
+ condition: z2.string().optional()
1400
+ },
1401
+ outputSchema: measureLineOutput
1269
1402
  }, run("measure_line", (a) => session.measureLine(a.sheet, a.pts, { condition: a.condition })));
1270
1403
  server.registerTool("takeoff_summary", {
1271
1404
  description: `Per-condition totals (floor/wall/border SF, LF, EA, SY, with and without waste) plus grand totals \u2014 the Report's numbers, computed by the same rules. ${COORDS}`,
1272
- inputSchema: {}
1405
+ inputSchema: {},
1406
+ outputSchema: takeoffSummaryOutput
1273
1407
  }, run("takeoff_summary", () => session.summary()));
1274
1408
  server.registerTool("export_takeoff", {
1275
1409
  description: `The full "opentakeoff.takeoff_canvas.v1" annotations payload \u2014 exactly what the app autosaves, importable by it. Returned inline; pass path to also write it to disk as JSON. ${COORDS}`,
1276
- inputSchema: { path: z.string().optional().describe("File path to write the payload to") }
1410
+ inputSchema: { path: z2.string().optional().describe("File path to write the payload to") },
1411
+ outputSchema: exportTakeoffOutput
1277
1412
  }, run("export_takeoff", async ({ path: outPath }) => {
1278
1413
  const payload = session.exportPayload();
1279
1414
  if (outPath) {
@@ -1284,14 +1419,16 @@ function registerTools(server, session) {
1284
1419
  }));
1285
1420
  server.registerTool("delete_shape", {
1286
1421
  description: `Remove a committed shape by the id returned when it was committed. ${COORDS}`,
1287
- inputSchema: { shape_id: z.string() }
1422
+ inputSchema: { shape_id: z2.string() },
1423
+ outputSchema: deleteShapeOutput
1288
1424
  }, run("delete_shape", ({ shape_id }) => session.deleteShape(shape_id)));
1289
1425
  server.registerTool("read_sheet_text", {
1290
1426
  description: `The sheet's text with positions \u2014 items [{str, x, y}] in image px plus the joined text. Optionally restrict to a region {x0, y0, x1, y1}. Use it to read title blocks, room labels, finish schedules, and scale notes. ${COORDS}`,
1291
1427
  inputSchema: {
1292
- sheet: z.string(),
1293
- region: z.object({ x0: z.number(), y0: z.number(), x1: z.number(), y1: z.number() }).optional()
1294
- }
1428
+ sheet: z2.string(),
1429
+ region: z2.object({ x0: z2.number(), y0: z2.number(), x1: z2.number(), y1: z2.number() }).optional()
1430
+ },
1431
+ outputSchema: readSheetTextOutput
1295
1432
  }, run("read_sheet_text", (a) => session.readSheetText(a.sheet, a.region)));
1296
1433
  }
1297
1434
 
@@ -1374,7 +1511,7 @@ function registerResources(server, session) {
1374
1511
  // package.json
1375
1512
  var package_default = {
1376
1513
  name: "opentakeoff-mcp",
1377
- version: "0.2.0",
1514
+ version: "0.3.0",
1378
1515
  mcpName: "io.github.Kentucky-ai/opentakeoff",
1379
1516
  type: "module",
1380
1517
  description: "OpenTakeoff MCP server \u2014 drive the takeoff engine from your MCP client over stdio.",
@@ -1386,9 +1523,11 @@ var package_default = {
1386
1523
  dev: "node --import tsx server.ts",
1387
1524
  start: "node dist/server.js",
1388
1525
  build: "esbuild server.ts --bundle --platform=node --format=esm --packages=external --outfile=dist/server-core.js && node scripts/finish-build.mjs",
1526
+ "smoke:dist": "node scripts/smoke-dist.mjs",
1527
+ mcpb: "npm run build && node scripts/build-mcpb.mjs",
1389
1528
  prepublishOnly: "npm run typecheck && npm test && npm run build",
1390
1529
  typecheck: "tsc --noEmit",
1391
- test: "node --import tsx --test test/*.test.ts"
1530
+ test: "node --import tsx --test test/e2e.test.ts test/resources.test.ts test/session.test.ts test/tools.test.ts"
1392
1531
  },
1393
1532
  dependencies: {
1394
1533
  "@modelcontextprotocol/sdk": "^1.12.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opentakeoff-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "mcpName": "io.github.Kentucky-ai/opentakeoff",
5
5
  "type": "module",
6
6
  "description": "OpenTakeoff MCP server \u2014 drive the takeoff engine from your MCP client over stdio.",
@@ -12,9 +12,11 @@
12
12
  "dev": "node --import tsx server.ts",
13
13
  "start": "node dist/server.js",
14
14
  "build": "esbuild server.ts --bundle --platform=node --format=esm --packages=external --outfile=dist/server-core.js && node scripts/finish-build.mjs",
15
+ "smoke:dist": "node scripts/smoke-dist.mjs",
16
+ "mcpb": "npm run build && node scripts/build-mcpb.mjs",
15
17
  "prepublishOnly": "npm run typecheck && npm test && npm run build",
16
18
  "typecheck": "tsc --noEmit",
17
- "test": "node --import tsx --test test/*.test.ts"
19
+ "test": "node --import tsx --test test/e2e.test.ts test/resources.test.ts test/session.test.ts test/tools.test.ts"
18
20
  },
19
21
  "dependencies": {
20
22
  "@modelcontextprotocol/sdk": "^1.12.0",