dwelldelta-mcp 0.3.1 → 0.4.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
@@ -12,8 +12,10 @@ Three read-only tools:
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
  | `data_sources` | the sources, their licences, and what DwellDelta cannot answer |
14
14
 
15
- It runs on your own machine over stdio, sends nothing anywhere and records nothing. Nothing it says is a
16
- forecast, a valuation or advice.
15
+ It runs on your own machine over stdio and records nothing. At start it fetches the week's indicators from
16
+ tools.dwelldelta.com.au - one request for one public file; nothing about you or your questions is sent - and
17
+ otherwise uses the copy it ships with. Set `DWELLDELTA_OFFLINE=1` and it makes no request at all. Nothing it says is
18
+ a forecast, a valuation or advice.
17
19
 
18
20
  ## Use it
19
21
 
@@ -41,12 +43,16 @@ It is listed in the MCP registry as `au.com.dwelldelta/dwelldelta`.
41
43
  ## What an agent gets back
42
44
 
43
45
  Every call returns text to quote and a structured result: the figures, plus `sources` (each with its licence and
44
- attribution), `data_as_of`, `snapshot_built`, `server_version`, `retrieved_at`, and `stale` / `stale_reason`.
46
+ attribution), `data_as_of`, `snapshot_built`, `snapshot_origin` (`published` for this week's file from
47
+ tools.dwelldelta.com.au, `bundled` for the copy in the package), `server_version`, `retrieved_at`, and `stale` /
48
+ `stale_reason`.
45
49
  Every failure is marked `isError` and ends with `Next step:` - an unknown city or geography names the valid ones.
46
50
 
47
- The indicators are a snapshot bundled with each release. Once it is more than 10 days old every answer says so, in
48
- words and in the structured result, rather than passing an old figure off as current; update the package for a
49
- newer one. Set `DWELLDELTA_INDICATORS` to read another snapshot file.
51
+ The indicators are a weekly snapshot, rebuilt every Monday and published at
52
+ https://tools.dwelldelta.com.au/market/indicators.json. The server uses that file when it is newer than the copy it
53
+ ships with, and the bundled copy when offline. Once a snapshot is more than 10 days old every answer says so, in
54
+ words and in the structured result, rather than passing an old figure off as current. Set `DWELLDELTA_INDICATORS`
55
+ to read another snapshot file.
50
56
 
51
57
  ## Licence
52
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dwelldelta-mcp",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Is an Australian rent fair? A rent check on the ABS rents index, plus sourced property and lending indicators, for AI agents.",
5
5
  "mcpName": "au.com.dwelldelta/dwelldelta",
6
6
  "license": "MIT",
package/server.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
- // DwellDelta MCP server: Australian property market data for AI agents. Runs on the user's machine over stdio;
3
- // sends nothing anywhere and records nothing. Three read-only tools; the logic lives in tools.mjs.
2
+ // DwellDelta MCP server: Australian property market data for AI agents. Runs on the user's machine over stdio and
3
+ // records nothing. From 0.4.0 it fetches the week's indicators once at start from tools.dwelldelta.com.au - one
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). Three read-only tools; the logic lives in tools.mjs.
4
6
  //
5
7
  // Every result carries text to quote and a structured result (the figures plus where they come from, under which
6
8
  // licence, how current, and whether stale). Every failure is isError with the next step to take, so an agent
@@ -10,12 +12,13 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
12
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
11
13
  import { z } from "zod";
12
14
  import {
13
- rentCheckResult, marketIndicatorsResult, dataSourcesResult, loadJson, ToolError,
15
+ rentCheckResult, marketIndicatorsResult, dataSourcesResult, loadJson, loadSnapshot, ToolError,
14
16
  RENTS_PATH, INDICATORS_PATH, SERVER_VERSION,
15
17
  } from "./tools.mjs";
16
18
 
17
19
  const rents = await loadJson(RENTS_PATH);
18
- const snapshot = await loadJson(INDICATORS_PATH).catch(() => null);
20
+ const loaded = await loadSnapshot();
21
+ const snapshot = loaded.snapshot ? { ...loaded.snapshot, origin: loaded.origin } : null;
19
22
  const readOnly = { readOnlyHint: true, idempotentHint: true, openWorldHint: false, destructiveHint: false };
20
23
 
21
24
  const ok = ({ text, structured }) => ({ content: [{ type: "text", text }], structuredContent: structured });
package/tools.mjs CHANGED
@@ -25,11 +25,44 @@ export const RENTS_PATH = join(HERE, "vendor", "rents-index.json");
25
25
  // owner's machine (rebuilt every Monday), else the copy bundled at pack time - which the stale flag then marks
26
26
  // as old once it is more than STALE_DAYS past its build date.
27
27
  const LIVE = join(HERE, "..", "..", "dwelldelta-data", "market", "indicators.json");
28
+ export const BUNDLED_PATH = join(HERE, "vendor", "indicators.json");
28
29
  export const INDICATORS_PATH = process.env.DWELLDELTA_INDICATORS
