dwelldelta-mcp 0.17.1 → 0.17.2

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
@@ -198,6 +198,25 @@ copy city by city (each city's series starts no later and ends no earlier than i
198
198
  later than the current one; otherwise, or with `DWELLDELTA_OFFLINE=1`, the bundled copy answers.
199
199
  `data_as_of` and the `Cite:` line's period say which month the answer runs to.
200
200
 
201
+ ### `bedrooms` as a number, and what rent_check needs (from 0.17.2)
202
+
203
+ - `bedrooms` on area_rents, property_rents and rent_check is read from a whole number as well as from text: 2
204
+ answers exactly as "2" does. A fraction, a number below 0 or any other kind of value is refused, and the refusal
205
+ names the forms that are read. rent_check places a rent against one group, so with `place` and `bedrooms` it needs
206
+ `dwelling_type` too, as before; in the city-wide check it says that `bedrooms` was not used.
207
+ - rent_check's description says what it needs: `current_rent`, and either `place` or `city` with a month
208
+ (`rent_since`, else `lease_start`). Its refusals say which of the two is missing, and name `rent_since` before
209
+ `lease_start`.
210
+ - A place is read only from `place`. When rent_check or property_rents is left without one, the refusal says that a
211
+ place under any other key (`suburb`, `postcode`, `locality`, `area`) is not read; a postcode sent as a number is
212
+ refused with the words to send it as text.
213
+ - An area_rents or nsw_sale_prices answer given with neither `area` nor `council` opens with "No area or council was
214
+ given, so these are the whole state's figures. A place is read only from area or council." (WA, SA and TAS: "No
215
+ area was given, so these are the whole state's figures. A place is read only from area.") The line comes first,
216
+ above any line that opens "STALE:". Its structuredContent is unchanged.
217
+ - Each tool's published inputSchema is unchanged, byte for byte: tools/list is 31,950 characters over stdio, 28,969
218
+ hosted.
219
+
201
220
  ### rent_check from the month the current rent began: `rent_since` (from 0.17.0)
202
221
 
203
222
  - `rent_since` is a new, optional input: the month the current rent began - the last rent rise, or the lease start
@@ -433,8 +433,10 @@ export function areaRentsResult({ state, area, council, dwelling_type, bedrooms,
433
433
  calculated: calculatedByUs(state, feed), several: res.structured.figures.filter((f) => !f.refusal).length > 1 });
434
434
  if (councils.length) cite.pages = places.filter((p) => p.url).map((p) => ({ place: p.name, url: p.url }));
435
435
  const note = resolved?.note ?? null;
436
+ // whole (SITE-237, F2a): the registered handler reads it to open a whole-state answer with a line saying so. It is
437
+ // beside text and structured, never in structuredContent (ok() passes on text and structured alone).
436
438
  return { text: withPlace(res.text, { note, ...cite }, FOOTER),
437
- structured: { ...res.structured, place_note: note, ...cite } };
439
+ structured: { ...res.structured, place_note: note, ...cite }, whole };
438
440
  };
