@pipeworx/mcp-altos 0.1.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 +21 -0
- package/README.md +34 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +404 -0
- package/tsconfig.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pipeworx
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# mcp-altos
|
|
2
|
+
|
|
3
|
+
Altos Research MCP — Real estate market intelligence
|
|
4
|
+
|
|
5
|
+
Part of the [Pipeworx](https://pipeworx.io) open MCP gateway.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
Add to your MCP client config:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"mcpServers": {
|
|
19
|
+
"altos": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/altos/mcp"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or use the CLI:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx pipeworx use altos
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-altos",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Altos Research MCP — Real estate market intelligence",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "altos"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-altos"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.pipeworx-io/altos",
|
|
4
|
+
"title": "altos",
|
|
5
|
+
"description": "Altos Research MCP — Real estate market intelligence",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/altos",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-altos",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/altos/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
interface McpToolDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: 'object';
|
|
6
|
+
properties: Record<string, unknown>;
|
|
7
|
+
required?: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface McpToolExport {
|
|
12
|
+
tools: McpToolDefinition[];
|
|
13
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Altos Research MCP — Real estate market intelligence
|
|
18
|
+
*
|
|
19
|
+
* BYO key: requires an Altos Research API key from https://altosresearch.com
|
|
20
|
+
* Passed via _altosKey parameter.
|
|
21
|
+
*
|
|
22
|
+
* API returns gzipped CSV files. We decompress and parse them into structured data.
|
|
23
|
+
* Dates must be Fridays — the helper lastFriday() finds the most recent one.
|
|
24
|
+
*
|
|
25
|
+
* Tools:
|
|
26
|
+
* - altos_market_stats: aggregated market statistics for a region
|
|
27
|
+
* - altos_inventory_trend: inventory trend over multiple weeks
|
|
28
|
+
* - altos_active_listings: active listing-level data for a region
|
|
29
|
+
* - altos_pending_sales: pending sales (under contract) for a region
|
|
30
|
+
* - altos_new_listings: new listings (on market less than a week)
|
|
31
|
+
* - altos_list_files: list available data files for a region
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
// ── Helpers ────────────────────────────────────────────────────────────
|
|
36
|
+
|
|
37
|
+
function getAuth(apiKey: string): string {
|
|
38
|
+
return `Basic ${btoa(apiKey + ':')}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function lastFriday(): string {
|
|
42
|
+
const d = new Date();
|
|
43
|
+
const day = d.getDay();
|
|
44
|
+
const diff = (day + 2) % 7; // days since last Friday
|
|
45
|
+
d.setDate(d.getDate() - (diff === 0 ? 7 : diff));
|
|
46
|
+
return d.toISOString().slice(0, 10);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function fridayNWeeksAgo(n: number): string {
|
|
50
|
+
const d = new Date();
|
|
51
|
+
const day = d.getDay();
|
|
52
|
+
const diff = (day + 2) % 7;
|
|
53
|
+
d.setDate(d.getDate() - (diff === 0 ? 7 : diff));
|
|
54
|
+
d.setDate(d.getDate() - n * 7);
|
|
55
|
+
return d.toISOString().slice(0, 10);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function parseCSV(text: string): Record<string, string>[] {
|
|
59
|
+
const lines = text.trim().split('\n');
|
|
60
|
+
if (lines.length < 2) return [];
|
|
61
|
+
const headers = lines[0].split(',').map(h => h.trim().replace(/^"|"$/g, ''));
|
|
62
|
+
return lines.slice(1).map(line => {
|
|
63
|
+
const values = line.split(',').map(v => v.trim().replace(/^"|"$/g, ''));
|
|
64
|
+
const row: Record<string, string> = {};
|
|
65
|
+
headers.forEach((h, i) => { row[h] = values[i] ?? ''; });
|
|
66
|
+
return row;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function extractKey(args: Record<string, unknown>): string {
|
|
71
|
+
const key = args._altosKey as string;
|
|
72
|
+
delete args._altosKey;
|
|
73
|
+
if (!key) throw new Error('Altos Research API key required. Get one at https://altosresearch.com and pass via _altosKey.');
|
|
74
|
+
return key;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function fetchAltosCSV(apiKey: string, params: Record<string, string>): Promise<Record<string, string>[]> {
|
|
78
|
+
const url = new URL('https://intel.altosresearch.com/api/data');
|
|
79
|
+
for (const [k, v] of Object.entries(params)) {
|
|
80
|
+
url.searchParams.set(k, v);
|
|
81
|
+
}
|
|
82
|
+
const res = await fetch(url.toString(), {
|
|
83
|
+
headers: { Authorization: getAuth(apiKey) },
|
|
84
|
+
});
|
|
85
|
+
if (!res.ok) {
|
|
86
|
+
const text = await res.text();
|
|
87
|
+
throw new Error(`Altos API error (${res.status}): ${text}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Response may be gzipped — try to decompress
|
|
91
|
+
const contentType = res.headers.get('content-type') || '';
|
|
92
|
+
const contentEncoding = res.headers.get('content-encoding') || '';
|
|
93
|
+
|
|
94
|
+
let text: string;
|
|
95
|
+
if (contentType.includes('gzip') || contentEncoding.includes('gzip') || res.url.endsWith('.csv.gz')) {
|
|
96
|
+
const ds = new DecompressionStream('gzip');
|
|
97
|
+
const decompressed = res.body!.pipeThrough(ds);
|
|
98
|
+
const reader = decompressed.getReader();
|
|
99
|
+
const chunks: Uint8Array[] = [];
|
|
100
|
+
while (true) {
|
|
101
|
+
const { done, value } = await reader.read();
|
|
102
|
+
if (done) break;
|
|
103
|
+
chunks.push(value);
|
|
104
|
+
}
|
|
105
|
+
const totalLength = chunks.reduce((a, c) => a + c.length, 0);
|
|
106
|
+
const merged = new Uint8Array(totalLength);
|
|
107
|
+
let offset = 0;
|
|
108
|
+
for (const chunk of chunks) {
|
|
109
|
+
merged.set(chunk, offset);
|
|
110
|
+
offset += chunk.length;
|
|
111
|
+
}
|
|
112
|
+
text = new TextDecoder().decode(merged);
|
|
113
|
+
} else {
|
|
114
|
+
text = await res.text();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return parseCSV(text);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function fetchAltosJSON(apiKey: string, path: string, params: Record<string, string>): Promise<unknown> {
|
|
121
|
+
const url = new URL(`https://intel.altosresearch.com/api${path}`);
|
|
122
|
+
for (const [k, v] of Object.entries(params)) {
|
|
123
|
+
url.searchParams.set(k, v);
|
|
124
|
+
}
|
|
125
|
+
const res = await fetch(url.toString(), {
|
|
126
|
+
headers: { Authorization: getAuth(apiKey) },
|
|
127
|
+
});
|
|
128
|
+
if (!res.ok) {
|
|
129
|
+
const text = await res.text();
|
|
130
|
+
throw new Error(`Altos API error (${res.status}): ${text}`);
|
|
131
|
+
}
|
|
132
|
+
return res.json();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ── Tool definitions ───────────────────────────────────────────────────
|
|
136
|
+
|
|
137
|
+
const tools: McpToolExport['tools'] = [
|
|
138
|
+
{
|
|
139
|
+
name: 'altos_market_stats',
|
|
140
|
+
description:
|
|
141
|
+
'Get aggregated market statistics for a region — inventory, new listings, median price, days on market, and market action index.',
|
|
142
|
+
inputSchema: {
|
|
143
|
+
type: 'object' as const,
|
|
144
|
+
properties: {
|
|
145
|
+
_altosKey: { type: 'string', description: 'Altos Research API key' },
|
|
146
|
+
region: { type: 'string', description: 'Region code (e.g., "us_national", "ca_los-angeles", "ca_94105")' },
|
|
147
|
+
date: { type: 'string', description: 'Date (must be a Friday, YYYY-MM-DD). Defaults to most recent Friday.' },
|
|
148
|
+
res_type: { type: 'string', description: 'Residential type filter: "single_family" or "multi_family". Default: single_family.' },
|
|
149
|
+
quartile: { type: 'string', description: 'Price quartile: "ALL", "FIRST", "SECOND", "THIRD", "FOURTH". Default: ALL.' },
|
|
150
|
+
},
|
|
151
|
+
required: ['_altosKey', 'region'],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: 'altos_inventory_trend',
|
|
156
|
+
description:
|
|
157
|
+
'Get inventory trend over multiple weeks — tracks inventory, new listings, days on market, median price, and percent price decreased over time.',
|
|
158
|
+
inputSchema: {
|
|
159
|
+
type: 'object' as const,
|
|
160
|
+
properties: {
|
|
161
|
+
_altosKey: { type: 'string', description: 'Altos Research API key' },
|
|
162
|
+
region: { type: 'string', description: 'Region code (e.g., "us_national", "ca_los-angeles")' },
|
|
163
|
+
weeks: { type: 'number', description: 'Number of weeks to look back (default 12, max 52)' },
|
|
164
|
+
},
|
|
165
|
+
required: ['_altosKey', 'region'],
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'altos_active_listings',
|
|
170
|
+
description:
|
|
171
|
+
'Get active listing-level data for a region — individual property details including address, price, beds, baths, and square footage.',
|
|
172
|
+
inputSchema: {
|
|
173
|
+
type: 'object' as const,
|
|
174
|
+
properties: {
|
|
175
|
+
_altosKey: { type: 'string', description: 'Altos Research API key' },
|
|
176
|
+
region: { type: 'string', description: 'Region code (e.g., "ca_los-angeles", "ca_94105")' },
|
|
177
|
+
date: { type: 'string', description: 'Date (must be a Friday, YYYY-MM-DD). Defaults to most recent Friday.' },
|
|
178
|
+
limit: { type: 'number', description: 'Max rows to return (default 100)' },
|
|
179
|
+
},
|
|
180
|
+
required: ['_altosKey', 'region'],
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: 'altos_pending_sales',
|
|
185
|
+
description:
|
|
186
|
+
'Get pending sales (under contract) for a region — properties that have accepted offers but have not yet closed.',
|
|
187
|
+
inputSchema: {
|
|
188
|
+
type: 'object' as const,
|
|
189
|
+
properties: {
|
|
190
|
+
_altosKey: { type: 'string', description: 'Altos Research API key' },
|
|
191
|
+
region: { type: 'string', description: 'Region code (e.g., "ca_los-angeles", "ca_94105")' },
|
|
192
|
+
date: { type: 'string', description: 'Date (must be a Friday, YYYY-MM-DD). Defaults to most recent Friday.' },
|
|
193
|
+
limit: { type: 'number', description: 'Max rows to return (default 100)' },
|
|
194
|
+
},
|
|
195
|
+
required: ['_altosKey', 'region'],
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'altos_new_listings',
|
|
200
|
+
description:
|
|
201
|
+
'Get new listings (on market less than a week) for a region — freshly listed properties.',
|
|
202
|
+
inputSchema: {
|
|
203
|
+
type: 'object' as const,
|
|
204
|
+
properties: {
|
|
205
|
+
_altosKey: { type: 'string', description: 'Altos Research API key' },
|
|
206
|
+
region: { type: 'string', description: 'Region code (e.g., "ca_los-angeles", "ca_94105")' },
|
|
207
|
+
date: { type: 'string', description: 'Date (must be a Friday, YYYY-MM-DD). Defaults to most recent Friday.' },
|
|
208
|
+
limit: { type: 'number', description: 'Max rows to return (default 100)' },
|
|
209
|
+
},
|
|
210
|
+
required: ['_altosKey', 'region'],
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'altos_list_files',
|
|
215
|
+
description:
|
|
216
|
+
'List available data files for a region — returns the catalog of downloadable data files from Altos Research.',
|
|
217
|
+
inputSchema: {
|
|
218
|
+
type: 'object' as const,
|
|
219
|
+
properties: {
|
|
220
|
+
_altosKey: { type: 'string', description: 'Altos Research API key' },
|
|
221
|
+
region: { type: 'string', description: 'Region code (default: "us_national")' },
|
|
222
|
+
type: { type: 'string', description: 'Data type: "stats", "listings", "listings-new", "pendings" (default: "stats")' },
|
|
223
|
+
},
|
|
224
|
+
required: ['_altosKey'],
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
];
|
|
228
|
+
|
|
229
|
+
// ── callTool dispatcher ────────────────────────────────────────────────
|
|
230
|
+
|
|
231
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
232
|
+
const key = extractKey(args);
|
|
233
|
+
|
|
234
|
+
switch (name) {
|
|
235
|
+
case 'altos_market_stats': {
|
|
236
|
+
const region = args.region as string;
|
|
237
|
+
const date = (args.date as string) || lastFriday();
|
|
238
|
+
const resType = (args.res_type as string) || 'single_family';
|
|
239
|
+
const quartile = (args.quartile as string) || 'ALL';
|
|
240
|
+
|
|
241
|
+
const rows = await fetchAltosCSV(key, {
|
|
242
|
+
region,
|
|
243
|
+
date,
|
|
244
|
+
type: 'stats',
|
|
245
|
+
columnset: 'classic',
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Filter rows by res_type, quartile, and 7-day rolling average
|
|
249
|
+
const filtered = rows.filter(r =>
|
|
250
|
+
(!r.res_type || r.res_type === resType) &&
|
|
251
|
+
(!r.quartile || r.quartile === quartile) &&
|
|
252
|
+
(!r.rolling_average || r.rolling_average === '7-day')
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
const result = (filtered.length > 0 ? filtered : rows.slice(0, 5)).map(r => ({
|
|
256
|
+
date: r.date ?? date,
|
|
257
|
+
inventory_total: r.inventory_total ?? '',
|
|
258
|
+
new_listings_total: r.new_listings_total ?? '',
|
|
259
|
+
listings_absorbed_total: r.listings_absorbed_total ?? '',
|
|
260
|
+
days_on_market_median: r.days_on_market_median ?? '',
|
|
261
|
+
price_median: r.price_median ?? '',
|
|
262
|
+
percent_price_decreased_median: r.percent_price_decreased_median ?? '',
|
|
263
|
+
market_action_median: r.market_action_median ?? '',
|
|
264
|
+
months_of_inventory_median: r.months_of_inventory_median ?? '',
|
|
265
|
+
estimated_sales_total: r.estimated_sales_total ?? '',
|
|
266
|
+
}));
|
|
267
|
+
|
|
268
|
+
return { region, date, res_type: resType, quartile, stats: result };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
case 'altos_inventory_trend': {
|
|
272
|
+
const region = args.region as string;
|
|
273
|
+
const weeksRaw = Math.min(Math.max((args.weeks as number) || 12, 1), 52);
|
|
274
|
+
|
|
275
|
+
// Limit actual API calls: fetch at most 6 snapshots, sampling evenly
|
|
276
|
+
const maxCalls = 6;
|
|
277
|
+
const datesToFetch: string[] = [];
|
|
278
|
+
|
|
279
|
+
if (weeksRaw <= maxCalls) {
|
|
280
|
+
for (let i = 0; i < weeksRaw; i++) {
|
|
281
|
+
datesToFetch.push(fridayNWeeksAgo(i));
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
// Sample evenly across the range
|
|
285
|
+
const step = Math.floor(weeksRaw / maxCalls);
|
|
286
|
+
for (let i = 0; i < maxCalls; i++) {
|
|
287
|
+
datesToFetch.push(fridayNWeeksAgo(i * step));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const snapshots = await Promise.all(
|
|
292
|
+
datesToFetch.map(async (date) => {
|
|
293
|
+
try {
|
|
294
|
+
const rows = await fetchAltosCSV(key, {
|
|
295
|
+
region,
|
|
296
|
+
date,
|
|
297
|
+
type: 'stats',
|
|
298
|
+
columnset: 'classic',
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
const match = rows.find(r =>
|
|
302
|
+
(!r.res_type || r.res_type === 'single_family') &&
|
|
303
|
+
(!r.quartile || r.quartile === 'ALL') &&
|
|
304
|
+
(!r.rolling_average || r.rolling_average === '7-day')
|
|
305
|
+
) || rows[0];
|
|
306
|
+
|
|
307
|
+
if (!match) return null;
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
date,
|
|
311
|
+
inventory: match.inventory_total ?? '',
|
|
312
|
+
new_listings: match.new_listings_total ?? '',
|
|
313
|
+
days_on_market: match.days_on_market_median ?? '',
|
|
314
|
+
price_median: match.price_median ?? '',
|
|
315
|
+
pct_price_decreased: match.percent_price_decreased_median ?? '',
|
|
316
|
+
};
|
|
317
|
+
} catch {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
})
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
return {
|
|
324
|
+
region,
|
|
325
|
+
weeks_requested: weeksRaw,
|
|
326
|
+
snapshots_fetched: datesToFetch.length,
|
|
327
|
+
trend: snapshots.filter(Boolean),
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
case 'altos_active_listings': {
|
|
332
|
+
const region = args.region as string;
|
|
333
|
+
const date = (args.date as string) || lastFriday();
|
|
334
|
+
const limit = Math.min((args.limit as number) || 100, 500);
|
|
335
|
+
|
|
336
|
+
const rows = await fetchAltosCSV(key, {
|
|
337
|
+
region,
|
|
338
|
+
date,
|
|
339
|
+
type: 'listings',
|
|
340
|
+
columnset: 'classic',
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
const listings = rows.slice(0, limit).map(r => ({
|
|
344
|
+
property_id: r.property_id ?? '',
|
|
345
|
+
street_address: r.street_address ?? '',
|
|
346
|
+
city: r.city ?? '',
|
|
347
|
+
state: r.state ?? '',
|
|
348
|
+
zip: r.zip ?? '',
|
|
349
|
+
price: r.price ?? '',
|
|
350
|
+
type: r.type ?? '',
|
|
351
|
+
beds: r.beds ?? '',
|
|
352
|
+
baths: r.baths ?? '',
|
|
353
|
+
floor_size: r.floor_size ?? '',
|
|
354
|
+
lot_size: r.lot_size ?? '',
|
|
355
|
+
built_in: r.built_in ?? '',
|
|
356
|
+
days_on_market: r.days_on_market ?? '',
|
|
357
|
+
}));
|
|
358
|
+
|
|
359
|
+
return { region, date, total_available: rows.length, returned: listings.length, listings };
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
case 'altos_pending_sales': {
|
|
363
|
+
const region = args.region as string;
|
|
364
|
+
const date = (args.date as string) || lastFriday();
|
|
365
|
+
const limit = Math.min((args.limit as number) || 100, 500);
|
|
366
|
+
|
|
367
|
+
const rows = await fetchAltosCSV(key, {
|
|
368
|
+
region,
|
|
369
|
+
date,
|
|
370
|
+
type: 'pendings',
|
|
371
|
+
columnset: 'classic',
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
return { region, date, total_available: rows.length, returned: Math.min(rows.length, limit), pendings: rows.slice(0, limit) };
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
case 'altos_new_listings': {
|
|
378
|
+
const region = args.region as string;
|
|
379
|
+
const date = (args.date as string) || lastFriday();
|
|
380
|
+
const limit = Math.min((args.limit as number) || 100, 500);
|
|
381
|
+
|
|
382
|
+
const rows = await fetchAltosCSV(key, {
|
|
383
|
+
region,
|
|
384
|
+
date,
|
|
385
|
+
type: 'listings-new',
|
|
386
|
+
columnset: 'classic',
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
return { region, date, total_available: rows.length, returned: Math.min(rows.length, limit), new_listings: rows.slice(0, limit) };
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
case 'altos_list_files': {
|
|
393
|
+
const region = (args.region as string) || 'us_national';
|
|
394
|
+
const type = (args.type as string) || 'stats';
|
|
395
|
+
|
|
396
|
+
return fetchAltosJSON(key, '/list', { region, type });
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
default:
|
|
400
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export default { tools, callTool, meter: { credits: 25 } } satisfies McpToolExport;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|