dwelldelta-mcp 0.12.0 → 0.13.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
@@ -134,6 +134,37 @@ copy city by city (each city's series starts no later and ends no earlier than i
134
134
  later than the current one; otherwise, or with `DWELLDELTA_OFFLINE=1`, the bundled copy answers.
135
135
  `data_as_of` and the `Cite:` line's period say which month the answer runs to.
136
136
 
137
+ ### rent_check reads common input shapes (from 0.13.0)
138
+
139
+ - `city` is read in any case ("sydney"), as "Greater Sydney", or as "Sydney, NSW" (the state must be the city's
140
+ own). A state or territory alone ("NSW", "Victoria") is refused, never read as its capital: the ABS rents index
141
+ exists only for capitals, so a regional tenant's "NSW" is not Sydney's index. The refusal names the capital, and
142
+ where local rents are held, says to give `place` for the local rent check.
143
+ - `current_rent` and `proposed_rent` are read from text as well as numbers: "550", "$550", "A$550", "550.00",
144
+ "$1,250", "550 pw", "550 per week". A range ("550-600"), a rent per month, fortnight or year, a decimal comma and
145
+ anything else are refused.
146
+ - `lease_start` is read as "2024-03", "2024-03-01" (a real date; its month is used) or "March 2024" / "Mar 2024".
147
+ - Each refusal names the field and every form that is read. The handler receives the same canonical values as
148
+ before, and tools/list declares the same JSON Schema, byte for byte: 31,159 characters over stdio, 28,451 hosted.
149
+
150
+ ### A name in several NSW postcodes, and a registry icon (from 0.13.0)
151
+
152
+ - `area_rents` (state NSW), `property_rents` and `rent_check`'s local mode refuse an NSW name the NSW suburb list
153
+ places in more than one postcode as a name held in more than one state is refused, all three in the same words:
154
+ `"Alison" is held in more than one postcode: 2259, 2420`, every postcode listed and none chosen. The next step's
155
+ example is one postcode alone, offered only where DCJ's file publishes a median for it, so each of the three answers
156
+ it with a figure: of those, the one with the most new bonds (a banded count by its lower end; a tie by the list's
157
+ order). A postcode with no median or no row is listed and said to have no figure; where none has a median, none is
158
+ offered and the next step says so. Until 0.13.0 the refusal said `No New South Wales postcode matches "Alison"` and
159
+ named the postcodes only in its next step. Refusals are text; no field and no tool description changes, so
160
+ tools/list is as in 0.12.0.
161
+ - The registry entry (`server.json`) lists an icon: https://tools.dwelldelta.com.au/mcp/icon-256.png, the DwellDelta
162
+ mark, 256x256 PNG.
163
+ - The hosted server answers a POST whose Accept allows JSON (`application/json`, `application/*` or `*/*`) but does
164
+ not list `text/event-stream`, in JSON as always; it was refused 406. An Accept that does not allow JSON is still 406.
165
+ - The hosted server's log lines name four more MCP methods (`server/discover`, `resources/read`, `prompts/get`,
166
+ `subscriptions/listen`) where they said "other". No field is added; the line holds what the privacy notice says.
167
+
137
168
  ### Answers on the first call, pages and citations (from 0.12.0)
138
169
 
139
170
  - A NSW suburb's name is answered on the first call where the NSW suburb list (NSW Spatial Services, CC BY 3.0 AU)
@@ -195,6 +195,56 @@ export function nswResolve(wanted, suburbs, feed) {
195
195
  `postcode, not ${suburb} alone.` };
196
196
  }
197
197
 