439
441
  if (wantsByType({ dwelling_type, bedrooms })) {
440
442
  return finish(byTypeResult({ state, info, feed, dwelling_type, bedrooms, whole, areas, councils, file: byType[state],
@@ -621,6 +623,18 @@ function bedroomsAsked(wanted) {
621
623
  return m ? { n: Number(m[1]), orMore: Boolean(m[2]) } : null;
622
624
  }
623
625
 
626
+ /**
627
+ * bedrooms sent as a number (SITE-237, F1). The hosted logs held most rent tool calls refused, and `bedrooms: 2` was
628
+ * one reproduced cause: the field is text, and the schema refused the number before any handler ran. A whole number
629
+ * of 0 or more is read as its text ("2"), which every tool then answers exactly as it answers "2"; anything else is
630
+ * returned unchanged, for the schema to refuse in BEDROOMS_REFUSAL's words. Used by area_rents, property_rents and
631
+ * rent_check through z.preprocess, so tools/list declares the same JSON Schema as before. Never touches a string.
632
+ */
633
+ export const readBedrooms = (v) => (typeof v === "number" && Number.isInteger(v) && v >= 0 ? String(v) : v);
634
+ export const BEDROOMS_REFUSAL = "bedrooms is a number of bedrooms: a whole number such as 2, or text such as \"2\", " +
635
+ "\"2 bedrooms\" or \"studio\". A fraction, a number below 0 or any other kind of value is not read: give a whole " +
636
+ "number, or leave bedrooms out for every size.";
637
+
624
638
  /** NSW: which of DCJ's dwelling types and sizes were asked for (null = every one), as DCJ labels them. */
625
639
  function nswAsked(file, dwelling_type, bedrooms) {
626
640
  const cells = file.state_total.breakdown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dwelldelta-mcp",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "description": "Australian rents by area for six states, New Zealand rents by council and region and interim ABS cover for the ACT and NT, asked by place with no state, a rent placed against its local median, NSW median sale prices, an ABS rents index check, and sourced property and lending indicators, for AI agents.",
5
5
  "mcpName": "au.com.dwelldelta/dwelldelta",
6
6
  "license": "MIT",
package/place-tool.mjs CHANGED
@@ -25,7 +25,7 @@
25
25
  import { z } from "zod";
26
26
  import { isRecord, ToolError } from "./tools.mjs";
27
27
  import { areaRentsResult, STATES, norm, wantsByType, dollars, spellings, nswSeveralPostcodes, medianOf, tasPostcodes,
28
- titled } from "./area-rents-tool.mjs";
28
+ titled, readBedrooms, BEDROOMS_REFUSAL } from "./area-rents-tool.mjs";
29
29
  import { vicRentsResult } from "./vic-rents-tool.mjs";
30
30
  import { OUTPUT_SCHEMAS } from "./output-schemas.mjs";
31
31
  import { rentPage } from "./pages.mjs";
@@ -633,6 +633,21 @@ export async function rentCheckLocal({ place, current_rent, proposed_rent, dwell
633
633
  export const PLACE_INSTRUCTIONS = "property_rents takes a place with no state - a suburb, locality or postcode - and " +
634
634
  "answers from the state that holds it; a name held in more than one state is listed, not chosen.";
635
635
 
636
+ /**
637
+ * A place is read only from place (SITE-237, F2). The SDK drops every argument a tool does not declare before its
638
+ * handler runs, so a place sent as suburb, postcode, locality or area never reaches it: the refusals say so, and what
639
+ * to send. Not in tools/list (a field's error is not listed). Exported for rent_check's refusals (register-tools.mjs),
640
+ * so the two tools keep one vocabulary.
641
+ */
642
+ export const ONLY_PLACE = "Only place is read: a place under any other key (suburb, postcode, locality, area) is not.";
643
+ export const QUOTED_POSTCODE = " Send a postcode in quotes (\"2150\"), not as the number 2150.";
644
+ /** property_rents' place refusal: missing (or null), a number, or any other kind of value. */
645
+ export const PLACE_REFUSAL = (issue) => (issue.input == null
646
+ ? "property_rents needs place: a suburb, locality, postcode or NZ council, as text (\"Parramatta\", \"2150\", " +
647
+ `"Richmond, VIC"). ${ONLY_PLACE}`
648
+ : "place is text: a suburb, locality, postcode or NZ council, as \"Parramatta\", \"2150\" or \"Richmond, VIC\"." +
649
+ (typeof issue.input === "number" ? QUOTED_POSTCODE : ""));
650
+
636
651
  /**
637
652
  * Registers property_rents on an McpServer. Called by registerReadOnlyTools (register-tools.mjs) from 0.12.0, so the
638
653
  * stdio and hosted servers list it.
@@ -649,9 +664,10 @@ export function registerPlaceTools(server, data, { byType = async () => ({}), ho
649
664
  "rent, the capital's rents index and sale prices, each with its period and flags. A name held in more than one " +
650
665
  "place is listed, not chosen. For questions such as \"median rent in Fremantle\".",
651
666
  inputSchema: {
652
- place: z.string().describe("A suburb, locality, postcode or NZ council; a state may follow (\"Richmond, VIC\")"),
667
+ // place's and bedrooms' errors and bedrooms' reader (SITE-237) are not listed: tools/list is as before, byte for byte.
668
+ place: z.string({ error: PLACE_REFUSAL }).describe("A suburb, locality, postcode or NZ council; a state may follow (\"Richmond, VIC\")"),
653
669
  dwelling_type: z.string().optional().describe("As area_rents (NSW and QLD only)"),
654
- bedrooms: z.string().optional().describe("As area_rents (NSW and QLD only)"),
670
+ bedrooms: z.preprocess(readBedrooms, z.string({ error: BEDROOMS_REFUSAL })).optional().describe("As area_rents (NSW and QLD only)"),
655
671
  },
656
672
  outputSchema: OUTPUT_SCHEMAS.property_rents,
657
673
  annotations: readOnly,
@@ -17,10 +17,11 @@ import {
17
17
  RENTS_PATH, INDICATORS_PATH,
18
18
  } from "./tools.mjs";
19
19
  import { loadVicRents, vicRentsResult } from "./vic-rents-tool.mjs";
20
- import { loadAllAreaRents, loadAllRentsByType, wantsByType, areaRentsResult, STATES } from "./area-rents-tool.mjs";
20
+ import { loadAllAreaRents, loadAllRentsByType, wantsByType, areaRentsResult, STATES, readBedrooms, BEDROOMS_REFUSAL }
21
+ from "./area-rents-tool.mjs";
21
22
  import { loadNswSales, salePricesResult, DWELLING_TYPES } from "./sale-prices-tool.mjs";
22
23
  import { OUTPUT_SCHEMAS } from "./output-schemas.mjs";
23
- import { rentCheckLocal, registerPlaceTools, PLACE_INSTRUCTIONS } from "./place-tool.mjs";
24
+ import { rentCheckLocal, registerPlaceTools, PLACE_INSTRUCTIONS, ONLY_PLACE, QUOTED_POSTCODE } from "./place-tool.mjs";
24
25
  import { loadCoverFeeds } from "./cover-tool.mjs";
25
26
  import { logField } from "./feed-text.mjs";
26
27
 
@@ -189,6 +190,29 @@ export const RENT_SINCE_REFUSAL = monthRefusal("rent_since", "the month the curr
189
190
  const ignoring = (res, keys, why) => (keys.length ? { text: `Not used: ${keys.join(", ")} (${why}).\n${res.text}`,
190
191
  structured: { ...res.structured, ignored: keys } } : res);
191
192
 
193
+ /**
194
+ * A whole-state answer opens by saying so (SITE-237, F2a). area_rents and nsw_sale_prices answer for the whole state
195
+ * when neither area nor council is given - also when an agent sends its place under a key they do not read (suburb,
196
+ * postcode), which the SDK drops before the handler runs. The result function says whether it answered for the whole
197
+ * state (its own whole, one rule); this puts the line first, above any STALE line, and leaves structuredContent as it
198
+ * is. Applied inside guard, so a refusal never gains it. The form is chosen from a fixed set of the states that hold
199
+ * councils (nsw_sale_prices is NSW), never from the data: in WA, SA and TAS a council is refused.
200
+ */
201
+ const COUNCIL_STATES = new Set(["NSW", "QLD"]);
202
+ const wholeState = (state, res) => (res.whole ? {
203
+ text: `${COUNCIL_STATES.has(state)
204
+ ? "No area or council was given, so these are the whole state's figures. A place is read only from area or council."
205
+ : "No area was given, so these are the whole state's figures. A place is read only from area."}\n${res.text}`,
206
+ structured: res.structured } : res);
207
+
208
+ /**
209
+ * rent_check's place refusal (SITE-237, F2): a number, null, or any other kind of value. No NZ council: rent_check
210
+ * places no rent against an NZ figure.
211
+ */
212
+ export const RENT_CHECK_PLACE_REFUSAL = (issue) => "place is text: a suburb, locality or postcode, as \"Parramatta\" " +
213
+ "or \"2150\"." + (typeof issue.input === "number" ? QUOTED_POSTCODE
214
+ : issue.input === null ? " To give no place, leave place out: null is not read." : "");
215
+
192
216
  /**
193
217
  * Every feed the seven tools answer from, loaded the way the stdio server has loaded them since 0.8.0 and in the same
194
218
  * order: the published copy where it is well formed and not older than the bundled one, else the bundled copy
@@ -287,10 +311,12 @@ export function registerReadOnlyTools(server, data, { byTypeWaitMs = null, hoste
287
311
 
288
312
  server.registerTool("rent_check", titled({
289
313
  title: "Australian rent check",
290
- description: "Compares a weekly rent, and any proposed rent, with how the ABS rents index for the tenant's capital " +
291
- "city has moved since rent_since, else lease_start: city-wide, not suburb-level. Information, not advice, with " +
292
- "the months compared, the source and the limits. Without either month, place (in NSW, VIC, QLD, WA, SA or TAS) " +
293
- "places the rent against its median of new bonds, and its quartiles where published.",
314
+ // SITE-237 (F3): says what the tool needs, and frees 31 characters of tools/list. No top-level anyOf: some clients
315
+ // refuse one (mcp/test/rent-check-needs.test.mjs).
316
+ description: "Compares current_rent with how the ABS rents index for city has moved since a month (rent_since, else " +
317
+ "lease_start): city-wide, not suburb-level. Without a month, with place's median of new bonds (NSW, VIC, QLD, " +
318
+ "WA, SA or TAS), and its quartiles where published. Needs place, or city and a month. Information, not advice, " +
319
+ "with the months compared, the source and the limits.",
294
320
  inputSchema: {
295
321
  // Each is read through z.preprocess (readCity, readMonth, readRent above): tools/list still declares the
296
322
  // canonical form, byte for byte (current_rent's description sits inside, where it keeps its place in the JSON
@@ -300,9 +326,10 @@ export function registerReadOnlyTools(server, data, { byTypeWaitMs = null, hoste
300
326
  rent_since: z.preprocess(readMonth, z.string({ error: RENT_SINCE_REFUSAL }).regex(/^\d{4}-(0[1-9]|1[0-2])$/, { error: RENT_SINCE_REFUSAL })).optional().describe("Month current rent began (last rise, else lease start), YYYY-MM"),
301
327
  current_rent: z.preprocess(readRent, z.number({ error: rentRefusal("current_rent") }).positive({ error: rentRefusal("current_rent") }).describe("Current weekly rent in Australian dollars")),
302
328
  proposed_rent: z.preprocess(readRent, z.number({ error: rentRefusal("proposed_rent") }).positive({ error: rentRefusal("proposed_rent") })).optional().describe("Proposed weekly rent in Australian dollars"),
303
- place: z.string().optional().describe("Without either month: a suburb, locality or postcode; a state may follow (\"Richmond, VIC\")"),
329
+ // place's error and bedrooms' reader (SITE-237) are not listed: each field lists as before, byte for byte.
330
+ place: z.string({ error: RENT_CHECK_PLACE_REFUSAL }).optional().describe("Without either month: a suburb, locality or postcode; a state may follow (\"Richmond, VIC\")"),
304
331
  dwelling_type: z.string().optional().describe("With place: as area_rents (NSW and QLD only)"),
305
- bedrooms: z.string().optional().describe("With place: as area_rents (NSW and QLD only)"),
332
+ bedrooms: z.preprocess(readBedrooms, z.string({ error: BEDROOMS_REFUSAL })).optional().describe("With place: as area_rents (NSW and QLD only)"),
306
333
  },
307
334
  outputSchema: OUTPUT_SCHEMAS.rent_check,
308
335
  annotations: readOnly,
@@ -323,9 +350,19 @@ export function registerReadOnlyTools(server, data, { byTypeWaitMs = null, hoste
323
350
  `with ${given}, the rent is compared with the city's ABS rents index; leave ${given} out for the place's ` +
324
351
  "median of new bonds");
325
352
  }
353
+ // Neither month, and no place (SITE-237, F3): with city, the month is what is missing; without it, place - and a
354
+ // place under another key never reaches here (the SDK drops it), so the refusal says so.
355
+ if ((args.place == null || !String(args.place).trim()) && args.city != null) {
356
+ throw new ToolError("rent_check with city needs a month, rent_since or lease_start: the ABS rents index is " +
357
+ "compared from it. Without a month it needs place, for the local median of new bonds.",
358
+ "Give rent_since (the month the current rent began, e.g. \"2024-03\") or lease_start, with city; or leave city " +
359
+ "out and give the suburb, locality or postcode as place.");
360
+ }
326
361
  if (args.place == null || !String(args.place).trim()) {
327
- throw new ToolError("rent_check needs lease_start with city (the city-wide index check), or place (the local " +
328
- "median of new bonds).", "Give lease_start and city, or a suburb, locality or postcode as place.");
362
+ throw new ToolError("rent_check needs place (a suburb, locality or postcode, for the local median of new bonds), " +
363
+ `or city with rent_since or lease_start (the city-wide index check). ${ONLY_PLACE}`,
364
+ "Give the suburb, locality or postcode as place, e.g. place \"Parramatta\" or \"2150\"; or give city and " +
365
+ "rent_since (or lease_start).");
329
366
  }
330
367
  return ignoring(await rentCheckLocal(args, data, new Date(), { byType: () => byTypeFiles(rentsByType, byTypeWaitMs), hosted }),
331
368
  args.city != null ? ["city"] : [], "without lease_start, the rent is placed against the place's own median; give " +
@@ -408,7 +445,8 @@ export function registerReadOnlyTools(server, data, { byTypeWaitMs = null, hoste
408
445
  dwelling_type: z.string().optional().describe("NSW and QLD only. NSW (DCJ's labels): House, Townhouse, " +
409
446
  "Flat/Unit, Other. QLD (the RTA's): Flat, House, Townhouse. 'unit' and 'apartment' are read as flat/unit. " +
410
447
  "Without bedrooms, every size the publisher reports for that type is given"),
411
- bedrooms: z.string().optional().describe("NSW and QLD only: a number of bedrooms, as '2' or '2 bedrooms'. NSW " +
448
+ // bedrooms' reader and error (SITE-237, F1) are not listed: the field lists as before, byte for byte.
449
+ bedrooms: z.preprocess(readBedrooms, z.string({ error: BEDROOMS_REFUSAL })).optional().describe("NSW and QLD only: a number of bedrooms, as '2' or '2 bedrooms'. NSW " +
412
450
  "also has Bedsitter, and 4 means DCJ's '4 or more Bedrooms'; a number above 4 is answered under that label " +
413
451
  "too, and the answer says it is not for that number alone. QLD: the RTA publishes flats of 1 to 3, houses " +
414
452
  "of 2 to 4 and town houses of 2 to 3, and does not define its labels - reading the number as bedrooms is " +
@@ -417,8 +455,8 @@ export function registerReadOnlyTools(server, data, { byTypeWaitMs = null, hoste
417
455
  },
418
456
  outputSchema: OUTPUT_SCHEMAS.area_rents,
419
457
  annotations: readOnly,
420
- }), guard(async (args) => areaRentsResult(args, areaRents, new Date(),
421
- { nswSuburbs: suburbs, byType: wantsByType(args) ? await byTypeFiles(rentsByType, byTypeWaitMs) : {}, hosted })));
458
+ }), guard(async (args) => wholeState(args.state, areaRentsResult(args, areaRents, new Date(),
459
+ { nswSuburbs: suburbs, byType: wantsByType(args) ? await byTypeFiles(rentsByType, byTypeWaitMs) : {}, hosted }))));
422
460
 
423
461
  server.registerTool("nsw_sale_prices", titled({
424
462
  title: "NSW median sale prices by postcode or council",
@@ -441,7 +479,7 @@ export function registerReadOnlyTools(server, data, { byTypeWaitMs = null, hoste
441
479
  },
442
480
  outputSchema: OUTPUT_SCHEMAS.nsw_sale_prices,
443
481
  annotations: readOnly,
444
- }), guard((args) => salePricesResult(args, nswSales, new Date(), { nswSuburbs: suburbs, refused: refused.nswSales })));
482
+ }), guard((args) => wholeState("NSW", salePricesResult(args, nswSales, new Date(), { nswSuburbs: suburbs, refused: refused.nswSales }))));
445
483
 
446
484
  // property_rents (0.12.0): registered with the others so the stdio and hosted servers list the same tools.
447
485
  registerPlaceTools(server, data, { byType: () => byTypeFiles(rentsByType, byTypeWaitMs), hosted, titled, readOnly, guard });
@@ -251,5 +251,7 @@ export function salePricesResult({ area, council, dwelling_type } = {}, feed, no
251
251
  councils: councils.map(pick), areas: areas.map(pick), any_unusual: marked,
252
252
  any_unusual_part: noted,
253
253
  truncated: dropped.length > 0, limits: feed.limits, changes_made: feed.changes_made,
254
- ...figureFields(figures), sample_rule: RULE, place_note: note, ...cite } };
254
+ ...figureFields(figures), sample_rule: RULE, place_note: note, ...cite },
255
+ // whole (SITE-237, F2a): read by the registered handler, never in structuredContent (as areaRentsResult).
256
+ whole };
255
257
  }
package/tools.mjs CHANGED
@@ -124,7 +124,7 @@ export async function loadSnapshot({ env = process.env, fetchImpl = globalThis.f
124
124
  }
125
125
 
126
126
  export const FOOTER = "Information, not advice. From DwellDelta (dwelldelta.com.au), built on public data.";
127
- export const SERVER_VERSION = "0.17.1";
127
+ export const SERVER_VERSION = "0.17.2";
128
128
  // The indicators snapshot is rebuilt every Monday. Older than this and the answer says so, in words and in the
129
129
  // structured result, rather than serving a stale figure as current.
130
130
  export const STALE_DAYS = 10;