catastro-gps-mcp 1.3.2 → 2.2.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/CHANGELOG.md +23 -0
- package/README.md +12 -5
- package/build/client/catastrogps-api.d.ts +9 -2
- package/build/client/catastrogps-api.js +31 -10
- package/build/server.js +14 -0
- package/build/tools/compare-parcels.js +15 -15
- package/build/tools/get-agriculture.js +2 -2
- package/build/tools/get-boundaries.js +5 -6
- package/build/tools/get-crop-catalog.d.ts +4 -0
- package/build/tools/get-crop-catalog.js +44 -0
- package/build/tools/get-ground-motion.js +3 -3
- package/build/tools/get-market.js +47 -21
- package/build/tools/get-neighbors.d.ts +4 -0
- package/build/tools/get-neighbors.js +31 -0
- package/build/tools/get-parcel-sigpac.d.ts +4 -0
- package/build/tools/get-parcel-sigpac.js +80 -0
- package/build/tools/get-parcel-subparcels.d.ts +4 -0
- package/build/tools/get-parcel-subparcels.js +58 -0
- package/build/tools/get-parcel.js +42 -29
- package/build/tools/get-score.js +12 -18
- package/build/tools/get-solar.js +13 -13
- package/build/tools/get-terrain.js +3 -3
- package/build/tools/get-units.js +25 -25
- package/build/tools/get-value-history.js +9 -8
- package/build/tools/list-municipalities.d.ts +4 -0
- package/build/tools/list-municipalities.js +21 -0
- package/build/tools/list-provinces.d.ts +4 -0
- package/build/tools/list-provinces.js +19 -0
- package/build/tools/list-streets.d.ts +4 -0
- package/build/tools/list-streets.js +24 -0
- package/build/tools/search-address.js +17 -17
- package/build/tools/shared.js +4 -0
- package/build/types/index.d.ts +368 -205
- package/build/types/index.js +2 -0
- package/build/version.d.ts +2 -2
- package/build/version.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.0 (2026-10-23)
|
|
4
|
+
|
|
5
|
+
- New `get_parcel_sigpac`: every SIGPAC enclosure of a Spanish parcel (ES, PV, NA) from `GET /v1/parcels/{ref}/sigpac`: SIGPAC parcel key, `match`, `land_use_code`, `land_use` in `lang`, `crop_code`, `use_class`, `area_ha`, `irrigation_pct`, `mean_slope_pct`, `altitude_m`, `pasture_eligibility_pct`, `cap_region` (null when SIGPAC does not apply them), `incidents`, attribution and licence, outline with `include_geometry`. `SIG_001` (SIGPAC down) is explained as retryable and not charged.
|
|
6
|
+
- `get_parcel_subparcels` states its real coverage: Spain, Austria, Germany, Czechia, the Netherlands, France, Portugal, Sweden, Switzerland, Finland, Belgium, Ireland, Slovenia, Estonia and Greece.
|
|
7
|
+
|
|
8
|
+
## 2.1.0 (2026-10-21)
|
|
9
|
+
|
|
10
|
+
- New `get_parcel_subparcels`: every crop or land-use subparcel (`crop_code`, `crop` in `lang`, `crop_original`, `area_m2`, `kind`, `use_class`, `intensity`, `land_type`, `land_class`, `source`, outline with `include_geometry`). Spain (foral territories included), Austria, Estonia and Greece. `SUB_001` (source down) is explained as retryable and not charged.
|
|
11
|
+
- New `get_crop_catalog` (free, no quota): crop codes with names in 10 languages, filterable by `code` or `source`.
|
|
12
|
+
- New `get_neighbors`: adjoining parcels with reference and centre point.
|
|
13
|
+
- New `list_provinces`, `list_municipalities`, `list_streets`: the Spanish cadastre lists.
|
|
14
|
+
- `get_parcel` takes `lang` and returns `subparcel_count` and `crop_summary` (the API no longer embeds subparcels in the parcel).
|
|
15
|
+
- `get_market_data` returns `zone_prices` for Spanish parcels: official province prices for housing (€/m²) and farmland (€/ha).
|
|
16
|
+
|
|
17
|
+
## 2.0.0 (2026-10-20)
|
|
18
|
+
|
|
19
|
+
- Every tool calls the English v1 API (`/v1/parcels/...`, `/v1/search/...`, `/v1/resolve`) instead of the legacy `/api/...` routes, which answer in Spanish field names and are now deprecated.
|
|
20
|
+
- Breaking: `get_parcel`, `search_address` and `get_units` return `region` instead of `province`; `get_parcel` by coordinates also returns `parcel_reference`.
|
|
21
|
+
- Breaking: the nested blocks passed through from the API are English camelCase: `get_agriculture.agriculture` (`landUse`, `mainCrop`, `ndvi.cropHealth`, `cropPrice`...), `get_terrain.relief`/`protected_areas`/`climate` (`meanPct`, `overlapPct`...) and `get_ground_motion.ground_motion` (`meanMmYear`...).
|
|
22
|
+
- `get_investment_score` ratings are English: `excellent`, `good`, `moderate`, `low`, `very_low`, `no_data`; risk and opportunity factors are English sentences.
|
|
23
|
+
- `get_boundaries` returns GeoJSON for every country (the `outline_lat_lng` ring of non-Spanish parcels is gone; use `get_parcel` for it).
|
|
24
|
+
- Errors read the v1 `{code, message, details}` body; the legacy `{error, data}` body is still understood.
|
|
25
|
+
|
|
3
26
|
## 1.3.2 (2026-10-06)
|
|
4
27
|
|
|
5
28
|
- Coverage stated the same way as the website: 29 European countries, including the Basque Country and Navarre foral cadastres; by cadastral reference in 27 and by coordinates in all 29 (United Kingdom and Croatia are coordinates only). The "31 official cadastres" count is gone.
|
package/README.md
CHANGED
|
@@ -45,23 +45,28 @@ Use the same `npx -y catastro-gps-mcp` command with `CATASTROGPS_API_KEY` in the
|
|
|
45
45
|
|
|
46
46
|
| Tool | What it does | Countries |
|
|
47
47
|
|------|--------------|-----------|
|
|
48
|
-
| `get_parcel` | Parcel by cadastral reference **or** WGS84 coordinates: reference, location, address, municipality, area, land use, outline | All 29 countries, Basque Country and Navarre included (UK and HR: coordinates only) |
|
|
48
|
+
| `get_parcel` | Parcel by cadastral reference **or** WGS84 coordinates: reference, location, address, municipality, area, land use, outline, number of crop subparcels and a crop summary (`lang` for crop names) | All 29 countries, Basque Country and Navarre included (UK and HR: coordinates only) |
|
|
49
49
|
| `search_address` | Postal address in free text to ranked parcels, with confidence and whether the number and municipality match | ES (with PV and NA entrances) and FR, IT, DE, AT, NL, BE, PL, CH, CZ, DK, NO, FI, EE, LV, LT, SI, SK, BG, GR, CY, LU, LI, IS, IE, UK, PT |
|
|
50
50
|
| `get_units` | Every unit (dwelling, shop, garage, storage) of a Spanish building: stair, floor, door, use, area, participation, year. Paginated, 200 per page | ES, PV, NA |
|
|
51
51
|
| `resolve_reference` | Free, no quota: is this text a reference, coordinates or a place name, and of which country | All |
|
|
52
|
+
| `get_parcel_subparcels` | Every crop or land-use part of the parcel: crop code, crop name in 10 languages, original label, area, land-use class, source and (optionally) outline. A source failure is `SUB_001`, not charged | ES (with Bizkaia, Álava, Navarre, Gipuzkoa), AT, DE, CZ, NL, FR, PT, SE, CH, FI, BE, IE, SI, EE, GR |
|
|
53
|
+
| `get_parcel_sigpac` | Every SIGPAC enclosure (recinto) of a Spanish parcel: land-use code and name in 10 languages, area in ha, irrigation coefficient, slope, altitude, CAP pasture eligibility and region, incidents and (optionally) outline. Cite "Fuente: FEGA — SIGPAC". A SIGPAC failure is `SIG_001`, not charged | ES, PV, NA |
|
|
54
|
+
| `get_crop_catalog` | Free, no quota: every crop code with its name in the chosen language and its land-use class | All crop catalogues |
|
|
55
|
+
| `get_neighbors` | Parcels that touch or surround the parcel (up to 60) with reference and centre point | ES from the cadastre; elsewhere from our own copy (`supported: false` when not) |
|
|
56
|
+
| `list_provinces`, `list_municipalities`, `list_streets` | Spanish cadastre provinces, municipalities (with INE code) and streets of a municipality | ES (common territory) |
|
|
52
57
|
| `get_boundaries` | Parcel outline as GeoJSON / `[lat, lng]` ring, centroid and area | 30 codes (all but UK) |
|
|
53
58
|
| `get_terrain` | Relief over the parcel outline (Copernicus DEM GLO-30), Natura 2000 / protected areas (EEA) and ERA5-Land climate normals with the recent change | Every reference country but HR; outside ES, PV, NA, PT, FR, IT, DE pass `latitude`/`longitude` |
|
|
54
59
|
| `get_ground_motion` | Ground motion measured by satellite (Copernicus EGMS, 2020-2024): subsidence or uplift in mm/year, fastest-sinking cell, east-west motion, yearly displacement; says so when there are no radar reflectors | Same as `get_terrain` |
|
|
55
60
|
| `get_solar_potential` | PVGIS photovoltaic estimate: kWp, kWh/year, savings, payback, CO2, tilt | ES, PV, NA, PT, FR, IT, DE |
|
|
56
61
|
| `get_agriculture` | Land use, main crop, NDVI and a reference crop price (SIGPAC detail in Spain) | ES, PV, NA, PT, FR, IT, DE |
|
|
57
|
-
| `get_market_data` |
|
|
62
|
+
| `get_market_data` | Rural land prices, paid API plans only. Never individual sales or housing figures | ES, PV, NA: rural parcels only, small agricultural buildings allowed (`crop_prices`, `zone_prices.rural`); anything else answers `MKT_001`, not charged |
|
|
58
63
|
| `get_investment_score` | Score 0-100 with a rating and qualitative factor levels (high / medium / low / not available) | ES, PV, NA, PT, FR, IT, DE |
|
|
59
64
|
| `get_value_history` | Area and land-use snapshots of the parcel over time | ES, PV, NA, PT, FR, IT, DE, AT |
|
|
60
65
|
| `compare_parcels` | Two or three parcels side by side: location, solar, agriculture, score | ES, PT, FR, IT, DE (not PV or NA) |
|
|
61
66
|
|
|
62
67
|
## Quota, prepaid balance and limits
|
|
63
68
|
|
|
64
|
-
- Only successful answers with data spend quota: a not found, a validation error, `CNV_COVERAGE`, `CNV_AMBIGUOUS`, a 5xx and an answer without data (`available: false`) are free. `resolve_reference` never
|
|
69
|
+
- Only successful answers with data spend quota: a not found, a validation error, `CNV_COVERAGE`, `CNV_AMBIGUOUS`, a 5xx and an answer without data (`available: false`) are free. `resolve_reference` and `get_crop_catalog` never spend; `get_parcel_subparcels` and `get_parcel_sigpac` are free when the parcel has none.
|
|
65
70
|
- Each successful call costs 1 unit, except `get_units` (one unit per unit served in the page, minimum 1) and `compare_parcels` (one per parcel found).
|
|
66
71
|
- Every result carries a `quota` object read from that same response: `remaining`, `limit`, `resets_at`, `plan`, and when they apply `prepaid_overage`, `prepaid_balance_eur`, `overage_units_left`, `per_minute_remaining`, and on `get_units` with a contract per-finca cap `finca_cap` / `finca_cap_used`.
|
|
67
72
|
- When the monthly quota runs out the API does not cut you off if you have prepaid balance: each extra unit is paid from it (top up at [parcelgps.com/app/developer](https://parcelgps.com/app/developer)). With the quota used up and no balance the call fails with `KEY_AUTH_004` (HTTP 429, never 402) and the error says whether to top up or upgrade, and when the quota resets.
|
|
@@ -69,7 +74,7 @@ Use the same `npx -y catastro-gps-mcp` command with `CATASTROGPS_API_KEY` in the
|
|
|
69
74
|
|
|
70
75
|
### What the market, score and history tools can and cannot tell
|
|
71
76
|
|
|
72
|
-
- **`get_market_data`**
|
|
77
|
+
- **`get_market_data`** is for paid API plans only (a Free-plan key gets `KEY_PLAN_001`, not charged) and only prices rural land: agricultural parcels in Spain (Basque Country and Navarre included), small agricultural buildings (sheds, farm stores, ponds, greenhouses) allowed; the figure is the land price, buildings are not valued. It returns `crop_prices` (price per hectare for each crop group of the parcel, with the number of sales behind it) and `zone_prices.rural` (the province farmland price per hectare). Housing, industrial or any other non-agricultural property is not supported and answers `MKT_001` with nothing charged; so does rural land without a price and any other country.
|
|
73
78
|
- **`get_investment_score`** combines what the API can gather for the parcel: solar potential and agricultural use everywhere it answers, market prices only in France, Italy and Germany (NRW). Accessibility and risk are not computed yet and come back as `not_available`, so the score is relative to the factors that were available. You get the score, the rating and qualitative factor levels, never the weights.
|
|
74
79
|
- **`get_value_history`** starts the first time anyone looks the parcel up through Catastro GPS (at most one snapshot every 30 days). A parcel nobody has queried returns an empty list. It records area and land use; the official cadastral value is not recorded yet, so `cadastral_value_eur` is always `null` and `change_pct` is the change in area.
|
|
75
80
|
- **`compare_parcels`** fills area, land use and municipality only for Spanish parcels; for Portugal, France, Italy and Germany it returns the location, solar, agriculture and score. It does not include market prices. A parcel that is not found comes back with an error and the others are still compared.
|
|
@@ -137,7 +142,7 @@ What a `get_parcel` call returns (shortened; values are illustrative):
|
|
|
137
142
|
"longitude": -3.7038,
|
|
138
143
|
"address": "CL MAYOR 1",
|
|
139
144
|
"municipality": "MADRID",
|
|
140
|
-
"
|
|
145
|
+
"region": "MADRID",
|
|
141
146
|
"area_m2": 512,
|
|
142
147
|
"land_use": "Residencial",
|
|
143
148
|
"outline_lat_lng": [[40.41662, -3.70391], [40.41671, -3.70362], "..."],
|
|
@@ -145,6 +150,8 @@ What a `get_parcel` call returns (shortened; values are illustrative):
|
|
|
145
150
|
}
|
|
146
151
|
```
|
|
147
152
|
|
|
153
|
+
Every call goes to the English v1 REST API (`https://api.parcelgps.com/v1/...`), so nested blocks such as `agriculture`, `relief` or `ground_motion` use the same English camelCase field names as the [API docs](https://www.parcelgps.com/en/api/docs).
|
|
154
|
+
|
|
148
155
|
Errors come back as a code plus a sentence the agent can act on, for example:
|
|
149
156
|
|
|
150
157
|
```text
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Quota, ServerConfig, ApiResponse, ParcelData, PolygonData, SolarData, TerrainData, GroundMotionData, AgroData, MarketData, ScoreData, ValueHistoryData, CompareData, CoordinatesSearchData, AddressCandidatesData, UnitsPageData, ResolveData } from "../types/index.js";
|
|
1
|
+
import type { Quota, ServerConfig, ApiResponse, ParcelData, PolygonData, SolarData, TerrainData, GroundMotionData, AgroData, MarketData, ScoreData, ValueHistoryData, CompareData, CoordinatesSearchData, AddressCandidatesData, UnitsPageData, ResolveData, SubparcelsData, SIGPACData, CropCatalogData, NeighborsData, ProvincesData, MunicipalitiesData, StreetsData } from "../types/index.js";
|
|
2
2
|
export interface ApiErrorExtras {
|
|
3
3
|
quota?: Quota;
|
|
4
4
|
retryAfterSeconds?: number;
|
|
@@ -23,7 +23,14 @@ export declare class CatastroGPSClient {
|
|
|
23
23
|
private buildUrl;
|
|
24
24
|
private send;
|
|
25
25
|
private parcelPath;
|
|
26
|
-
getParcelByReference(reference: string, country?: string): Promise<ApiResponse<ParcelData>>;
|
|
26
|
+
getParcelByReference(reference: string, country?: string, lang?: string): Promise<ApiResponse<ParcelData>>;
|
|
27
|
+
getSubparcels(reference: string, country?: string, lang?: string): Promise<ApiResponse<SubparcelsData>>;
|
|
28
|
+
getSIGPAC(reference: string, country?: string, lang?: string): Promise<ApiResponse<SIGPACData>>;
|
|
29
|
+
getNeighbors(reference: string, country?: string): Promise<ApiResponse<NeighborsData>>;
|
|
30
|
+
getCropCatalog(lang?: string): Promise<ApiResponse<CropCatalogData>>;
|
|
31
|
+
listProvinces(): Promise<ApiResponse<ProvincesData>>;
|
|
32
|
+
listMunicipalities(region: string): Promise<ApiResponse<MunicipalitiesData>>;
|
|
33
|
+
listStreets(region: string, municipality: string, name?: string): Promise<ApiResponse<StreetsData>>;
|
|
27
34
|
getParcelByCoordinates(lat: number, lng: number, country?: string): Promise<ApiResponse<CoordinatesSearchData>>;
|
|
28
35
|
searchAddressCandidates(address: string, country?: string, limit?: number): Promise<ApiResponse<AddressCandidatesData>>;
|
|
29
36
|
getUnits(reference: string, country?: string, cursor?: string): Promise<ApiResponse<UnitsPageData>>;
|
|
@@ -122,7 +122,7 @@ export class CatastroGPSClient {
|
|
|
122
122
|
this.lastQuota = quota;
|
|
123
123
|
if (!response.ok) {
|
|
124
124
|
const errorBody = (await response.json().catch(() => ({})));
|
|
125
|
-
throw new CatastroGPSApiError(errorBody.code || `HTTP_${response.status}`, errorBody.
|
|
125
|
+
throw new CatastroGPSApiError(errorBody.code || `HTTP_${response.status}`, errorBody.message || errorBody.error || `API returned ${response.status}`, response.status, errorBody.details ?? errorBody.data, { quota, retryAfterSeconds: retryAfterSeconds(response.headers) });
|
|
126
126
|
}
|
|
127
127
|
const payload = (await response.json());
|
|
128
128
|
if (quota && payload && typeof payload === "object") {
|
|
@@ -143,22 +143,43 @@ export class CatastroGPSClient {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
parcelPath(reference, suffix = "") {
|
|
146
|
-
return `/
|
|
146
|
+
return `/v1/parcels/${encodeURIComponent(reference)}${suffix}`;
|
|
147
147
|
}
|
|
148
|
-
async getParcelByReference(reference, country) {
|
|
149
|
-
return this.send("GET", this.parcelPath(reference), { country });
|
|
148
|
+
async getParcelByReference(reference, country, lang) {
|
|
149
|
+
return this.send("GET", this.parcelPath(reference), { country, lang });
|
|
150
|
+
}
|
|
151
|
+
async getSubparcels(reference, country, lang) {
|
|
152
|
+
return this.send("GET", this.parcelPath(reference, "/subparcels"), { country, lang });
|
|
153
|
+
}
|
|
154
|
+
async getSIGPAC(reference, country, lang) {
|
|
155
|
+
return this.send("GET", this.parcelPath(reference, "/sigpac"), { country, lang });
|
|
156
|
+
}
|
|
157
|
+
async getNeighbors(reference, country) {
|
|
158
|
+
return this.send("GET", this.parcelPath(reference, "/neighbors"), { country });
|
|
159
|
+
}
|
|
160
|
+
async getCropCatalog(lang) {
|
|
161
|
+
return this.send("GET", "/v1/reference/crops", { lang });
|
|
162
|
+
}
|
|
163
|
+
async listProvinces() {
|
|
164
|
+
return this.send("GET", "/v1/locations/provinces");
|
|
165
|
+
}
|
|
166
|
+
async listMunicipalities(region) {
|
|
167
|
+
return this.send("GET", "/v1/locations/municipalities", { region });
|
|
168
|
+
}
|
|
169
|
+
async listStreets(region, municipality, name) {
|
|
170
|
+
return this.send("GET", "/v1/locations/streets", { region, municipality, name });
|
|
150
171
|
}
|
|
151
172
|
async getParcelByCoordinates(lat, lng, country) {
|
|
152
|
-
return this.send("GET", "/
|
|
173
|
+
return this.send("GET", "/v1/search/coordinates", { lat, lng, country });
|
|
153
174
|
}
|
|
154
175
|
async searchAddressCandidates(address, country, limit) {
|
|
155
|
-
return this.send("GET", "/
|
|
176
|
+
return this.send("GET", "/v1/search/address/candidates", { q: address, country, limit });
|
|
156
177
|
}
|
|
157
178
|
async getUnits(reference, country, cursor) {
|
|
158
179
|
return this.send("GET", this.parcelPath(reference, "/units"), { country, cursor });
|
|
159
180
|
}
|
|
160
181
|
async resolve(text, hint) {
|
|
161
|
-
return this.send("GET", "/
|
|
182
|
+
return this.send("GET", "/v1/resolve", { q: text, hint });
|
|
162
183
|
}
|
|
163
184
|
async getPolygon(reference, country) {
|
|
164
185
|
return this.send("GET", this.parcelPath(reference, "/polygon"), { country });
|
|
@@ -173,7 +194,7 @@ export class CatastroGPSClient {
|
|
|
173
194
|
return this.send("GET", this.parcelPath(reference, "/ground-motion"), { country, lat: point?.lat, lng: point?.lng });
|
|
174
195
|
}
|
|
175
196
|
async getAgriculture(reference, country) {
|
|
176
|
-
return this.send("GET", this.parcelPath(reference, "/
|
|
197
|
+
return this.send("GET", this.parcelPath(reference, "/agriculture"), { country });
|
|
177
198
|
}
|
|
178
199
|
async getMarketData(reference, country) {
|
|
179
200
|
return this.send("GET", this.parcelPath(reference, "/market"), { country });
|
|
@@ -185,8 +206,8 @@ export class CatastroGPSClient {
|
|
|
185
206
|
return this.send("GET", this.parcelPath(reference, "/value-history"), { country });
|
|
186
207
|
}
|
|
187
208
|
async compareParcels(parcels) {
|
|
188
|
-
return this.send("POST", "/
|
|
189
|
-
|
|
209
|
+
return this.send("POST", "/v1/parcels/compare", undefined, {
|
|
210
|
+
parcels: parcels.map((parcel) => ({ reference: parcel.reference, country: parcel.country })),
|
|
190
211
|
});
|
|
191
212
|
}
|
|
192
213
|
}
|
package/build/server.js
CHANGED
|
@@ -13,6 +13,13 @@ import { registerGetValueHistory } from "./tools/get-value-history.js";
|
|
|
13
13
|
import { registerCompareParcels } from "./tools/compare-parcels.js";
|
|
14
14
|
import { registerGetUnits } from "./tools/get-units.js";
|
|
15
15
|
import { registerResolveReference } from "./tools/resolve-reference.js";
|
|
16
|
+
import { registerGetParcelSubparcels } from "./tools/get-parcel-subparcels.js";
|
|
17
|
+
import { registerGetParcelSIGPAC } from "./tools/get-parcel-sigpac.js";
|
|
18
|
+
import { registerGetCropCatalog } from "./tools/get-crop-catalog.js";
|
|
19
|
+
import { registerGetNeighbors } from "./tools/get-neighbors.js";
|
|
20
|
+
import { registerListProvinces } from "./tools/list-provinces.js";
|
|
21
|
+
import { registerListMunicipalities } from "./tools/list-municipalities.js";
|
|
22
|
+
import { registerListStreets } from "./tools/list-streets.js";
|
|
16
23
|
import { SERVER_VERSION } from "./version.js";
|
|
17
24
|
export const DEFAULT_API_URL = "https://api.parcelgps.com";
|
|
18
25
|
export const DEFAULT_TIMEOUT_MS = 20000;
|
|
@@ -35,6 +42,13 @@ export function createServer(config) {
|
|
|
35
42
|
registerCompareParcels(server, client);
|
|
36
43
|
registerGetUnits(server, client);
|
|
37
44
|
registerResolveReference(server, client);
|
|
45
|
+
registerGetParcelSubparcels(server, client);
|
|
46
|
+
registerGetParcelSIGPAC(server, client);
|
|
47
|
+
registerGetCropCatalog(server, client);
|
|
48
|
+
registerGetNeighbors(server, client);
|
|
49
|
+
registerListProvinces(server, client);
|
|
50
|
+
registerListMunicipalities(server, client);
|
|
51
|
+
registerListStreets(server, client);
|
|
38
52
|
return server;
|
|
39
53
|
}
|
|
40
54
|
export function loadEndpointConfig() {
|
|
@@ -3,26 +3,26 @@ import { COMPARE_COUNTRIES } from "../types/index.js";
|
|
|
3
3
|
import { handleToolError, jsonResult } from "./shared.js";
|
|
4
4
|
function summarize(item) {
|
|
5
5
|
if (item.error) {
|
|
6
|
-
return { reference: item.
|
|
6
|
+
return { reference: item.reference, country: item.country, error: item.error };
|
|
7
7
|
}
|
|
8
|
-
const parcel = item.
|
|
8
|
+
const parcel = item.parcel ?? {};
|
|
9
9
|
const solar = item.solar;
|
|
10
|
-
const agro = item.
|
|
10
|
+
const agro = item.agriculture;
|
|
11
11
|
return {
|
|
12
|
-
reference: item.
|
|
12
|
+
reference: item.reference,
|
|
13
13
|
country: item.country,
|
|
14
|
-
latitude: parcel.
|
|
15
|
-
longitude: parcel.
|
|
16
|
-
area_m2: parcel.
|
|
17
|
-
land_use: parcel.
|
|
18
|
-
municipality: parcel.
|
|
19
|
-
solar: solar?.
|
|
20
|
-
? { production_kwh_year: solar.
|
|
14
|
+
latitude: parcel.latitude ?? null,
|
|
15
|
+
longitude: parcel.longitude ?? null,
|
|
16
|
+
area_m2: parcel.parcelArea || null,
|
|
17
|
+
land_use: parcel.use || null,
|
|
18
|
+
municipality: parcel.municipality || null,
|
|
19
|
+
solar: solar?.available
|
|
20
|
+
? { production_kwh_year: solar.annualProductionKwh ?? null, installable_kwp: solar.installableKw ?? null, solar_grade: solar.solarGrade ?? null }
|
|
21
21
|
: null,
|
|
22
|
-
agriculture: agro?.
|
|
23
|
-
? { is_agricultural: agro.
|
|
22
|
+
agriculture: agro?.available
|
|
23
|
+
? { is_agricultural: agro.isAgricultural ?? null, land_use: agro.landUse || null, crop_group: agro.cropGroup || null }
|
|
24
24
|
: null,
|
|
25
|
-
score: item.score?.
|
|
25
|
+
score: item.score?.available ? { value: item.score.score ?? null, rating: item.score.rating ?? null } : null,
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
export function registerCompareParcels(server, client) {
|
|
@@ -47,7 +47,7 @@ export function registerCompareParcels(server, client) {
|
|
|
47
47
|
}, async ({ parcels }) => {
|
|
48
48
|
try {
|
|
49
49
|
const { data, quota } = await client.compareParcels(parcels);
|
|
50
|
-
const items = data.
|
|
50
|
+
const items = data.parcels ?? [];
|
|
51
51
|
return jsonResult({ total: data.total ?? items.length, parcels: items.map(summarize) }, quota);
|
|
52
52
|
}
|
|
53
53
|
catch (error) {
|
|
@@ -7,7 +7,7 @@ export function registerGetAgriculture(server, client) {
|
|
|
7
7
|
description: "Agricultural context for a rural parcel: land use and main crop from the agricultural " +
|
|
8
8
|
"parcel registry (SIGPAC in Spain, with slope, altitude and irrigation), vegetation index " +
|
|
9
9
|
"(NDVI) and a reference crop price when available. Richest in Spain; also Portugal, France, " +
|
|
10
|
-
"Italy and Germany.
|
|
10
|
+
"Italy and Germany. Values from official registries (land use, crop) stay in the source language.",
|
|
11
11
|
inputSchema: {
|
|
12
12
|
reference: z.string().min(1).describe("Official cadastral reference of a rural parcel"),
|
|
13
13
|
country: z
|
|
@@ -18,7 +18,7 @@ export function registerGetAgriculture(server, client) {
|
|
|
18
18
|
}, async ({ reference, country }) => {
|
|
19
19
|
try {
|
|
20
20
|
const { data, quota } = await client.getAgriculture(reference, country);
|
|
21
|
-
return jsonResult({ reference, country: country ?? null, agriculture: data
|
|
21
|
+
return jsonResult({ reference, country: country ?? null, agriculture: data }, quota);
|
|
22
22
|
}
|
|
23
23
|
catch (error) {
|
|
24
24
|
return handleToolError(error);
|
|
@@ -18,12 +18,11 @@ export function registerGetBoundaries(server, client) {
|
|
|
18
18
|
try {
|
|
19
19
|
const { data: d, quota } = await client.getPolygon(reference, country);
|
|
20
20
|
return jsonResult(compact({
|
|
21
|
-
reference: d.
|
|
22
|
-
country: d.
|
|
23
|
-
latitude: d.
|
|
24
|
-
longitude: d.
|
|
25
|
-
area_m2: d.area
|
|
26
|
-
outline_lat_lng: d.poligono,
|
|
21
|
+
reference: d.reference || reference,
|
|
22
|
+
country: d.country || country,
|
|
23
|
+
latitude: d.centroid?.latitude,
|
|
24
|
+
longitude: d.centroid?.longitude,
|
|
25
|
+
area_m2: d.area,
|
|
27
26
|
geojson: d.geojson,
|
|
28
27
|
}), quota);
|
|
29
28
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { CatastroGPSClient } from "../client/catastrogps-api.js";
|
|
3
|
+
export declare function registerGetCropCatalog(server: McpServer, client: CatastroGPSClient): void;
|
|
4
|
+
//# sourceMappingURL=get-crop-catalog.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CROP_LANGUAGES } from "../types/index.js";
|
|
3
|
+
import { handleToolError, jsonResult } from "./shared.js";
|
|
4
|
+
export function registerGetCropCatalog(server, client) {
|
|
5
|
+
server.registerTool("get_crop_catalog", {
|
|
6
|
+
title: "Get Crop Catalog",
|
|
7
|
+
description: "Free and without quota: every crop or land-use code that can appear as crop_code (Spanish " +
|
|
8
|
+
"Catastro codes, the foral codes of Alava, Bizkaia, Gipuzkoa and Navarre, and the Austrian, " +
|
|
9
|
+
"Estonian and Greek catalogues) with its name in the requested language, the original label " +
|
|
10
|
+
"and its common use_class. Use it to translate or group crop codes; pass code to look one up.",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
lang: z.enum(CROP_LANGUAGES).optional().describe("Language of the names (default English)"),
|
|
13
|
+
code: z.string().min(1).optional().describe("Return only this crop code (e.g. G-, NA:1501, AT:53)"),
|
|
14
|
+
source: z
|
|
15
|
+
.string()
|
|
16
|
+
.min(1)
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Return only codes of this catalogue: ES, AL, BI, GI, NA, AT, EE or GR"),
|
|
19
|
+
},
|
|
20
|
+
}, async ({ lang, code, source }) => {
|
|
21
|
+
try {
|
|
22
|
+
const { data } = await client.getCropCatalog(lang);
|
|
23
|
+
const crops = (data.crops ?? []).filter((crop) => (!code || crop.code === code) && (!source || crop.source === source.toUpperCase()));
|
|
24
|
+
return jsonResult({
|
|
25
|
+
locale: data.locale,
|
|
26
|
+
locales: data.locales,
|
|
27
|
+
sources: data.sources,
|
|
28
|
+
count: crops.length,
|
|
29
|
+
use_classes: (data.useClasses ?? []).map((useClass) => ({ code: useClass.code, name: useClass.name })),
|
|
30
|
+
crops: crops.map((crop) => ({
|
|
31
|
+
code: crop.code,
|
|
32
|
+
source: crop.source,
|
|
33
|
+
name: crop.name,
|
|
34
|
+
original: crop.original,
|
|
35
|
+
use_class: crop.useClass ?? null,
|
|
36
|
+
})),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return handleToolError(error);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=get-crop-catalog.js.map
|
|
@@ -30,14 +30,14 @@ export function registerGetGroundMotion(server, client) {
|
|
|
30
30
|
try {
|
|
31
31
|
const { data, quota } = await client.getGroundMotion(reference, country, point);
|
|
32
32
|
return jsonResult({
|
|
33
|
-
reference: data.
|
|
33
|
+
reference: data.reference,
|
|
34
34
|
country: data.country,
|
|
35
35
|
status: data.status,
|
|
36
36
|
reason: data.reason,
|
|
37
37
|
period: data.period?.label,
|
|
38
|
-
ground_motion: data.
|
|
38
|
+
ground_motion: data.groundMotion,
|
|
39
39
|
source: data.source,
|
|
40
|
-
calculated_at: data.
|
|
40
|
+
calculated_at: data.calculatedAt,
|
|
41
41
|
}, quota);
|
|
42
42
|
}
|
|
43
43
|
catch (caught) {
|
|
@@ -1,41 +1,67 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { ENRICHMENT_COUNTRIES } from "../types/index.js";
|
|
3
|
-
import { handleToolError, jsonResult } from "./shared.js";
|
|
3
|
+
import { compact, handleToolError, jsonResult } from "./shared.js";
|
|
4
|
+
function zonePrice(price) {
|
|
5
|
+
if (!price)
|
|
6
|
+
return null;
|
|
7
|
+
return compact({
|
|
8
|
+
price_per_m2_eur: price.pricePerM2Eur,
|
|
9
|
+
price_per_ha_eur: price.pricePerHaEur,
|
|
10
|
+
period: price.period,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function zonePrices(prices) {
|
|
14
|
+
if (!prices)
|
|
15
|
+
return null;
|
|
16
|
+
return {
|
|
17
|
+
zone: prices.zone,
|
|
18
|
+
zone_level: prices.zoneLevel,
|
|
19
|
+
municipality: prices.municipality ?? null,
|
|
20
|
+
rural: zonePrice(prices.rural),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function cropPrices(prices) {
|
|
24
|
+
return (prices ?? []).map((price) => compact({
|
|
25
|
+
crop_group: price.cropGroup,
|
|
26
|
+
crop_group_name: price.cropGroupName,
|
|
27
|
+
land_use_codes: price.landUseCodes,
|
|
28
|
+
area_ha: price.areaHa,
|
|
29
|
+
price_per_ha_eur: price.pricePerHaEur,
|
|
30
|
+
sales_count: price.salesCount,
|
|
31
|
+
level: price.level,
|
|
32
|
+
zone: price.zone,
|
|
33
|
+
period: price.period,
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
4
36
|
export function registerGetMarket(server, client) {
|
|
5
37
|
server.registerTool("get_market_data", {
|
|
6
38
|
title: "Get Market Data",
|
|
7
|
-
description: "
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"One API call
|
|
39
|
+
description: "Paid API plans only (Developer, Startup, Growth, Enterprise): with a Free-plan key it answers " +
|
|
40
|
+
"KEY_PLAN_001 and nothing is charged. Rural land only: prices agricultural parcels in Spain (ES, PV, NA), " +
|
|
41
|
+
"small agricultural buildings allowed (sheds, farm stores, ponds, greenhouses), with crop_prices (EUR per " +
|
|
42
|
+
"hectare for each crop group of the parcel, with the number of sales behind it) and zone_prices.rural (the " +
|
|
43
|
+
"province farmland price per hectare). It is the price of the land; buildings are not valued (price_note). " +
|
|
44
|
+
"Housing, industrial or any other non-agricultural property is not supported and answers MKT_001 with " +
|
|
45
|
+
"nothing charged; so does rural land without a price, and any other country. One API call, charged only " +
|
|
46
|
+
"when a price comes back.",
|
|
14
47
|
inputSchema: {
|
|
15
48
|
reference: z.string().min(1).describe("Official cadastral reference"),
|
|
16
49
|
country: z
|
|
17
50
|
.enum(ENRICHMENT_COUNTRIES)
|
|
18
51
|
.optional()
|
|
19
|
-
.describe("Optional country code
|
|
52
|
+
.describe("Optional country code. Rural land prices exist for ES, PV and NA; other countries answer MKT_001. Omit to auto-detect."),
|
|
20
53
|
},
|
|
21
54
|
}, async ({ reference, country }) => {
|
|
22
55
|
try {
|
|
23
56
|
const { data: d, quota } = await client.getMarketData(reference, country);
|
|
24
|
-
const hasFigures = (d.precio_m2_eur ?? 0) > 0 || (d.precio_estimado_eur ?? 0) > 0;
|
|
25
57
|
return jsonResult({
|
|
26
58
|
reference,
|
|
27
59
|
country: country ?? null,
|
|
28
|
-
available: d.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
last_sale_date: d.fecha_ultima_transaccion || null,
|
|
34
|
-
granularity: d.granularidad_display || d.granularidad || null,
|
|
35
|
-
data_quality: d.data_quality ?? null,
|
|
36
|
-
updated: d.fecha_actualizacion || null,
|
|
37
|
-
source: d.fuente ?? null,
|
|
38
|
-
note: d.mensaje_usuario ?? null,
|
|
60
|
+
available: d.available,
|
|
61
|
+
granularity: d.granularity || null,
|
|
62
|
+
crop_prices: cropPrices(d.cropPrices),
|
|
63
|
+
zone_prices: zonePrices(d.zonePrices),
|
|
64
|
+
price_note: d.priceNote ?? null,
|
|
39
65
|
}, quota);
|
|
40
66
|
}
|
|
41
67
|
catch (error) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { CatastroGPSClient } from "../client/catastrogps-api.js";
|
|
3
|
+
export declare function registerGetNeighbors(server: McpServer, client: CatastroGPSClient): void;
|
|
4
|
+
//# sourceMappingURL=get-neighbors.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { REFERENCE_COUNTRIES } from "../types/index.js";
|
|
3
|
+
import { handleToolError, jsonResult } from "./shared.js";
|
|
4
|
+
export function registerGetNeighbors(server, client) {
|
|
5
|
+
server.registerTool("get_neighbors", {
|
|
6
|
+
title: "Get Neighboring Parcels",
|
|
7
|
+
description: "Parcels that touch or surround a parcel (up to 60), each with its cadastral reference and " +
|
|
8
|
+
"centre point. Spain from the official cadastre; other countries from our own copy where we " +
|
|
9
|
+
"hold one. Where neighbours cannot be listed it answers supported=false with an empty list, " +
|
|
10
|
+
"free. One API call.",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
reference: z.string().min(1).describe("Official cadastral reference of the parcel"),
|
|
13
|
+
country: z.enum(REFERENCE_COUNTRIES).optional().describe("Optional country code. Omit to auto-detect."),
|
|
14
|
+
},
|
|
15
|
+
}, async ({ reference, country }) => {
|
|
16
|
+
try {
|
|
17
|
+
const { data: d, quota } = await client.getNeighbors(reference, country);
|
|
18
|
+
return jsonResult({
|
|
19
|
+
reference,
|
|
20
|
+
country: d.country ?? country ?? null,
|
|
21
|
+
supported: d.supported,
|
|
22
|
+
count: d.count,
|
|
23
|
+
neighbors: d.neighbors ?? [],
|
|
24
|
+
}, quota);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
return handleToolError(error);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=get-neighbors.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { CatastroGPSClient } from "../client/catastrogps-api.js";
|
|
3
|
+
export declare function registerGetParcelSIGPAC(server: McpServer, client: CatastroGPSClient): void;
|
|
4
|
+
//# sourceMappingURL=get-parcel-sigpac.d.ts.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CROP_LANGUAGES, SIGPAC_COUNTRIES } from "../types/index.js";
|
|
3
|
+
import { compact, handleToolError, jsonResult } from "./shared.js";
|
|
4
|
+
function mapEnclosure(row, includeGeometry) {
|
|
5
|
+
return {
|
|
6
|
+
...compact({
|
|
7
|
+
id: row.id,
|
|
8
|
+
enclosure: row.enclosure,
|
|
9
|
+
land_use_code: row.landUseCode,
|
|
10
|
+
land_use: row.landUse,
|
|
11
|
+
crop_code: row.cropCode,
|
|
12
|
+
use_class: row.useClass,
|
|
13
|
+
use_class_name: row.useClassName,
|
|
14
|
+
area_ha: row.areaHa,
|
|
15
|
+
}),
|
|
16
|
+
irrigation_pct: row.irrigationPct ?? null,
|
|
17
|
+
mean_slope_pct: row.meanSlopePct ?? null,
|
|
18
|
+
altitude_m: row.altitudeM ?? null,
|
|
19
|
+
pasture_eligibility_pct: row.pastureEligibilityPct ?? null,
|
|
20
|
+
cap_region: row.capRegion ?? null,
|
|
21
|
+
incidents: row.incidents ?? [],
|
|
22
|
+
...(includeGeometry ? { geometry: row.geometry ?? null } : {}),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function registerGetParcelSIGPAC(server, client) {
|
|
26
|
+
server.registerTool("get_parcel_sigpac", {
|
|
27
|
+
title: "Get Parcel SIGPAC Enclosures",
|
|
28
|
+
description: "Every SIGPAC enclosure (recinto) of a Spanish parcel, the CAP land parcel identification system: " +
|
|
29
|
+
"SIGPAC id, land-use code (TA, OV, VI, FY, PS...) with its name in the requested language, area in " +
|
|
30
|
+
"hectares, irrigation coefficient, mean slope, altitude, CAP pasture eligibility and region, " +
|
|
31
|
+
"incidents with their official text and, with include_geometry, the GeoJSON outline. Spain, the " +
|
|
32
|
+
"Basque Country and Navarre only; other countries answer CNV_COVERAGE. match tells whether the " +
|
|
33
|
+
"SIGPAC parcel was found by the cadastral reference or under the parcel's point. Source FEGA " +
|
|
34
|
+
"SIGPAC: cite 'Fuente: FEGA - SIGPAC'. One API call; free when there are no enclosures. If SIGPAC " +
|
|
35
|
+
"does not answer it returns SIG_001: nothing is charged, retry in a few seconds.",
|
|
36
|
+
inputSchema: {
|
|
37
|
+
reference: z.string().min(1).describe("Official Spanish cadastral reference of the parcel or unit"),
|
|
38
|
+
country: z
|
|
39
|
+
.enum(SIGPAC_COUNTRIES)
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Optional: ES, PV (Basque Country) or NA (Navarre). Omit to auto-detect."),
|
|
42
|
+
lang: z.enum(CROP_LANGUAGES).optional().describe("Language of land-use names (default English)"),
|
|
43
|
+
include_geometry: z
|
|
44
|
+
.boolean()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("Include the GeoJSON outline of each enclosure (large). Default false."),
|
|
47
|
+
},
|
|
48
|
+
}, async ({ reference, country, lang, include_geometry }) => {
|
|
49
|
+
try {
|
|
50
|
+
const { data: d, quota } = await client.getSIGPAC(reference, country, lang);
|
|
51
|
+
const parcel = d.sigpacParcel;
|
|
52
|
+
return jsonResult({
|
|
53
|
+
reference: d.reference,
|
|
54
|
+
country: d.country ?? country ?? null,
|
|
55
|
+
sigpac_parcel: parcel
|
|
56
|
+
? {
|
|
57
|
+
province: parcel.province,
|
|
58
|
+
municipality: parcel.municipality,
|
|
59
|
+
aggregate: parcel.aggregate,
|
|
60
|
+
zone: parcel.zone,
|
|
61
|
+
polygon: parcel.polygon,
|
|
62
|
+
parcel: parcel.parcel,
|
|
63
|
+
}
|
|
64
|
+
: null,
|
|
65
|
+
match: d.match ?? null,
|
|
66
|
+
count: d.count,
|
|
67
|
+
total_area_ha: d.totalAreaHa,
|
|
68
|
+
crs: d.crs,
|
|
69
|
+
retrieved_at: d.retrievedAt ?? null,
|
|
70
|
+
attribution: d.source?.attribution ?? null,
|
|
71
|
+
license: d.source?.license ?? null,
|
|
72
|
+
enclosures: (d.enclosures ?? []).map((row) => mapEnclosure(row, include_geometry)),
|
|
73
|
+
}, quota);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return handleToolError(error);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=get-parcel-sigpac.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { CatastroGPSClient } from "../client/catastrogps-api.js";
|
|
3
|
+
export declare function registerGetParcelSubparcels(server: McpServer, client: CatastroGPSClient): void;
|
|
4
|
+
//# sourceMappingURL=get-parcel-subparcels.d.ts.map
|