198
+ /** A name and its "Mt"/"Mount" twin: the files spell it one way ("Mount Victoria"), an asker often the other. */
199
+ export const spellings = (name) => {
200
+ const n = norm(name);
201
+ return new Set([n, n.replace(/\bmt\.?\s/g, "mount "), n.replace(/\bmount\s/g, "mt ")]);
202
+ };
203
+
204
+ /**
205
+ * An NSW name the suburb list places in more than one postcode ("Alison": 2259 and 2420), as a ToolError that says so
206
+ * and lists every one, none chosen - or null for a name in one postcode or none (0.13.0). Until then area_rents said
207
+ * "No New South Wales postcode matches "Alison"" and named the postcodes only in its next step. One check for the
208
+ * three tools that take an NSW name: area_rents here, and property_rents and rent_check's local mode through
209
+ * resolvePlace (place-tool.mjs), so all three refuse in the same words.
210
+ *
211
+ * The next step's example is one postcode alone, and only one whose row in DCJ's file has a published median, so
212
+ * that each of the three tools answers it with a figure (the cold review of #80: offering the first postcode with a
213
+ * row sent rent_check to a postcode with no median for 9 of 79 names). Of those, the RULE is: the most new bonds; a
214
+ * count DCJ gives only as a band ("10 to 30") ranks by its lower end; a tie goes to the list's order. A postcode with
215
+ * a row but no median, or with no row, is listed and said to have no figure, and never offered; where no postcode has
216
+ * a median, none is offered and the next step says so.
217
+ */
218
+ export const medianOf = (r) => (isRecord(r) && typeof r.median_weekly_rent_aud === "number" &&
219
+ Number.isFinite(r.median_weekly_rent_aud) && r.median_weekly_rent_aud > 0 ? r.median_weekly_rent_aud : null);
220
+ const bondsOf = (r) => (typeof r.new_bonds === "number" && Number.isFinite(r.new_bonds) ? r.new_bonds
221
+ : Number(/^\d+/.exec(String(r.new_bonds_band ?? r.new_bonds_range ?? ""))?.[0] ?? 0));
222
+ const postcodes = (list) => `${list.length > 1 ? "postcodes" : "postcode"} ${list.join(", ")}`;
223
+
224
+ export function nswSeveralPostcodes(name, suburbs, feed) {
225
+ const want = spellings(name);
226
+ const exact = suburbs.map((s) => /^(.*) \((\d{4})\)$/.exec(String(s))).filter((m) => m && want.has(norm(m[1])));
227
+ const codes = [...new Set(exact.map((m) => m[2]))];
228
+ if (codes.length < 2) return null;
229
+ const rows = new Map((feed?.areas ?? []).filter(isRecord).map((r) => [String(r.area), r]));
230
+ const priced = codes.filter((p) => medianOf(rows.get(p)) != null);
231
+ const unpriced = codes.filter((p) => rows.has(p) && medianOf(rows.get(p)) == null);
232
+ const rowless = codes.filter((p) => !rows.has(p));
233
+ const offer = priced.reduce((best, p) => (bondsOf(rows.get(p)) > bondsOf(rows.get(best)) ? p : best), priced[0]);
234
+ const next = offer
235
+ ? `Ask again with one postcode, e.g. ${JSON.stringify(offer)} (of those with a published median, the one with the ` +
236
+ "most new bonds), or ask which one is meant. No one of them is chosen here; a postcode's figure is for the whole " +
237
+ `postcode, not ${exact[0][1]} alone.` +
238
+ (unpriced.length ? ` DCJ's file publishes no median for ${postcodes(unpriced)}, so ` +
239
+ `${unpriced.length > 1 ? "they have" : "it has"} no figure here.` : "") +
240
+ (rowless.length ? ` DCJ's rents file has no row for ${postcodes(rowless)}, so ` +
241
+ `${rowless.length > 1 ? "they have" : "it has"} no figure here.` : "")
242
+ : "No one of them is chosen here, and none is offered: DCJ's file publishes no median for any of them, so none " +
243
+ "has a figure here.";
244
+ return new ToolError(`${JSON.stringify(String(name).trim())} is held in more than one postcode: ${codes.join(", ")} ` +
245
+ `(${SUBURB_LIST_CREDIT}).`, next);
246
+ }
247
+
198
248
  /** The note when a resolved suburb's name is also a council's: the council's figure is a call of its own. */
