dwelldelta-mcp 0.5.0 → 0.7.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/LICENSE CHANGED
@@ -20,8 +20,15 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
22
 
23
- The data files in vendor/ (rents-index.json, indicators.json, nsw-suburbs.json, vic-rents.json) are
23
+ The data files in vendor/ (rents-index.json, indicators.json, nsw-suburbs.json, vic-rents.json,
24
+ nsw-rents.json, qld-rents.json, wa-rents.json, nsw-sales.json) are
24
25
  not covered by this licence. Each figure keeps its source's own licence and
25
26
  attribution, which the data files and every answer state (for example, ABS data:
26
27
  CC BY 4.0, "Based on Australian Bureau of Statistics data"; the NSW suburb list:
27
- CC BY 3.0 AU, NSW Spatial Services; Victorian rents: CC BY 4.0, Homes Victoria).
28
+ CC BY 3.0 AU, NSW Spatial Services; Victorian rents: CC BY 4.0, Homes Victoria;
29
+ NSW rents: CC BY 4.0, State of New South Wales (Department of Communities and
30
+ Justice); Queensland rents: CC BY 4.0, The State of Queensland (Residential
31
+ Tenancies Authority); WA rents: based on WA Rental Bonds Data, CC BY 4.0,
32
+ Government of Western Australia, with medians calculated by DwellDelta;
33
+ NSW sale prices: CC BY 4.0, State of New South Wales (Department of
34
+ Communities and Justice)).
package/README.md CHANGED
@@ -1,16 +1,18 @@
1
1
  # dwelldelta-mcp - is an Australian rent fair?
2
2
 