29
- ?? (existsSync(LIVE) ? LIVE : join(HERE, "vendor", "indicators.json"));
30
+ ?? (existsSync(LIVE) ? LIVE : BUNDLED_PATH);
31
+ // 0.4.0: the snapshot is also published every Monday (dwelldelta-local tools/sync_indicators.py). At start the server
32
+ // fetches it once - a plain request for one public file; nothing about the user or their questions is sent - and
33
+ // uses it only if it is well formed and newer than the copy it ships with. DWELLDELTA_OFFLINE=1 never fetches.
34
+ export const PUBLISHED_URL = "https://tools.dwelldelta.com.au/market/indicators.json";
35
+ export const FETCH_TIMEOUT_MS = 5000;
36
+
37
+ const wellFormed = (s) => s && typeof s.built === "string" && /^\d{4}-\d{2}-\d{2}$/.test(s.built)
38
+ && Array.isArray(s.indicators) && s.indicators.length > 0 && Array.isArray(s.sources)
39
+ && s.indicators.every((i) => i.source && i.licence && i.period);
40
+
41
+ /**
42
+ * The snapshot and where it came from: "env" (DWELLDELTA_INDICATORS), "live" (the owner's machine), "published"
43
+ * (this week's file from tools.dwelldelta.com.au) or "bundled" (the copy shipped in the package). Never throws for
44
+ * a failed fetch; returns { snapshot: null } only when no copy can be read at all.
45
+ */
46
+ export async function loadSnapshot({ env = process.env, fetchImpl = globalThis.fetch, live = LIVE,
47
+ bundled = BUNDLED_PATH } = {}) {
48
+ const read = (path) => loadJson(path).catch(() => null);
49
+ if (env.DWELLDELTA_INDICATORS) return { snapshot: await read(env.DWELLDELTA_INDICATORS), origin: "env" };
50
+ if (existsSync(live)) return { snapshot: await read(live), origin: "live" };
51
+ const shipped = await read(bundled);
52
+ if (env.DWELLDELTA_OFFLINE !== "1" && typeof fetchImpl === "function") {
53
+ try {
54
+ const res = await fetchImpl(PUBLISHED_URL, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
55
+ const got = res.ok ? await res.json() : null;
56
+ if (wellFormed(got) && (!shipped || got.built >= shipped.built)) return { snapshot: got, origin: "published" };
57
+ } catch {
58
+ // Offline, blocked or slow: the bundled copy answers, and the stale flag says how old it is.
59
+ }
60
+ }
61
+ return { snapshot: shipped, origin: shipped ? "bundled" : null };
62
+ }
30
63
 
31
64
  export const FOOTER = "Information, not advice. From DwellDelta (dwelldelta.com.au), built on public data.";
32
- export const SERVER_VERSION = "0.3.1";
65
+ export const SERVER_VERSION = "0.4.0";
33
66
  // The indicators snapshot is rebuilt every Monday. Older than this and the answer says so, in words and in the
34
67
  // structured result, rather than serving a stale figure as current.
35
68
  export const STALE_DAYS = 10;
@@ -50,7 +83,7 @@ export class ToolError extends Error {
50
83
  * The provenance that travels WITH every answer, as structured data an agent can carry into its own output.
51
84
  * "The attribution must travel with the data" - the principle, from abs-mcp's DataResponse.
52
85
  */
53
- export function envelope({ sources, dataAsOf, built = null }, now = new Date()) {
86
+ export function envelope({ sources, dataAsOf, built = null, origin = null }, now = new Date()) {
54
87
  const age = built ? Math.floor((now - new Date(built + "T00:00:00Z")) / 86400000) : null;
55
88
  const stale = age !== null && age > STALE_DAYS;
56
89
  return {
@@ -59,6 +92,7 @@ export function envelope({ sources, dataAsOf, built = null }, now = new Date())
59
92
  retrieved_at: now.toISOString(),
60
93
  data_as_of: dataAsOf,
61
94
  snapshot_built: built,
95
+ snapshot_origin: origin,
62
96
  stale,
63
97
  stale_reason: stale ? `the indicators snapshot was built ${built}, ${age} days ago; it is rebuilt weekly` : null,
64
98
  sources: sources.map((s) => ({ source: s.source, licence: s.licence, attribution: s.attribution ?? null })),
@@ -122,7 +156,7 @@ export function marketIndicatorsResult({ geography } = {}, snapshot, now = new D
122
156
  `Call market_indicators again with one of: ${GEOGRAPHIES(snapshot).join(", ")}; or with no geography for all.`);
123
157
  }
124
158
  const env = envelope({ sources: snapshot.sources, dataAsOf: items.map((i) => i.period).sort().at(-1),
125
- built: snapshot.built }, now);
159
+ built: snapshot.built, origin: snapshot.origin ?? null }, now);
126
160
  const text = [
127
161
  ...staleNote(env),
128
162
  `Australian property market indicators (snapshot built ${snapshot.built}). Each is the latest observed figure;`,
@@ -141,7 +175,8 @@ export function dataSources(snapshot) {
141
175
  }
142
176
 
143
177
  export function dataSourcesResult(snapshot, now = new Date()) {
144
- const env = envelope({ sources: snapshot.sources, dataAsOf: null, built: snapshot.built }, now);
178
+ const env = envelope({ sources: snapshot.sources, dataAsOf: null, built: snapshot.built,
179
+ origin: snapshot.origin ?? null }, now);
145
180
  const text = [
146
181
  ...staleNote(env),
147
182
  `Publisher: ${snapshot.publisher}.`,