199
249
  export function councilToo(wanted, councils) {
200
250
  const c = (councils ?? []).filter(isRecord).find((r) => norm(r.council) === norm(wanted));
@@ -234,6 +284,9 @@ export function areaRentsResult({ state, area, council, dwelling_type, bedrooms
234
284
  areas = match(feed.areas, "area", resolved.postcode);
235
285
  resolved.note += council == null || !String(council).trim() ? councilToo(area, feed.councils) : "";
236
286
  }
287
+ // A name in several postcodes is refused as such, never as a name with no match (0.13.0).
288
+ const several = resolved ? null : nswSeveralPostcodes(area, nswSuburbs, feed);
289
+ if (several) throw several;
237
290
  }
238
291
  if (!areas.length) {
239
292
  const named = state === "NSW" ? nswPostcodes(area, nswSuburbs, feed) : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dwelldelta-mcp",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Australian rents by area for five states, 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
@@ -18,7 +18,7 @@
18
18
  */
19
19
  import { z } from "zod";
20
20
  import { isRecord, ToolError } from "./tools.mjs";
21
- import { areaRentsResult, STATES, norm, wantsByType, dollars } from "./area-rents-tool.mjs";
21
+ import { areaRentsResult, STATES, norm, wantsByType, dollars, spellings, nswSeveralPostcodes } from "./area-rents-tool.mjs";
22
22
  import { vicRentsResult } from "./vic-rents-tool.mjs";
23
23
  import { OUTPUT_SCHEMAS } from "./output-schemas.mjs";
24
24
 
@@ -77,12 +77,6 @@ export function postcodeState(postcode) {
77
77
  return null;
78
78
  }
79
79
 
80
- /** A name and its "Mt"/"Mount" twin: the files spell it one way ("Mount Victoria"), an asker often the other. */
81
- const spellings = (name) => {
82
- const n = norm(name);
83
- return new Set([n, n.replace(/\bmt\.?\s/g, "mount "), n.replace(/\bmount\s/g, "mt ")]);
84
- };
85
-
86
80
  /** Every held place of exactly this name, by state: [{ state, area | suburb_group, postcodes?, label }]. */
87
81
  export function placeCandidates(name, { suburbs = [], areaRents = {}, vic = null } = {}) {
88
82
  if (!norm(name)) return [];
@@ -182,6 +176,9 @@ export function resolvePlace(raw, data) {
182
176
  "which one is meant. No one of them is chosen here.");
183
177
  }
184
178
  const c = pick[0];
179
+ // A name in several NSW postcodes: area_rents's own refusal (nswSeveralPostcodes), so the three tools say it alike.
180
+ const several = c.state === "NSW" ? nswSeveralPostcodes(name, data.suburbs ?? [], data.areaRents?.NSW) : null;
181
+ if (several) throw several;
185
182
  // Outside NSW the feeds are by name: a postcode given with the name has only said which state it is in.
186
183
  const byName = postcode ? ` (postcode ${postcode} read for its state only; this feed is by name)` : "";
187
184
  if (c.state === "VIC") {
@@ -74,6 +74,89 @@ export const guard = (fn) => async (args) => {
74
74
  return fail(err instanceof ToolError ? err : new ToolError(err.message, "Report this to lingtao@xcelerent.com."));
75
75
  }
76
76
  };
77
+ /**
78
+ * rent_check's inputs in the shapes agents send them (2026-11-03: the hosted logs held 4 of 4 genuine rent_check
79
+ * calls refused; the logs keep no arguments, so the cause is inferred - a lower-case city, a rent sent as text, a
80
+ * full date). Each reader returns the canonical value the handler has always received (a city as the index names it,
81
+ * a number, "YYYY-MM"), or the input unchanged, which the schema then refuses in words that name every accepted form,
82
+ * so a second call can be right. Nothing ambiguous is read: a range, a rent that is not weekly, a day that is not a
83
+ * real date, a state for its capital city. Used through z.preprocess, so tools/list declares the same JSON Schema as before (the canonical form).
84
+ */
85
+ // Each state and territory: its names as read after a city ("Sydney, NSW"), its capital, and what place takes there
86
+ // (null where no local rents are held: SERVER_INSTRUCTIONS' "Not held"). A state alone is never read as its capital:
87
+ // a regional tenant's "NSW" would get Sydney's index without a word (the coordinator's review of #87, 2026-11-03).
88
+ const STATES_OF = [
89
+ ["NSW", "New South Wales", "Sydney", "a NSW postcode or suburb"], ["VIC", "Victoria", "Melbourne", "a Victorian suburb"],
90
+ ["QLD", "Queensland", "Brisbane", "a Queensland suburb"], ["SA", "South Australia", "Adelaide", "an SA suburb"],
91
+ ["WA", "Western Australia", "Perth", "a WA locality"], ["TAS", "Tasmania", "Hobart", null],
92
+ ["NT", "the Northern Territory", "Darwin", null], ["ACT", "the Australian Capital Territory", "Canberra", null],
93
+ ].map(([abbr, name, capital, place]) => ({ abbr, name, capital, place,
94
+ keys: [abbr, name.replace(/^the /, "").toUpperCase()] }));
95
+ const stateNamed = (s) => STATES_OF.find((st) => st.keys.includes(s.replace(/^THE /, "")));
96
+ const normCity = (v) => v.trim().replace(/\s+/g, " ").toUpperCase();
97
+ /** A capital city in any case, "Greater Sydney", or "Sydney, NSW" (the state must be its own). Never a state alone. */
98
+ export const readCity = (cities) => (v) => {
99
+ if (typeof v !== "string") return v;
100
+ const named = new Map(cities.map((c) => [c.toUpperCase(), c]));
101
+ const city = (t) => named.get(t.replace(/^GREATER /, ""));
102
+ const s = normCity(v);
103
+ if (city(s)) return city(s);
104
+ for (const st of STATES_OF) {
105
+ for (const key of st.keys) {
106
+ const head = s.endsWith(` ${key}`) || s.endsWith(`,${key}`) ? s.slice(0, -key.length).replace(/[ ,]+$/, "") : "";
107
+ if (head && city(head) === st.capital) return st.capital;
108
+ }
109
+ }
110
+ return v;
111
+ };
112
+ /** The refusal: for a state or territory, its capital and what place takes there; otherwise every capital. */
113
+ export const cityRefusal = (cities) => (issue) => {
114
+ const st = typeof issue.input === "string" ? stateNamed(normCity(issue.input)) : undefined;
115
+ if (st && cities.includes(st.capital)) {
116
+ return `city takes a capital city: the ABS rents index exists only for capitals. For ${st.name} use ` +
117
+ `"${st.capital}"; ` + (st.place ? `for a regional place, give place (${st.place}) for the local rent check.`
118
+ : `local rents for ${st.name} are not held.`);
119
+ }
120
+ return `city takes a capital city, in any case: ${cities.join(", ")} ("Greater Sydney" and "Sydney, NSW" are read ` +
121
+ "too). The ABS rents index exists only for capitals: for a place outside one, leave lease_start and city out and " +
122
+ "give place (a postcode or suburb in NSW, Victoria, Queensland, WA or SA) for the local rent check.";
123
+ };
124
+
125
+ const WEEKLY = /^(?:p\.? ?w\.?|\/ ?(?:w|wk|week)|per week|a week|weekly)$/i;
126
+ /** A weekly rent: 550, "550", "$550", "A$550", "AUD 550", "550.00", "$1,250", "550 pw", "550 per week", "$550/wk". */
127
+ export function readRent(v) {
128
+ if (typeof v !== "string") return v;
129
+ const m = /^\s*(?:A?\$|AUD ?)? ?(\d{1,3}(?:,\d{3})+|\d+)(\.\d{1,2})?\s*(.*?)\s*$/i.exec(v);
130
+ if (!m || (m[3] && !WEEKLY.test(m[3].replace(/\s+/g, " ")))) return v;
131
+ return Number(m[1].replace(/,/g, "") + (m[2] ?? ""));
132
+ }
133
+ export const rentRefusal = (field) => `${field} is a weekly rent in Australian dollars, more than 0: a number such as ` +
134
+ "550, or text such as \"550\", \"$550\", \"550.00\", \"$1,250\" or \"550 pw\". A range (\"550-600\") or a rent " +
135
+ "per month, fortnight or year is not read: give one weekly figure.";
136
+
137
+ const MONTH_NAMES = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october",
138
+ "november", "december"];
139
+ /** A month: "2024-03"; "2024-03-01" (a real date; its month is used); "March 2024", "Mar 2024" or "Sept 2024". */
140
+ export function readMonth(v) {
141
+ if (typeof v !== "string") return v;
142
+ const s = v.trim();
143
+ const iso = /^(\d{4})-(0[1-9]|1[0-2])(?:-(\d{2}))?$/.exec(s);
144
+ if (iso) {
145
+ const lastDay = new Date(Date.UTC(Number(iso[1]), Number(iso[2]), 0)).getUTCDate();
146
+ return iso[3] == null || (Number(iso[3]) >= 1 && Number(iso[3]) <= lastDay) ? `${iso[1]}-${iso[2]}` : v;
147
+ }
148
+ const named = /^([A-Za-z]+)\.?,?\s+(\d{4})$/.exec(s);
149
+ if (named) {
150
+ const word = named[1].toLowerCase();
151
+ const i = MONTH_NAMES.findIndex((n) => n === word || n.slice(0, 3) === word || (word === "sept" && n === "september"));
152
+ if (i >= 0) return `${named[2]}-${String(i + 1).padStart(2, "0")}`;
153
+ }
154
+ return v;
155
+ }
156
+ export const MONTH_REFUSAL = "lease_start is the month the lease began, as \"2024-03\" (YYYY-MM), \"2024-03-01\" " +
157
+ "(YYYY-MM-DD, a real date; its month is used) or \"March 2024\" (a month's name or its first three letters, then " +
158
+ "the year).";
159
+
77
160
  /** An answer with a first line naming the arguments it did not use, and why (0.12.0, rent_check's two modes). */
78
161
  const ignoring = (res, keys, why) => (keys.length ? { text: `Not used: ${keys.join(", ")} (${why}).\n${res.text}`,
79
162
  structured: { ...res.structured, ignored: keys } } : res);
@@ -153,6 +236,7 @@ export function registerReadOnlyTools(server, data, { byTypeWaitMs = null, hoste
153
236
  }
154
237
  return snapshot;
155
238
  };
239
+ const cities = Object.keys(rents.cities).sort();
156
240
 
157
241
  server.registerTool("rent_check", titled({
158
242
  title: "Australian rent check",
@@ -163,10 +247,13 @@ export function registerReadOnlyTools(server, data, { byTypeWaitMs = null, hoste
163
247
  "NSW, Victoria, Queensland, WA or SA) gives instead where the rent sits against that place's median of new " +
164
248
  "bonds, and between its quartiles where the publisher gives them.",
165
249
  inputSchema: {
166
- city: z.enum(Object.keys(rents.cities).sort()).optional().describe("Capital city whose ABS rents index the rent is compared with (with lease_start)"),
167
- lease_start: z.string().regex(/^\d{4}-(0[1-9]|1[0-2])$/).optional().describe("Month the lease began, YYYY-MM"),
168
- current_rent: z.number().positive().describe("Current weekly rent in Australian dollars"),
169
- proposed_rent: z.number().positive().optional().describe("Proposed new weekly rent in Australian dollars"),
250
+ // Each is read through z.preprocess (readCity, readMonth, readRent above): tools/list still declares the
251
+ // canonical form, byte for byte (current_rent's description sits inside, where it keeps its place in the JSON
252
+ // Schema), and the handler still receives it; the refusals name every form that is read.
253
+ city: z.preprocess(readCity(cities), z.enum(cities, { error: cityRefusal(cities) })).optional().describe("Capital city whose ABS rents index the rent is compared with (with lease_start)"),
254
+ lease_start: z.preprocess(readMonth, z.string({ error: MONTH_REFUSAL }).regex(/^\d{4}-(0[1-9]|1[0-2])$/, { error: MONTH_REFUSAL })).optional().describe("Month the lease began, YYYY-MM"),
255
+ current_rent: z.preprocess(readRent, z.number({ error: rentRefusal("current_rent") }).positive({ error: rentRefusal("current_rent") }).describe("Current weekly rent in Australian dollars")),
256
+ proposed_rent: z.preprocess(readRent, z.number({ error: rentRefusal("proposed_rent") }).positive({ error: rentRefusal("proposed_rent") })).optional().describe("Proposed new weekly rent in Australian dollars"),
170
257
  place: z.string().optional().describe("Without lease_start: a suburb, locality or postcode; a state may follow (\"Richmond, VIC\")"),
171
258
  dwelling_type: z.string().optional().describe("With place: as area_rents (NSW and QLD only)"),
172
259
  bedrooms: z.string().optional().describe("With place: as area_rents (NSW and QLD only)"),
package/tools.mjs CHANGED
@@ -112,7 +112,7 @@ export async function loadSnapshot({ env = process.env, fetchImpl = globalThis.f
112
112
  }
113
113
 
114
114
  export const FOOTER = "Information, not advice. From DwellDelta (dwelldelta.com.au), built on public data.";
115
- export const SERVER_VERSION = "0.12.0";
115
+ export const SERVER_VERSION = "0.13.0";
116
116
  // The indicators snapshot is rebuilt every Monday. Older than this and the answer says so, in words and in the
117
117
  // structured result, rather than serving a stale figure as current.
118
118
  export const STALE_DAYS = 10;