3
- An MCP server that lets an AI assistant check a weekly rent against the ABS rents index, and quote sourced
4
- Australian property and lending indicators. From [DwellDelta](https://dwelldelta.com.au/), a service of
5
- Xcelerent Pty Ltd, built on public data.
3
+ An MCP server that lets an AI assistant check a weekly rent against the ABS rents index, look up median rents
4
+ by area in four states and NSW median sale prices, and quote sourced Australian property and lending indicators. From
5
+ [DwellDelta](https://dwelldelta.com.au/), a service of Xcelerent Pty Ltd, built on public data.
6
6
 
7
- Three read-only tools, and one that adds the user's own rent when they ask:
7
+ Six read-only tools, and one that adds the user's own rent when they ask:
8
8
 
9
9
  | Tool | What it answers |
10
10
  |---|---|
11
11
  | `rent_check` | a weekly rent, and any proposed new rent, against the ABS rents index for the capital city since the lease began (the same arithmetic as the rent check at tools.dwelldelta.com.au) |
12
12
  | `market_indicators` | the latest RBA cash rate, unemployment, wage growth, rents for all eight capitals, NSW lending, lending standards and arrears, approvals and completions - each with period, source, licence and limits; filter by `geography` |
13
13
  | `vic_rents` | Victorian rents by suburb group from Homes Victoria's Rental Report: the median weekly rent of new leases, the lease count and the change on a year before, for 146 suburb groups and 13 regions; filter by `suburb_group` or `region` (from 0.5.0) |
14
+ | `area_rents` | median weekly rent of new bonds, all dwellings together, with the bond count and the change on a year before, for one state per call: NSW by postcode or council (NSW Department of Communities and Justice), Queensland by suburb or council (Residential Tenancies Authority), WA by locality (calculated by DwellDelta from the Government of Western Australia's bond records); each CC BY 4.0 (from 0.6.0) |
15
+ | `nsw_sale_prices` | NSW median sale prices by postcode or council from the NSW Department of Communities and Justice's Rent and Sales Report (CC BY 4.0): the median, the quartiles, the number of sales and the change on a year before, each for all dwellings, houses (non-strata) and units and town houses (strata). Medians of homes sold - never what any one home sold for; a line a few very large sales have set is marked UNUSUAL (from 0.7.0) |
14
16
  | `data_sources` | the sources, their licences, and what DwellDelta cannot answer |
15
17
  | `contribute_rent` | adds the user's own rent, anonymously, to DwellDelta's suburb benchmarks - only when the user asks, and only after they have read and agreed to the consent wording (from 0.5.0) |
16
18
 
@@ -30,6 +32,17 @@ property you own - never an address, name or email. You get a deletion code; ema
30
32
  and the record is deleted. Only your own rent may be added: an assistant must not add a figure it read on a
31
33
  website or a listing.
32
34
 
35
+ ## NSW sale prices (from 0.7.0)
36
+
37
+ `nsw_sale_prices` gives DCJ's medians for the dwellings sold in a quarter - not asking prices, not valuations,
38
+ and never the price or value of any one home; no individual sale is in the data. Every answer names the dwelling
39
+ type, because a sale price without it answers nobody's question, and carries the quarter, DCJ's source line and
40
+ its limits. DCJ reports a quarter when about 80% of its sales have been notified, so the counts are incomplete
41
+ and the sales quarter runs behind the rents quarter. DCJ's own table has rows that a few very large sales, or
42
+ many sales at one identical price, have set: the answer marks those lines UNUSUAL and says not to quote them as
43
+ a going price. Prices in the structured result stay in DCJ's unit, thousands of dollars, and `unit` says so.
44
+ The feed is public at <https://tools.dwelldelta.com.au/market/nsw-sales.json>.
45
+
33
46
  ## Use it
34
47
 
35
48
  Claude Desktop - add to `claude_desktop_config.json`:
@@ -48,8 +61,20 @@ Claude Desktop - add to `claude_desktop_config.json`:
48
61
  Claude Code: `claude mcp add dwelldelta -- npx -y dwelldelta-mcp`. Any other MCP client: run `npx -y dwelldelta-mcp`
49
62
  as a stdio server. Node 18 or later.
50
63
 
51
- Then ask: "Is a rise from $700 to $770 a week in Sydney since July 2025 in line with rents?" or "What is NSW
52
- unemployment doing?"
64
+ Then ask: "Is a rise from $700 to $770 a week in Sydney since July 2025 in line with rents?", "What is the
65
+ median rent of new leases in postcode 2148?" or "What is NSW unemployment doing?"
66
+
67
+ ## Rents by area (from 0.6.0)
68
+
69
+ `area_rents` answers for one state at a time, because the three publishers measure in their own ways and the WA
70
+ medians are DwellDelta's own calculation from the Government's one-record-per-bond data. They must not be added
71
+ or ranked as one series. Every answer carries that state's quarter, its source line, what DwellDelta selected or
72
+ calculated, and its limits. These are medians of new bonds, all dwellings together - not advertised rents, not
73
+ what sitting tenants pay, and not the rent of a home of a given size. Where a publisher reports nothing for a
74
+ small area the answer says so; it never shows a zero. The feeds are public at
75
+ https://tools.dwelldelta.com.au/market/nsw-rents.json, `qld-rents.json` and `wa-rents.json`; the server reads them
76
+ at start the way it reads the indicators, and `DWELLDELTA_STATE_RENTS_DIR` points it at a folder of copies.
77
+ Victoria, measured differently again, stays in `vic_rents`.
53
78
 
54
79
  It is listed in the MCP registry as `au.com.dwelldelta/dwelldelta`.
55
80
 
@@ -74,6 +99,6 @@ answer states - for example ABS data is CC BY 4.0, "Based on Australian Bureau o
74
99
 
75
100
  ## Development
76
101
 
77
- `npm test` here starts the server and calls the three read-only tools, and the first (consent) call of
102
+ `npm test` here starts the server and calls the six read-only tools, and the first (consent) call of
78
103
  `contribute_rent`, over MCP; the repository's root `npm test` holds the
79
104
  tool answers themselves and checks that `vendor/` matches its sources. `npm pack` runs `scripts/vendor.mjs` first.
@@ -0,0 +1,178 @@
1
+ /**
2
+ * area_rents (0.6.0, 2026-10-10): rents by area for NSW (postcodes and councils, NSW Department of Communities and
3
+ * Justice), Queensland (suburbs and councils, Residential Tenancies Authority) and Western Australia (localities,
4
+ * calculated by DwellDelta from the Government's bond records), as published at
5
+ * tools.dwelldelta.com.au/market/{nsw,qld,wa}-rents.json - each CC BY 4.0, republishable with attribution.
6
+ *
7
+ * One state per call, never pooled: each publisher measures in its own way, and the WA medians are our own
8
+ * calculation, so every answer carries that state's own source line, what was changed, and its limits.
9
+ *
10
+ * Loaded like vic_rents: DWELLDELTA_STATE_RENTS_DIR (a folder holding the three files), else the owner's live store,
11
+ * else the published file (fetched once at start - one public file each; nothing about the user or their questions is
12
+ * sent - and used if well formed, for the right state, and not older than the bundled copy), else the copy bundled at
13
+ * pack time. DWELLDELTA_OFFLINE=1 never fetches. The data changes once a quarter, so every answer states its quarter.
14
+ */
15
+ import { existsSync } from "node:fs";
16
+ import { fileURLToPath } from "node:url";
17
+ import { dirname, join } from "node:path";
18
+ import { loadJson, envelope, ToolError, FOOTER, FETCH_TIMEOUT_MS } from "./tools.mjs";
19
+ import { quarterKey } from "./vic-rents-tool.mjs";
20
+
21
+ const HERE = dirname(fileURLToPath(import.meta.url));
22
+ const LIVE_DIR = join(HERE, "..", "..", "dwelldelta-data", "market");
23
+ export const BUNDLED_DIR = join(HERE, "vendor");
24
+ export const PUBLISHED_BASE = "https://tools.dwelldelta.com.au/market/";
25
+ export const STATES = {
26
+ NSW: { file: "nsw-rents.json", name: "New South Wales",
27
+ hint: "NSW rents are by four-digit postcode (area: \"2148\") or by council (council: \"Blacktown\")." },
28
+ QLD: { file: "qld-rents.json", name: "Queensland",
29
+ hint: "Queensland rents are by suburb, as the RTA names it (area: \"Acacia Ridge\"; part of a name works), " +
30
+ "or by council (council: \"Brisbane\")." },
31
+ WA: { file: "wa-rents.json", name: "Western Australia",
32
+ hint: "WA rents are by locality (area: \"Fremantle\"; part of a name works). There are no councils in the " +
33
+ "bond records." },
34
+ };
35
+ /** Rows shown in one answer; a wider match says how many more there are instead of dropping them silently. */
36
+ export const MAX_ROWS = 25;
37
+
38
+ const wellFormed = (f, state) => f && f.state === state && quarterKey(f.quarter) > 0
39
+ && Array.isArray(f.areas) && f.areas.length > 0 && Array.isArray(f.councils) && Array.isArray(f.regions)
40
+ && f.state_total && Array.isArray(f.limits) && f.licence && f.attribution && f.changes_made;
41
+
42
+ /** One state's feed and where it came from ("env", "live", "published" or "bundled"); { feed: null } if none. */
43
+ export async function loadAreaRents(state, { env = process.env, fetchImpl = globalThis.fetch, liveDir = LIVE_DIR,
44
+ bundledDir = BUNDLED_DIR } = {}) {
45
+ const { file } = STATES[state];
46
+ // A copy that is not this state's feed is no copy: the wrong file under the right name must never answer.
47
+ const read = (path) => loadJson(path).then((f) => (wellFormed(f, state) ? f : null)).catch(() => null);
48
+ if (env.DWELLDELTA_STATE_RENTS_DIR) return { feed: await read(join(env.DWELLDELTA_STATE_RENTS_DIR, file)), origin: "env" };
49
+ if (existsSync(join(liveDir, file))) return { feed: await read(join(liveDir, file)), origin: "live" };
50
+ const shipped = await read(join(bundledDir, file));
51
+ if (env.DWELLDELTA_OFFLINE !== "1" && typeof fetchImpl === "function") {
52
+ try {
53
+ const res = await fetchImpl(PUBLISHED_BASE + file, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
54
+ const got = res.ok ? await res.json() : null;
55
+ if (wellFormed(got, state) && (!shipped || quarterKey(got.quarter) >= quarterKey(shipped.quarter))) {
56
+ return { feed: got, origin: "published" };
57
+ }
58
+ } catch {
59
+ // Offline, blocked or slow: the bundled copy answers, and its quarter says how current it is.
60
+ }
61
+ }
62
+ return { feed: shipped, origin: shipped ? "bundled" : null };
63
+ }
64
+
65
+ /** Every state's feed, loaded together at start: { NSW: feed-with-origin | null, QLD: ..., WA: ... }. */
66
+ export async function loadAllAreaRents(opts) {
67
+ const loaded = await Promise.all(Object.keys(STATES).map((s) => loadAreaRents(s, opts)));
68
+ return Object.fromEntries(Object.keys(STATES).map((s, i) =>
69
+ [s, loaded[i].feed ? { ...loaded[i].feed, origin: loaded[i].origin } : null]));
70
+ }
71
+
72
+ // Exported for sale-prices-tool.mjs (0.7.0), which matches names and words figures the same way.
73
+ export const norm = (s) => String(s).trim().toLowerCase();
74
+ export const dollars = (v) => `$${v.toLocaleString("en-AU")}`;
75
+ export const signed = (v) => `${v >= 0 ? "+" : ""}${v}%`;
76
+
77
+ function line(r, name) {
78
+ if (r.median_weekly_rent_aud == null) {
79
+ const why = r.withheld ?? (r.new_bonds == null ? "too few bonds"
80
+ : `${r.new_bonds} new bond${r.new_bonds === 1 ? "" : "s"} - too few for a median`);
81
+ return `${name}: no median (${why}).`;
82
+ }
83
+ const bonds = r.new_bonds_band ? ` from ${r.new_bonds_band} new bonds (the publisher withholds the count)`
84
+ : r.new_bonds == null ? "" : ` from ${r.new_bonds.toLocaleString("en-AU")} new bonds`;
85
+ const change = r.change_pct == null ? ""
86
+ : r.year_ago_median_aud == null ? `, ${signed(r.change_pct)} on a year before`
87
+ : `, ${signed(r.change_pct)} on ${dollars(r.year_ago_median_aud)} a year before`;
88
+ const spread = r.first_quartile_aud == null || r.third_quartile_aud == null ? ""
89
+ : `; half of new bonds between ${dollars(r.first_quartile_aud)} and ${dollars(r.third_quartile_aud)}`;
90
+ return `${name}: ${dollars(r.median_weekly_rent_aud)} a week${bonds}${change}${spread}` +
91
+ `${r.small_sample ? " (small sample: treat with caution)" : ""}.`;
92
+ }
93
+
94
+ /** Exact name first, so "Brighton" does not drag in "Brighton East"; otherwise every name containing the words. */
95
+ export function match(rows, key, wanted) {
96
+ const exact = rows.filter((r) => norm(r[key]) === norm(wanted));
97
+ return exact.length ? exact : rows.filter((r) => norm(r[key]).includes(norm(wanted)));
98
+ }
99
+
100
+ /**
101
+ * People ask NSW by suburb, and DCJ reports by postcode. For a name that matched no postcode: the suburbs of that name
102
+ * in the NSW suburb list ("Parramatta (2150)", already shipped for contribute_rent), with the postcodes this feed
103
+ * holds - offered as the next step, never answered silently, because a postcode's median is not a suburb's.
104
+ */
105
+ export function nswPostcodes(wanted, suburbs, feed) {
106
+ const held = new Set(feed.areas.map((r) => r.area));
107
+ const named = suburbs.map((s) => /^(.*) \((\d{4})\)$/.exec(s)).filter((m) => m && held.has(m[2]));
108
+ const exact = named.filter((m) => norm(m[1]) === norm(wanted));
109
+ const found = exact.length ? exact : named.filter((m) => norm(m[1]).includes(norm(wanted)));
110
+ return found.slice(0, 5).map((m) => `${m[1]} is in postcode ${m[2]}`);
111
+ }
112
+
113
+ /** area_rents: one state; an area (postcode, suburb or locality), a council, or neither for the state's own row. */
114
+ export function areaRentsResult({ state, area, council } = {}, feeds, now = new Date(), { nswSuburbs = [] } = {}) {
115
+ const info = STATES[state];
116
+ if (!info) {
117
+ throw new ToolError(`No area rents for ${JSON.stringify(state)}.`,
118
+ `Call area_rents with state NSW, QLD or WA. Victoria is in vic_rents; South Australia, Tasmania, the ACT and ` +
119
+ `the Northern Territory are not covered.`);
120
+ }
121
+ const feed = feeds[state];
122
+ if (!feed) {
123
+ throw new ToolError(`The ${info.name} rents feed is not on this machine.`,
124
+ `Point DWELLDELTA_STATE_RENTS_DIR at a folder holding a copy of ${PUBLISHED_BASE}${info.file}.`);
125
+ }
126
+ const kind = feed.area_kind;
127
+ let areas = [], councils = [], regions = [];
128
+ if (area != null && String(area).trim()) {
129
+ areas = match(feed.areas, "area", area);
130
+ if (!areas.length) {
131
+ const named = state === "NSW" ? nswPostcodes(area, nswSuburbs, feed) : [];
132
+ throw new ToolError(`No ${info.name} ${kind} matches ${JSON.stringify(area)}.`,
133
+ `${info.hint} ${feed.areas.length.toLocaleString("en-AU")} ${kind} rows are held.` +
134
+ (named.length ? ` In the NSW suburb list (NSW Spatial Services, CC BY 3.0 AU): ${named.join("; ")}. Call ` +
135
+ "again with that postcode, and say the figure is for the whole postcode, not the suburb alone." : ""));
136
+ }
137
+ }
138
+ if (council != null && String(council).trim()) {
139
+ councils = match(feed.councils, "council", council);
140
+ if (!councils.length) {
141
+ throw new ToolError(`No ${info.name} council matches ${JSON.stringify(council)}.`,
142
+ feed.councils.length ? `Try part of a council's name; ${feed.councils.length} councils are held. ${info.hint}` : info.hint);
143
+ }
144
+ }
145
+ const whole = !areas.length && !councils.length;
146
+ if (whole) regions = feed.regions;
147
+ const dropped = [];
148
+ for (const [label, rows] of [[kind, areas], ["council", councils]]) {
149
+ if (rows.length > MAX_ROWS) dropped.push(`${rows.length - MAX_ROWS} more ${label} rows match: narrow the name.`);
150
+ }
151
+ areas = areas.slice(0, MAX_ROWS);
152
+ councils = councils.slice(0, MAX_ROWS);
153
+ const env = envelope({ sources: [{ source: feed.source, licence: feed.licence, attribution: feed.attribution }],
154
+ dataAsOf: feed.quarter, origin: feed.origin ?? null }, now);
155
+ const text = [
156
+ `${feed.what}. Quarter: ${feed.quarter}, against ${feed.compared_with}.`,
157
+ "",
158
+ ...(whole ? [line(feed.state_total, `${info.name} (whole state)`)] : []),
159
+ ...regions.map((r) => line(r, `${r.region} (region)`)),
160
+ ...councils.map((r) => line(r, `${r.council} (council)`)),
161
+ ...areas.map((r) => line(r, `${r.area} (${kind})`)),
162
+ ...dropped,
163
+ ...(whole ? ["", `${feed.areas.length.toLocaleString("en-AU")} ${kind} rows` +
164
+ `${feed.councils.length ? ` and ${feed.councils.length} councils` : ""} are available: call again with area` +
165
+ `${feed.councils.length ? " or council" : ""}.`] : []),
166
+ "",
167
+ "Limits:",
168
+ ...feed.limits.map((l) => "- " + l),
169
+ "",
170
+ `Source: ${feed.attribution}`,
171
+ `What DwellDelta changed: ${feed.changes_made}`,
172
+ FOOTER,
173
+ ].join("\n");
174
+ return { text, structured: { ...env, state, state_name: info.name, area_kind: kind, quarter: feed.quarter,
175
+ compared_with: feed.compared_with, derived: feed.derived === true,
176
+ state_total: whole ? feed.state_total : null, regions, councils, areas,
177
+ truncated: dropped.length > 0, limits: feed.limits, changes_made: feed.changes_made } };
178
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dwelldelta-mcp",
3
- "version": "0.5.0",
4
- "description": "Is an Australian rent fair? A rent check on the ABS rents index, plus sourced property and lending indicators, for AI agents.",
3
+ "version": "0.7.0",
4
+ "description": "Is an Australian rent fair? A rent check on the ABS rents index, rents by area for four states, NSW median sale prices, and sourced property and lending indicators, for AI agents.",
5
5
  "mcpName": "au.com.dwelldelta/dwelldelta",
6
6
  "license": "MIT",
7
7
  "homepage": "https://dwelldelta.com.au/",
@@ -23,6 +23,8 @@
23
23
  "tools.mjs",
24
24
  "contribute-tool.mjs",
25
25
  "vic-rents-tool.mjs",
26
+ "area-rents-tool.mjs",
27
+ "sale-prices-tool.mjs",
26
28
  "vendor/",
27
29
  "LICENSE",
28
30
  "README.md"
@@ -0,0 +1,145 @@
1
+ /**
2
+ * nsw_sale_prices (0.7.0): NSW median sale prices by postcode and council, from the NSW Department of Communities and
3
+ * Justice's Rent and Sales Report, sales tables, as published at tools.dwelldelta.com.au/market/nsw-sales.json
4
+ * (CC BY 4.0, republishable with attribution; DCJ's licence re-read for the sales tables on 2026-10-10).
5
+ *
6
+ * Medians of the dwellings SOLD in a quarter, by dwelling type - never the price or value of any one home, and never an
7
+ * individual sale. Three things this tool will not let an agent miss:
8
+ * - a sale price without its dwelling type answers nobody's question, so every area is given as all dwellings,
9
+ * non-strata (separate houses) and strata (units, town houses, villas), each labelled;
10
+ * - DCJ's own table has rows that a few unusual sales set (postcode 2034, strata, March 2026: $8.954m, up 478%, from
11
+ * 184 sales). The feed marks them `unusual_prices`; the answer says UNUSUAL in words, on that line, with the reason;
12
+ * - a gap is said with its reason and is never shown as zero.
13
+ *
14
+ * The feed keeps DCJ's unit (thousands of dollars) and so does the structured result, which says so; the text writes
15
+ * the same figure out in dollars, to the thousand DCJ reports.
16
+ *
17
+ * Loaded like the rents feeds: DWELLDELTA_STATE_RENTS_DIR (a folder holding copies of the feeds), else the owner's
18
+ * live store, else the published file (fetched once at start - one public file; nothing about the user or their
19
+ * questions is sent - and used if well formed and not older than the bundled copy), else the copy bundled at pack
20
+ * time. DWELLDELTA_OFFLINE=1 never fetches.
21
+ */
22
+ import { existsSync } from "node:fs";
23
+ import { fileURLToPath } from "node:url";
24
+ import { dirname, join } from "node:path";
25
+ import { loadJson, envelope, ToolError, FOOTER, FETCH_TIMEOUT_MS } from "./tools.mjs";
26
+ import { quarterKey } from "./vic-rents-tool.mjs";
27
+ import { signed, match, nswPostcodes, MAX_ROWS, BUNDLED_DIR, PUBLISHED_BASE } from "./area-rents-tool.mjs";
28
+
29
+ const HERE = dirname(fileURLToPath(import.meta.url));
30
+ const LIVE_DIR = join(HERE, "..", "..", "dwelldelta-data", "market");
31
+ export const SALES_FILE = "nsw-sales.json";
32
+ export const DWELLING_TYPES = ["total", "non_strata", "strata"];
33
+ const LABEL = { total: "all dwellings", non_strata: "houses (non-strata)", strata: "units and town houses (strata)" };
34
+ const HINT = "NSW sale prices are by four-digit postcode (area: \"2148\") or by council (council: \"Blacktown\").";
35
+
36
+ const wellFormed = (f) => f && f.state === "NSW" && f.measure === "sale_price" && quarterKey(f.quarter) > 0
37
+ && Array.isArray(f.areas) && f.areas.length > 0 && Array.isArray(f.councils) && f.state_total?.total
38
+ && Array.isArray(f.limits) && f.licence && f.attribution && f.changes_made && f.unit;
39
+
40
+ /** The feed and where it came from ("env", "live", "published" or "bundled"); { feed: null } if none can be read. */
41
+ export async function loadNswSales({ env = process.env, fetchImpl = globalThis.fetch, liveDir = LIVE_DIR,
42
+ bundledDir = BUNDLED_DIR } = {}) {
43
+ // A rents feed saved under this name is no sales feed: `measure` must say sale_price or the copy does not answer.
44
+ const read = (path) => loadJson(path).then((f) => (wellFormed(f) ? f : null)).catch(() => null);
45
+ if (env.DWELLDELTA_STATE_RENTS_DIR) return { feed: await read(join(env.DWELLDELTA_STATE_RENTS_DIR, SALES_FILE)), origin: "env" };
46
+ if (existsSync(join(liveDir, SALES_FILE))) return { feed: await read(join(liveDir, SALES_FILE)), origin: "live" };
47
+ const shipped = await read(join(bundledDir, SALES_FILE));
48
+ if (env.DWELLDELTA_OFFLINE !== "1" && typeof fetchImpl === "function") {
49
+ try {
50
+ const res = await fetchImpl(PUBLISHED_BASE + SALES_FILE, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
51
+ const got = res.ok ? await res.json() : null;
52
+ if (wellFormed(got) && (!shipped || quarterKey(got.quarter) >= quarterKey(shipped.quarter))) {
53
+ return { feed: got, origin: "published" };
54
+ }
55
+ } catch {
56
+ // Offline, blocked or slow: the bundled copy answers, and its quarter says how current it is.
57
+ }
58
+ }
59
+ return { feed: shipped, origin: shipped ? "bundled" : null };
60
+ }
61
+
62
+ /** 1033 (thousands, as DCJ reports) -> "$1,033,000". */
63
+ const price = (k) => `$${(k * 1000).toLocaleString("en-AU")}`;
64
+
65
+ function line(r, name, type) {
66
+ const label = `${name}, ${LABEL[type]}`;
67
+ if (r == null) return `${label}: no row in DCJ's table.`;
68
+ if (r.median_price_k_aud == null) return `${label}: no median (${r.withheld ?? "not reported"}).`;
69
+ const sales = r.sales_band ? ` from ${r.sales_band} sales (DCJ withholds the count)`
70
+ : r.sales == null ? "" : ` from ${r.sales.toLocaleString("en-AU")} sales`;
71
+ const change = r.change_pct == null ? "" : `, ${signed(r.change_pct)} on a year before`;
72
+ const spread = r.first_quartile_k_aud == null || r.third_quartile_k_aud == null ? ""
73
+ : `; half of sales between ${price(r.first_quartile_k_aud)} and ${price(r.third_quartile_k_aud)}`;
74
+ return `${label}: median ${price(r.median_price_k_aud)}${sales}${change}${spread}` +
75
+ `${r.small_sample ? " (small sample: treat with caution)" : ""}.` +
76
+ `${r.unusual_prices ? ` UNUSUAL - ${r.unusual_prices}: do not quote this as the going price of a home there.` : ""}`;
77
+ }
78
+
79
+ /** nsw_sale_prices: a postcode, a council, or neither for the state; optionally one dwelling type. */
80
+ export function salePricesResult({ area, council, dwelling_type } = {}, feed, now = new Date(), { nswSuburbs = [] } = {}) {
81
+ if (!feed) {
82
+ throw new ToolError("The NSW sale prices feed is not on this machine.",
83
+ `Point DWELLDELTA_STATE_RENTS_DIR at a folder holding a copy of ${PUBLISHED_BASE}${SALES_FILE}.`);
84
+ }
85
+ if (dwelling_type != null && !DWELLING_TYPES.includes(dwelling_type)) {
86
+ throw new ToolError(`No dwelling type ${JSON.stringify(dwelling_type)}.`,
87
+ `Use one of ${DWELLING_TYPES.join(", ")} - or leave it out for all three.`);
88
+ }
89
+ const types = dwelling_type ? [dwelling_type] : DWELLING_TYPES;
90
+ let areas = [], councils = [];
91
+ if (area != null && String(area).trim()) {
92
+ areas = match(feed.areas, "area", area);
93
+ if (!areas.length) {
94
+ const named = nswPostcodes(area, nswSuburbs, feed);
95
+ throw new ToolError(`No NSW postcode matches ${JSON.stringify(area)}.`,
96
+ `${HINT} ${feed.areas.length.toLocaleString("en-AU")} postcode rows are held.` +
97
+ (named.length ? ` In the NSW suburb list (NSW Spatial Services, CC BY 3.0 AU): ${named.join("; ")}. Call ` +
98
+ "again with that postcode, and say the figure is for the whole postcode, not the suburb alone." : ""));
99
+ }
100
+ }
101
+ if (council != null && String(council).trim()) {
102
+ councils = match(feed.councils, "council", council);
103
+ if (!councils.length) {
104
+ throw new ToolError(`No NSW council matches ${JSON.stringify(council)}.`,
105
+ `Try part of a council's name; ${feed.councils.length} councils are held. ${HINT}`);
106
+ }
107
+ }
108
+ const whole = !areas.length && !councils.length;
109
+ const dropped = [];
110
+ for (const [label, rows] of [["postcode", areas], ["council", councils]]) {
111
+ if (rows.length > MAX_ROWS) dropped.push(`${rows.length - MAX_ROWS} more ${label} rows match: narrow the name.`);
112
+ }
113
+ areas = areas.slice(0, MAX_ROWS);
114
+ councils = councils.slice(0, MAX_ROWS);
115
+ const shown = [...(whole ? [["New South Wales (whole state)", feed.state_total]] : []),
116
+ ...councils.map((g) => [`${g.council} (council)`, g]), ...areas.map((g) => [`${g.area} (postcode)`, g])];
117
+ const marked = shown.some(([, g]) => types.some((t) => g[t]?.unusual_prices));
118
+ const env = envelope({ sources: [{ source: feed.source, licence: feed.licence, attribution: feed.attribution }],
119
+ dataAsOf: feed.quarter, origin: feed.origin ?? null }, now);
120
+ const text = [
121
+ `${feed.what}. Quarter: ${feed.quarter}, against ${feed.compared_with}. Medians of homes sold - not asking ` +
122
+ "prices, not valuations, and not the price or value of any one home.",
123
+ "",
124
+ ...shown.flatMap(([name, g]) => types.map((t) => line(g[t], name, t))),
125
+ ...dropped,
126
+ ...(whole ? ["", `${feed.areas.length.toLocaleString("en-AU")} postcode rows and ${feed.councils.length} councils ` +
127
+ "are available: call again with area or council."] : []),
128
+ ...(marked ? ["", "At least one row above is marked UNUSUAL: its figure is DCJ's own, and a few very large sales " +
129
+ "or many sales at one identical price have set it. Say so if you mention it."] : []),
130
+ "",
131
+ "Limits:",
132
+ ...feed.limits.map((l) => "- " + l),
133
+ "",
134
+ `Source: ${feed.attribution}`,
135
+ `What DwellDelta changed: ${feed.changes_made}`,
136
+ FOOTER,
137
+ ].join("\n");
138
+ const pick = (g) => Object.fromEntries(Object.entries(g).filter(([k]) => !DWELLING_TYPES.includes(k) || types.includes(k)));
139
+ return { text, structured: { ...env, state: "NSW", measure: "sale_price", unit: feed.unit, area_kind: "postcode",
140
+ quarter: feed.quarter, compared_with: feed.compared_with,
141
+ dwelling_types: feed.dwelling_types ?? null,
142
+ state_total: whole ? pick(feed.state_total) : null,
143
+ councils: councils.map(pick), areas: areas.map(pick), any_unusual: marked,
144
+ truncated: dropped.length > 0, limits: feed.limits, changes_made: feed.changes_made } };
145
+ }
package/server.mjs CHANGED
@@ -2,8 +2,10 @@
2
2
  // DwellDelta MCP server: Australian property market data for AI agents. Runs on the user's machine over stdio and
3
3
  // records nothing unless the user chooses to add their rent. From 0.4.0 it fetches the week's indicators once at start from tools.dwelldelta.com.au - one
4
4
  // public file; nothing about the user or their questions is sent - and falls back to its bundled copy
5
- // (DWELLDELTA_OFFLINE=1 never fetches). Four read-only tools; the logic lives in tools.mjs, and vic_rents
6
- // (Victorian rents by suburb group, 0.5.0) in vic-rents-tool.mjs, loaded the same way. A fourth,
5
+ // (DWELLDELTA_OFFLINE=1 never fetches). Six read-only tools; the logic lives in tools.mjs, vic_rents
6
+ // (Victorian rents by suburb group, 0.5.0) in vic-rents-tool.mjs, area_rents (NSW postcodes, Queensland suburbs
7
+ // and WA localities, 0.6.0) in area-rents-tool.mjs, and nsw_sale_prices (NSW median sale prices by postcode, 0.7.0)
8
+ // in sale-prices-tool.mjs, each feed loaded the same way. A seventh tool,
7
9
  // contribute_rent (contribute-tool.mjs), is connected from 0.5.0 (2026-10-03): it sends a rent only on a second call carrying the user's agreement.
8
10
  //
9
11
  // Every result carries text to quote and a structured result (the figures plus where they come from, under which
@@ -19,6 +21,8 @@ import {
19
21
  } from "./tools.mjs";
20
22
  import { makeContributeTool, INSTRUCTION } from "./contribute-tool.mjs";
21
23
  import { loadVicRents, vicRentsResult } from "./vic-rents-tool.mjs";
24
+ import { loadAllAreaRents, areaRentsResult, STATES } from "./area-rents-tool.mjs";
25
+ import { loadNswSales, salePricesResult, DWELLING_TYPES } from "./sale-prices-tool.mjs";
22
26
  import { HOME_TYPES, BEDROOMS, LEASE_KINDS, WHOSE } from "./vendor/contribute.mjs";
23
27
 
24
28
  const rents = await loadJson(RENTS_PATH);
@@ -28,6 +32,9 @@ const loaded = await loadSnapshot();
28
32
  const snapshot = loaded.snapshot ? { ...loaded.snapshot, origin: loaded.origin } : null;
29
33
  const vicLoaded = await loadVicRents();
30
34
  const vic = vicLoaded.feed ? { ...vicLoaded.feed, origin: vicLoaded.origin } : null;
35
+ const areaRents = await loadAllAreaRents();
36
+ const salesLoaded = await loadNswSales();
37
+ const nswSales = salesLoaded.feed ? { ...salesLoaded.feed, origin: salesLoaded.origin } : null;
31
38
  const readOnly = { readOnlyHint: true, idempotentHint: true, openWorldHint: false, destructiveHint: false };
32
39
 
33
40
  const ok = ({ text, structured }) => ({ content: [{ type: "text", text }], structuredContent: structured });
@@ -78,8 +85,9 @@ server.registerTool("market_indicators", {
78
85
 
79
86
  server.registerTool("data_sources", {
80
87
  title: "What DwellDelta covers",
81
- description: "The sources behind DwellDelta's figures, their licences, and what it cannot answer (individual " +
82
- "sale prices, suburb rents outside Victoria, advice).",
88
+ description: "The sources behind DwellDelta's figures, their licences, and what it cannot answer (what any one " +
89
+ "home sold for, the rent of a single street or home, rents by area outside NSW, Victoria, Queensland and WA, " +
90
+ "sale prices outside NSW, advice).",
83
91
  inputSchema: {},
84
92
  annotations: readOnly,
85
93
  }, guard(() => dataSourcesResult(needSnapshot())));
@@ -103,6 +111,41 @@ server.registerTool("vic_rents", {
103
111
  return vicRentsResult(args, vic);
104
112
  }));
105
113
 
114
+ server.registerTool("area_rents", {
115
+ title: "NSW, Queensland and WA rents by postcode, suburb or locality",
116
+ description: "Median weekly rent of new bonds lodged in the latest quarter, all dwellings together, with the bond " +
117
+ "count and the change on a year before, for one state per call: NSW by postcode or council (NSW Department of " +
118
+ "Communities and Justice), QLD by suburb or council (Residential Tenancies Authority), WA by locality " +
119
+ "(calculated by DwellDelta from the Government of Western Australia's bond records). Each CC BY 4.0. With no " +
120
+ "area or council it gives the state's own figure. New-bond medians, not advertised rents; never add or compare " +
121
+ "the states as one series; quote the quarter, the source line and the limits. Victoria is in vic_rents.",
122
+ inputSchema: {
123
+ state: z.enum(Object.keys(STATES)).describe("NSW, QLD or WA - one state per call"),
124
+ area: z.string().optional().describe("NSW: a four-digit postcode (a suburb name returns its postcodes to try). " +
125
+ "QLD: a suburb. WA: a locality. Part of a suburb or locality name works"),
126
+ council: z.string().optional().describe("A council (NSW or QLD), or part of its name"),
127
+ },
128
+ annotations: readOnly,
129
+ }, guard((args) => areaRentsResult(args, areaRents, new Date(), { nswSuburbs: suburbs })));
130
+
131
+ server.registerTool("nsw_sale_prices", {
132
+ title: "NSW median sale prices by postcode or council",
133
+ description: "Median sale price of the dwellings sold in the latest reported quarter in NSW, with the quartiles, " +
134
+ "the number of sales and the change on a year before, by postcode or council and by dwelling type - all " +
135
+ "dwellings, non_strata (separate houses) and strata (units, town houses, villas). From the NSW Department of " +
136
+ "Communities and Justice's Rent and Sales Report (CC BY 4.0). Medians of homes sold: not asking prices, not " +
137
+ "valuations, and never what any one home sold for or is worth. A line marked UNUSUAL was set by a few very " +
138
+ "large sales - say so, and do not quote it as a going price. Always name the dwelling type, the quarter and " +
139
+ "the source line, and repeat the limits. With no area or council it gives the state's own figures.",
140
+ inputSchema: {
141
+ area: z.string().optional().describe("A four-digit NSW postcode (a suburb name returns its postcodes to try)"),
142
+ council: z.string().optional().describe("An NSW council, or part of its name"),
143
+ dwelling_type: z.enum(DWELLING_TYPES).optional().describe("total, non_strata (houses) or strata (units, town " +
144
+ "houses, villas); leave out for all three"),
145
+ },
146
+ annotations: readOnly,
147
+ }, guard((args) => salePricesResult(args, nswSales, new Date(), { nswSuburbs: suburbs })));
148
+
106
149
  server.registerTool("contribute_rent", {
107
150
  title: "Add the user's own rent (NSW), with their consent",
108
151
  description: "Add the user's own weekly rent, anonymously, to DwellDelta's NSW suburb rents - suburb, home type, " +
package/tools.mjs CHANGED
@@ -62,7 +62,7 @@ export async function loadSnapshot({ env = process.env, fetchImpl = globalThis.f
62
62
  }
63
63
 
64
64
  export const FOOTER = "Information, not advice. From DwellDelta (dwelldelta.com.au), built on public data.";
65
- export const SERVER_VERSION = "0.5.0";
65
+ export const SERVER_VERSION = "0.7.0";
66
66
  // The indicators snapshot is rebuilt every Monday. Older than this and the answer says so, in words and in the
67
67
  // structured result, rather than serving a stale figure as current.
68
68
  export const STALE_DAYS = 10;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "publisher": "DwellDelta, a service of Xcelerent Pty Ltd",
3
- "built": "2026-10-05",
3
+ "built": "2026-10-10",
4
4
  "indicators": [
5
5
  {
6
6
  "id": "cash_rate",
@@ -286,6 +286,96 @@
286
286
  "over": "quarter"
287
287
  }
288
288
  },
289
+ {
290
+ "id": "commercial_property_exposures",
291
+ "name": "Commercial property: loans outstanding, banks and other deposit-takers",
292
+ "geography": "Australia",
293
+ "value": 501.59,
294
+ "unit": "AUD billion",
295
+ "period": "2026-06",
296
+ "source": "APRA Quarterly authorised deposit-taking institution property exposures statistics, all ADIs",
297
+ "licence": "CC BY 3.0 AU",
298
+ "attribution": "Australian Prudential Regulation Authority",
299
+ "change": {
300
+ "value": 8.3,
301
+ "unit": "percent",
302
+ "over": "year"
303
+ },
304
+ "limit": "Commercial property, not housing: what banks and other deposit-takers reporting to APRA have lent against offices, shops, industrial property, land and development - including $67 billion against residential development and investment blocks (APRA's 'other residential') and their lending outside Australia. Non-bank and foreign lenders are left out.",
305
+ "sector": "commercial"
306
+ },
307
+ {
308
+ "id": "commercial_property_office",
309
+ "name": "Commercial property: loans outstanding against office property",
310
+ "geography": "Australia",
311
+ "value": 119.98,
312
+ "unit": "AUD billion",
313
+ "period": "2026-06",
314
+ "source": "APRA Quarterly authorised deposit-taking institution property exposures statistics, all ADIs",
315
+ "licence": "CC BY 3.0 AU",
316
+ "attribution": "Australian Prudential Regulation Authority",
317
+ "change": {
318
+ "value": -0.4,
319
+ "unit": "percent",
320
+ "over": "year"
321
+ },
322
+ "limit": "One part of the commercial property total, not housing; deposit-takers reporting to APRA only.",
323
+ "sector": "commercial"
324
+ },
325
+ {
326
+ "id": "commercial_property_retail",
327
+ "name": "Commercial property: loans outstanding against retail property",
328
+ "geography": "Australia",
329
+ "value": 120.91,
330
+ "unit": "AUD billion",
331
+ "period": "2026-06",
332
+ "source": "APRA Quarterly authorised deposit-taking institution property exposures statistics, all ADIs",
333
+ "licence": "CC BY 3.0 AU",
334
+ "attribution": "Australian Prudential Regulation Authority",
335
+ "change": {
336
+ "value": 7.8,
337
+ "unit": "percent",
338
+ "over": "year"
339
+ },
340
+ "limit": "One part of the commercial property total, not housing; deposit-takers reporting to APRA only.",
341
+ "sector": "commercial"
342
+ },
343
+ {
344
+ "id": "commercial_property_industrial",
345
+ "name": "Commercial property: loans outstanding against industrial property",
346
+ "geography": "Australia",
347
+ "value": 97.77,
348
+ "unit": "AUD billion",
349
+ "period": "2026-06",
350
+ "source": "APRA Quarterly authorised deposit-taking institution property exposures statistics, all ADIs",
351
+ "licence": "CC BY 3.0 AU",
352
+ "attribution": "Australian Prudential Regulation Authority",
353
+ "change": {
354
+ "value": 10.0,
355
+ "unit": "percent",
356
+ "over": "year"
357
+ },
358
+ "limit": "One part of the commercial property total, not housing; deposit-takers reporting to APRA only.",
359
+ "sector": "commercial"
360
+ },
361
+ {
362
+ "id": "commercial_property_npl",
363
+ "name": "Commercial property: non-performing loans, share of loans outstanding",
364
+ "geography": "Australia",
365
+ "value": 0.56,
366
+ "unit": "percent",
367
+ "period": "2026-06",
368
+ "source": "APRA Quarterly authorised deposit-taking institution property exposures statistics, all ADIs",
369
+ "licence": "CC BY 3.0 AU",
370
+ "attribution": "Australian Prudential Regulation Authority",
371
+ "change": {
372
+ "value": -0.07,
373
+ "unit": "points",
374
+ "over": "quarter"
375
+ },
376
+ "limit": "Share of the commercial property loans outstanding that are non-performing, from APRA's two amounts; not the housing figure of the same name.",
377
+ "sector": "commercial"
378
+ },
289
379
  {
290
380
  "id": "approvals",
291
381
  "name": "Dwellings approved, seasonally adjusted",