catastro-gps-mcp 2.1.0 → 2.2.2
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 +14 -0
- package/README.md +46 -11
- package/build/client/catastrogps-api.d.ts +3 -1
- package/build/client/catastrogps-api.js +6 -1
- package/build/http.d.ts +3 -0
- package/build/http.js +15 -0
- package/build/remote.d.ts +12 -0
- package/build/remote.js +132 -0
- package/build/server.js +3 -1
- package/build/tools/get-boundaries.js +2 -2
- package/build/tools/get-market.js +24 -23
- 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.js +2 -1
- package/build/tools/get-parcel.js +8 -5
- package/build/tools/get-value-history.js +2 -1
- package/build/tools/shared.js +6 -3
- package/build/types/index.d.ts +63 -0
- package/build/types/index.js +4 -0
- package/build/version.d.ts +3 -2
- package/build/version.js +2 -1
- package/package.json +3 -3
- package/server.json +19 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.2 (2026-11-16)
|
|
4
|
+
|
|
5
|
+
- One version everywhere: npm, the official registry and `serverInfo.version` of the remote server all report 2.2.2. The registry entry 2.2.1 pointed at npm 2.2.0, so `tools/list` and the registry disagreed.
|
|
6
|
+
|
|
7
|
+
- Remote server at `https://mcp.parcelgps.com/mcp` (Streamable HTTP, stateless): nothing to install. Each request runs on the caller's own key, taken from `Authorization: Bearer`, `X-API-Key` or `?api_key=` for clients that only take a URL; never on a server key. `server.json` declares it under `remotes`.
|
|
8
|
+
- Without a key the remote server still answers `initialize` and `tools/list`, so directories and connector setups can show the tools; any tool call without a key gets 401 with the link to a free key.
|
|
9
|
+
- The remote server calls the API as `catastro-gps-mcp-remote/<version>`, so its traffic is counted apart from the npm server.
|
|
10
|
+
- `build/sse.js` is gone: the remote server replaces the SSE transport, which was never deployed.
|
|
11
|
+
|
|
12
|
+
## 2.2.0 (2026-10-23)
|
|
13
|
+
|
|
14
|
+
- 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.
|
|
15
|
+
- `get_parcel_subparcels` states its real coverage: Spain, Austria, Germany, Czechia, the Netherlands, France, Portugal, Sweden, Switzerland, Finland, Belgium, Ireland, Slovenia, Estonia and Greece.
|
|
16
|
+
|
|
3
17
|
## 2.1.0 (2026-10-21)
|
|
4
18
|
|
|
5
19
|
- 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.
|
package/README.md
CHANGED
|
@@ -2,21 +2,54 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- mcp-name: com.parcelgps/catastro-gps -->
|
|
4
4
|
|
|
5
|
-
Official cadastral parcels for AI agents from **
|
|
5
|
+
Official cadastral parcels for AI agents from the **full cadastre of 27 European countries (including the Basque Country and Navarre foral cadastres)**, with one API key, by cadastral reference and by coordinates. Partial coverage in 2 more: the United Kingdom (Scotland only, by coordinates) and Sweden (agricultural blocks). Every parcel names its official source and licence in `source`.
|
|
6
6
|
|
|
7
7
|
Ask your agent for a parcel by its cadastral reference, by a point on the map or by a postal address. It gets back the reference, location, area, land use and the parcel outline; it can list every dwelling of a Spanish building, read relief, protected areas, climate normals and satellite ground motion, estimate solar and agricultural potential, read aggregated market prices, and score and compare parcels.
|
|
8
8
|
|
|
9
|
-
- **
|
|
9
|
+
- **27 full cadastres plus 2 partial countries, one call shape.** `ES`, `PT`, `FR`, `IT`, `DE`, `PL`, `NL`, `CH`... and the two Spanish foral cadastres (`PV`, `NA`) that the central Catastro does not serve.
|
|
10
10
|
- **The country is optional.** It is detected from the reference format or from the point. When bare digits fit several countries the API says so (`CNV_AMBIGUOUS`) and `resolve_reference` tells you which ones, for free.
|
|
11
11
|
- **Address search in 27 countries.** `"Calle Gran Via 31, Madrid"`, `"8 boulevard du Port, Amiens"` or `"Damrak 1, 1012 LG Amsterdam"` become ranked parcels.
|
|
12
12
|
- **Buildings, not only plots.** `get_units` lists every dwelling, shop and garage of a Spanish building with floor, door, area and participation coefficient.
|
|
13
13
|
- **Your quota in every answer.** Each result carries the monthly quota left, the prepaid balance and the per-minute headroom.
|
|
14
|
-
- **Free tier for good.**
|
|
14
|
+
- **Free tier for good.** 25 calls a month at no cost, no card. Failed lookups are not charged.
|
|
15
15
|
|
|
16
16
|
Get a key at **[parcelgps.com/developers](https://www.parcelgps.com/developers)**.
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
20
|
+
### Remote server, nothing to install
|
|
21
|
+
|
|
22
|
+
The server runs at **`https://mcp.parcelgps.com/mcp`** (Streamable HTTP). Every tool call runs on your own key, so it
|
|
23
|
+
counts against your own quota. Listing the tools needs no key.
|
|
24
|
+
|
|
25
|
+
**Claude Code**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
claude mcp add --transport http parcel-gps https://mcp.parcelgps.com/mcp --header "Authorization: Bearer pk_live_your_key_here"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Cursor, VS Code, Windsurf** (`mcp.json`)
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"mcpServers": {
|
|
36
|
+
"parcel-gps": {
|
|
37
|
+
"url": "https://mcp.parcelgps.com/mcp",
|
|
38
|
+
"headers": { "Authorization": "Bearer pk_live_your_key_here" }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Claude.ai and ChatGPT custom connectors**, or any client that only takes a URL: put the key in the URL and keep
|
|
45
|
+
that URL private.
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
https://mcp.parcelgps.com/mcp?api_key=pk_live_your_key_here
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The key is also accepted in an `X-API-Key` header.
|
|
52
|
+
|
|
20
53
|
### Claude Desktop
|
|
21
54
|
|
|
22
55
|
```json
|
|
@@ -45,11 +78,12 @@ Use the same `npx -y catastro-gps-mcp` command with `CATASTROGPS_API_KEY` in the
|
|
|
45
78
|
|
|
46
79
|
| Tool | What it does | Countries |
|
|
47
80
|
|------|--------------|-----------|
|
|
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
|
|
81
|
+
| `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: Scotland, coordinates only) |
|
|
49
82
|
| `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
83
|
| `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
84
|
| `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, EE, GR |
|
|
85
|
+
| `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 |
|
|
86
|
+
| `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 |
|
|
53
87
|
| `get_crop_catalog` | Free, no quota: every crop code with its name in the chosen language and its land-use class | All crop catalogues |
|
|
54
88
|
| `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) |
|
|
55
89
|
| `list_provinces`, `list_municipalities`, `list_streets` | Spanish cadastre provinces, municipalities (with INE code) and streets of a municipality | ES (common territory) |
|
|
@@ -58,14 +92,14 @@ Use the same `npx -y catastro-gps-mcp` command with `CATASTROGPS_API_KEY` in the
|
|
|
58
92
|
| `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` |
|
|
59
93
|
| `get_solar_potential` | PVGIS photovoltaic estimate: kWp, kWh/year, savings, payback, CO2, tilt | ES, PV, NA, PT, FR, IT, DE |
|
|
60
94
|
| `get_agriculture` | Land use, main crop, NDVI and a reference crop price (SIGPAC detail in Spain) | ES, PV, NA, PT, FR, IT, DE |
|
|
61
|
-
| `get_market_data` |
|
|
95
|
+
| `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 |
|
|
62
96
|
| `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 |
|
|
63
97
|
| `get_value_history` | Area and land-use snapshots of the parcel over time | ES, PV, NA, PT, FR, IT, DE, AT |
|
|
64
98
|
| `compare_parcels` | Two or three parcels side by side: location, solar, agriculture, score | ES, PT, FR, IT, DE (not PV or NA) |
|
|
65
99
|
|
|
66
100
|
## Quota, prepaid balance and limits
|
|
67
101
|
|
|
68
|
-
- 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`
|
|
102
|
+
- 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.
|
|
69
103
|
- 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).
|
|
70
104
|
- 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`.
|
|
71
105
|
- 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.
|
|
@@ -73,7 +107,7 @@ Use the same `npx -y catastro-gps-mcp` command with `CATASTROGPS_API_KEY` in the
|
|
|
73
107
|
|
|
74
108
|
### What the market, score and history tools can and cannot tell
|
|
75
109
|
|
|
76
|
-
- **`get_market_data`**
|
|
110
|
+
- **`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.
|
|
77
111
|
- **`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.
|
|
78
112
|
- **`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.
|
|
79
113
|
- **`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.
|
|
@@ -102,9 +136,9 @@ What each code answers today (measured against production on 1 October 2026). "P
|
|
|
102
136
|
| `LV` | Latvia | with `country: LV` | yes | yes | |
|
|
103
137
|
| `GR` | Greece | with `country: GR` | yes | yes | |
|
|
104
138
|
| `PT` | Portugal | yes | partial | partial | The cadastre does not cover Lisbon, Porto or Coimbra; the DGT source is often down |
|
|
105
|
-
| `IE` | Ireland | with `country: IE` (SP_ID) |
|
|
139
|
+
| `IE` | Ireland | with `country: IE` (SP_ID) | registered land | partial | Unregistered land answers `CNV_COVERAGE` (Tailte Éireann, CC BY 4.0) |
|
|
106
140
|
| `UK` | United Kingdom | no | Scotland only | Scotland only | England, Wales and Northern Ireland not yet |
|
|
107
|
-
| `HR` | Croatia |
|
|
141
|
+
| `HR` | Croatia | yes (`334553-6250/3` or `6250/3 k.o. Zabok`) | yes | no | Full DGU cadastre (Otvorena dozvola); a bare parcel number lists its cadastral municipalities |
|
|
108
142
|
| `SE` | Sweden | agricultural blocks | agricultural blocks | no | Not property units |
|
|
109
143
|
|
|
110
144
|
Hungary, Romania and the rest of Europe are not covered: a reference or point there answers `CNV_COVERAGE`. Data comes from each country's official cadastre or INSPIRE service (Spain from our copy of the Catastro), so availability follows theirs; when one is down the server answers `SERVICE_UNAVAILABLE`, which is free.
|
|
@@ -165,7 +199,7 @@ The same key works for this server, the REST API and the SDKs ([`catastrogps`](h
|
|
|
165
199
|
|
|
166
200
|
| Plan | Price | Calls / month |
|
|
167
201
|
|------|-------|---------------|
|
|
168
|
-
| Free | €0, forever |
|
|
202
|
+
| Free | €0, forever | 25 |
|
|
169
203
|
| Developer | €19 / month | 5,000 |
|
|
170
204
|
| Startup | €49 / month | 15,000 |
|
|
171
205
|
| Growth | €99 / month | 50,000 |
|
|
@@ -190,6 +224,7 @@ npm test
|
|
|
190
224
|
npm run test:coverage
|
|
191
225
|
npm run build
|
|
192
226
|
CATASTROGPS_API_KEY=pk_live_xxx node build/index.js
|
|
227
|
+
node build/http.js
|
|
193
228
|
```
|
|
194
229
|
|
|
195
230
|
## License
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Quota, ServerConfig, ApiResponse, ParcelData, PolygonData, SolarData, TerrainData, GroundMotionData, AgroData, MarketData, ScoreData, ValueHistoryData, CompareData, CoordinatesSearchData, AddressCandidatesData, UnitsPageData, ResolveData, SubparcelsData, CropCatalogData, NeighborsData, ProvincesData, MunicipalitiesData, StreetsData } 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;
|
|
@@ -18,6 +18,7 @@ export declare class CatastroGPSClient {
|
|
|
18
18
|
private readonly apiKey;
|
|
19
19
|
private readonly baseUrl;
|
|
20
20
|
private readonly timeout;
|
|
21
|
+
private readonly userAgent;
|
|
21
22
|
lastQuota?: Quota;
|
|
22
23
|
constructor(config: ServerConfig);
|
|
23
24
|
private buildUrl;
|
|
@@ -25,6 +26,7 @@ export declare class CatastroGPSClient {
|
|
|
25
26
|
private parcelPath;
|
|
26
27
|
getParcelByReference(reference: string, country?: string, lang?: string): Promise<ApiResponse<ParcelData>>;
|
|
27
28
|
getSubparcels(reference: string, country?: string, lang?: string): Promise<ApiResponse<SubparcelsData>>;
|
|
29
|
+
getSIGPAC(reference: string, country?: string, lang?: string): Promise<ApiResponse<SIGPACData>>;
|
|
28
30
|
getNeighbors(reference: string, country?: string): Promise<ApiResponse<NeighborsData>>;
|
|
29
31
|
getCropCatalog(lang?: string): Promise<ApiResponse<CropCatalogData>>;
|
|
30
32
|
listProvinces(): Promise<ApiResponse<ProvincesData>>;
|
|
@@ -84,11 +84,13 @@ export class CatastroGPSClient {
|
|
|
84
84
|
apiKey;
|
|
85
85
|
baseUrl;
|
|
86
86
|
timeout;
|
|
87
|
+
userAgent;
|
|
87
88
|
lastQuota;
|
|
88
89
|
constructor(config) {
|
|
89
90
|
this.apiKey = config.apiKey;
|
|
90
91
|
this.baseUrl = config.apiUrl.replace(/\/$/, "");
|
|
91
92
|
this.timeout = config.timeout;
|
|
93
|
+
this.userAgent = config.userAgent ?? USER_AGENT;
|
|
92
94
|
}
|
|
93
95
|
buildUrl(path, params) {
|
|
94
96
|
const url = new URL(`${this.baseUrl}${path}`);
|
|
@@ -105,7 +107,7 @@ export class CatastroGPSClient {
|
|
|
105
107
|
const headers = {
|
|
106
108
|
"X-API-Key": this.apiKey,
|
|
107
109
|
Accept: "application/json",
|
|
108
|
-
"User-Agent":
|
|
110
|
+
"User-Agent": this.userAgent,
|
|
109
111
|
};
|
|
110
112
|
if (body !== undefined) {
|
|
111
113
|
headers["Content-Type"] = "application/json";
|
|
@@ -151,6 +153,9 @@ export class CatastroGPSClient {
|
|
|
151
153
|
async getSubparcels(reference, country, lang) {
|
|
152
154
|
return this.send("GET", this.parcelPath(reference, "/subparcels"), { country, lang });
|
|
153
155
|
}
|
|
156
|
+
async getSIGPAC(reference, country, lang) {
|
|
157
|
+
return this.send("GET", this.parcelPath(reference, "/sigpac"), { country, lang });
|
|
158
|
+
}
|
|
154
159
|
async getNeighbors(reference, country) {
|
|
155
160
|
return this.send("GET", this.parcelPath(reference, "/neighbors"), { country });
|
|
156
161
|
}
|
package/build/http.d.ts
ADDED
package/build/http.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createServer as createHttpServer } from "node:http";
|
|
3
|
+
import { loadEndpointConfig } from "./server.js";
|
|
4
|
+
import { createRemoteHandler, MCP_PATH } from "./remote.js";
|
|
5
|
+
const DEFAULT_PORT = 3001;
|
|
6
|
+
const log = (msg) => console.error(`[catastro-gps-mcp] ${msg}`);
|
|
7
|
+
function main() {
|
|
8
|
+
const port = parseInt(process.env.MCP_PORT || process.env.PORT || "", 10) || DEFAULT_PORT;
|
|
9
|
+
const httpServer = createHttpServer(createRemoteHandler(loadEndpointConfig(), log));
|
|
10
|
+
httpServer.listen(port, () => {
|
|
11
|
+
log(`Streamable HTTP server listening on :${port}${MCP_PATH}`);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
main();
|
|
15
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { type EndpointConfig } from "./server.js";
|
|
3
|
+
export declare const MCP_PATH = "/mcp";
|
|
4
|
+
export declare const DEVELOPERS_URL = "https://www.parcelgps.com/developers";
|
|
5
|
+
export declare const MAX_BODY_BYTES: number;
|
|
6
|
+
type Log = (msg: string) => void;
|
|
7
|
+
export declare function apiKeyFromRequest(headers: IncomingHttpHeaders, url: URL): string | undefined;
|
|
8
|
+
export declare function callsATool(body: unknown): boolean;
|
|
9
|
+
export declare function describeRpc(body: unknown): string;
|
|
10
|
+
export declare function createRemoteHandler(endpoint: EndpointConfig, log?: Log): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=remote.d.ts.map
|
package/build/remote.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
2
|
+
import { createServer, sessionConfig } from "./server.js";
|
|
3
|
+
import { REMOTE_USER_AGENT, SERVER_NAME, SERVER_VERSION } from "./version.js";
|
|
4
|
+
export const MCP_PATH = "/mcp";
|
|
5
|
+
export const DEVELOPERS_URL = "https://www.parcelgps.com/developers";
|
|
6
|
+
export const MAX_BODY_BYTES = 1024 * 1024;
|
|
7
|
+
const BEARER_PREFIX = /^bearer\s+/i;
|
|
8
|
+
const JSONRPC_PARSE_ERROR = -32700;
|
|
9
|
+
const JSONRPC_SERVER_ERROR = -32000;
|
|
10
|
+
export function apiKeyFromRequest(headers, url) {
|
|
11
|
+
const authorization = headers.authorization?.trim();
|
|
12
|
+
if (authorization && BEARER_PREFIX.test(authorization)) {
|
|
13
|
+
return authorization.replace(BEARER_PREFIX, "").trim() || undefined;
|
|
14
|
+
}
|
|
15
|
+
const header = headers["x-api-key"];
|
|
16
|
+
const fromHeader = (Array.isArray(header) ? header[0] : header)?.trim();
|
|
17
|
+
if (fromHeader)
|
|
18
|
+
return fromHeader;
|
|
19
|
+
return url.searchParams.get("api_key")?.trim() || undefined;
|
|
20
|
+
}
|
|
21
|
+
export function callsATool(body) {
|
|
22
|
+
const messages = (Array.isArray(body) ? body : [body]);
|
|
23
|
+
return messages.some((m) => m?.method === "tools/call");
|
|
24
|
+
}
|
|
25
|
+
export function describeRpc(body) {
|
|
26
|
+
const messages = (Array.isArray(body) ? body : [body]);
|
|
27
|
+
return messages
|
|
28
|
+
.map((m) => {
|
|
29
|
+
if (m?.method === "tools/call")
|
|
30
|
+
return `tools/call:${m.params?.name ?? "?"}`;
|
|
31
|
+
if (m?.method === "initialize") {
|
|
32
|
+
const client = m.params?.clientInfo;
|
|
33
|
+
return `initialize:${client?.name ?? "?"}/${client?.version ?? "?"}`;
|
|
34
|
+
}
|
|
35
|
+
return m?.method ?? "response";
|
|
36
|
+
})
|
|
37
|
+
.join(",");
|
|
38
|
+
}
|
|
39
|
+
function sendJson(res, status, body, headers = {}) {
|
|
40
|
+
res.writeHead(status, { "Content-Type": "application/json", ...headers });
|
|
41
|
+
res.end(JSON.stringify(body));
|
|
42
|
+
}
|
|
43
|
+
function rpcError(res, status, code, message) {
|
|
44
|
+
sendJson(res, status, { jsonrpc: "2.0", error: { code, message }, id: null });
|
|
45
|
+
}
|
|
46
|
+
async function readJsonBody(req) {
|
|
47
|
+
const chunks = [];
|
|
48
|
+
let size = 0;
|
|
49
|
+
for await (const chunk of req) {
|
|
50
|
+
size += chunk.length;
|
|
51
|
+
if (size > MAX_BODY_BYTES)
|
|
52
|
+
throw new RangeError("body too large");
|
|
53
|
+
chunks.push(chunk);
|
|
54
|
+
}
|
|
55
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
56
|
+
}
|
|
57
|
+
function setCors(res) {
|
|
58
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
59
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
|
60
|
+
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-API-Key, Mcp-Session-Id, Mcp-Protocol-Version, Last-Event-ID");
|
|
61
|
+
res.setHeader("Access-Control-Expose-Headers", "Mcp-Session-Id");
|
|
62
|
+
}
|
|
63
|
+
function discoveryConfig(endpoint, body) {
|
|
64
|
+
return callsATool(body) ? null : { ...endpoint, apiKey: "" };
|
|
65
|
+
}
|
|
66
|
+
async function handleMcpPost(req, res, endpoint, url, log) {
|
|
67
|
+
const startedAt = Date.now();
|
|
68
|
+
let body;
|
|
69
|
+
try {
|
|
70
|
+
body = await readJsonBody(req);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
const tooLarge = error instanceof RangeError;
|
|
74
|
+
rpcError(res, tooLarge ? 413 : 400, JSONRPC_PARSE_ERROR, tooLarge ? "Request body too large" : "Invalid JSON");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const rpc = describeRpc(body);
|
|
78
|
+
const config = sessionConfig(endpoint, apiKeyFromRequest(req.headers, url)) ?? discoveryConfig(endpoint, body);
|
|
79
|
+
if (!config) {
|
|
80
|
+
rpcError(res, 401, JSONRPC_SERVER_ERROR, `Your own Parcel GPS API key is required: send "Authorization: Bearer <key>" or add ?api_key=<key> ` +
|
|
81
|
+
`to the URL. Free key (25 calls/month): ${DEVELOPERS_URL}`);
|
|
82
|
+
log(`POST ${MCP_PATH} ${rpc} 401 ${Date.now() - startedAt}ms`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const server = createServer({ ...config, userAgent: REMOTE_USER_AGENT });
|
|
86
|
+
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: true });
|
|
87
|
+
res.on("close", () => {
|
|
88
|
+
void transport.close();
|
|
89
|
+
void server.close();
|
|
90
|
+
log(`POST ${MCP_PATH} ${rpc} ${res.statusCode} ${Date.now() - startedAt}ms`);
|
|
91
|
+
});
|
|
92
|
+
await server.connect(transport);
|
|
93
|
+
await transport.handleRequest(req, res, body);
|
|
94
|
+
}
|
|
95
|
+
export function createRemoteHandler(endpoint, log = () => { }) {
|
|
96
|
+
return async (req, res) => {
|
|
97
|
+
setCors(res);
|
|
98
|
+
const url = new URL(req.url || "/", "http://localhost");
|
|
99
|
+
if (req.method === "OPTIONS") {
|
|
100
|
+
res.writeHead(204);
|
|
101
|
+
res.end();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (url.pathname === "/health") {
|
|
105
|
+
sendJson(res, 200, { status: "ok", server: SERVER_NAME, version: SERVER_VERSION });
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (url.pathname === "/" && req.method === "GET") {
|
|
109
|
+
res.writeHead(302, { Location: DEVELOPERS_URL });
|
|
110
|
+
res.end();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (url.pathname !== MCP_PATH) {
|
|
114
|
+
sendJson(res, 404, { error: "Not found" });
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (req.method !== "POST") {
|
|
118
|
+
res.setHeader("Allow", "POST, OPTIONS");
|
|
119
|
+
rpcError(res, 405, JSONRPC_SERVER_ERROR, "Method not allowed: this server is stateless, use POST");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
await handleMcpPost(req, res, endpoint, url, log);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
log(`POST ${MCP_PATH} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
127
|
+
if (!res.headersSent)
|
|
128
|
+
rpcError(res, 500, JSONRPC_SERVER_ERROR, "Internal server error");
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=remote.js.map
|
package/build/server.js
CHANGED
|
@@ -14,6 +14,7 @@ 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
16
|
import { registerGetParcelSubparcels } from "./tools/get-parcel-subparcels.js";
|
|
17
|
+
import { registerGetParcelSIGPAC } from "./tools/get-parcel-sigpac.js";
|
|
17
18
|
import { registerGetCropCatalog } from "./tools/get-crop-catalog.js";
|
|
18
19
|
import { registerGetNeighbors } from "./tools/get-neighbors.js";
|
|
19
20
|
import { registerListProvinces } from "./tools/list-provinces.js";
|
|
@@ -42,6 +43,7 @@ export function createServer(config) {
|
|
|
42
43
|
registerGetUnits(server, client);
|
|
43
44
|
registerResolveReference(server, client);
|
|
44
45
|
registerGetParcelSubparcels(server, client);
|
|
46
|
+
registerGetParcelSIGPAC(server, client);
|
|
45
47
|
registerGetCropCatalog(server, client);
|
|
46
48
|
registerGetNeighbors(server, client);
|
|
47
49
|
registerListProvinces(server, client);
|
|
@@ -60,7 +62,7 @@ export function loadConfig() {
|
|
|
60
62
|
const apiKey = process.env.CATASTROGPS_API_KEY;
|
|
61
63
|
if (!apiKey) {
|
|
62
64
|
console.error("[catastro-gps-mcp] ERROR: CATASTROGPS_API_KEY environment variable is required.\n" +
|
|
63
|
-
"Get a free key (
|
|
65
|
+
"Get a free key (25 calls/month, failed lookups are free) at https://www.parcelgps.com/developers");
|
|
64
66
|
process.exit(1);
|
|
65
67
|
}
|
|
66
68
|
return { apiKey, ...loadEndpointConfig() };
|
|
@@ -5,8 +5,8 @@ export function registerGetBoundaries(server, client) {
|
|
|
5
5
|
server.registerTool("get_boundaries", {
|
|
6
6
|
title: "Get Parcel Boundaries",
|
|
7
7
|
description: "Get the outline of a cadastral parcel as GeoJSON and/or a [lat, lng] ring, plus its " +
|
|
8
|
-
"centroid and area, for mapping and GIS work. Accepts references from the same
|
|
9
|
-
"codes as get_parcel
|
|
8
|
+
"centroid and area, for mapping and GIS work. Accepts references from the same 31 " +
|
|
9
|
+
"codes as get_parcel except the United Kingdom, which is coordinates only.",
|
|
10
10
|
inputSchema: {
|
|
11
11
|
reference: z.string().min(1).describe("Official cadastral reference"),
|
|
12
12
|
country: z
|
|
@@ -7,8 +7,6 @@ function zonePrice(price) {
|
|
|
7
7
|
return compact({
|
|
8
8
|
price_per_m2_eur: price.pricePerM2Eur,
|
|
9
9
|
price_per_ha_eur: price.pricePerHaEur,
|
|
10
|
-
statistic: price.statistic,
|
|
11
|
-
authority: price.authority,
|
|
12
10
|
period: price.period,
|
|
13
11
|
});
|
|
14
12
|
}
|
|
@@ -19,48 +17,51 @@ function zonePrices(prices) {
|
|
|
19
17
|
zone: prices.zone,
|
|
20
18
|
zone_level: prices.zoneLevel,
|
|
21
19
|
municipality: prices.municipality ?? null,
|
|
22
|
-
urban: zonePrice(prices.urban),
|
|
23
20
|
rural: zonePrice(prices.rural),
|
|
24
21
|
};
|
|
25
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
|
+
}
|
|
26
36
|
export function registerGetMarket(server, client) {
|
|
27
37
|
server.registerTool("get_market_data", {
|
|
28
38
|
title: "Get Market Data",
|
|
29
|
-
description: "
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"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.",
|
|
38
47
|
inputSchema: {
|
|
39
48
|
reference: z.string().min(1).describe("Official cadastral reference"),
|
|
40
49
|
country: z
|
|
41
50
|
.enum(ENRICHMENT_COUNTRIES)
|
|
42
51
|
.optional()
|
|
43
|
-
.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."),
|
|
44
53
|
},
|
|
45
54
|
}, async ({ reference, country }) => {
|
|
46
55
|
try {
|
|
47
56
|
const { data: d, quota } = await client.getMarketData(reference, country);
|
|
48
|
-
const hasFigures = (d.pricePerM2Eur ?? 0) > 0 || (d.estimatedPriceEur ?? 0) > 0;
|
|
49
57
|
return jsonResult({
|
|
50
58
|
reference,
|
|
51
59
|
country: country ?? null,
|
|
52
60
|
available: d.available,
|
|
53
|
-
has_price_figures: hasFigures,
|
|
54
|
-
price_per_m2_eur: d.pricePerM2Eur || null,
|
|
55
|
-
estimated_value_eur: d.estimatedPriceEur || null,
|
|
56
|
-
sales_count: d.salesCount || null,
|
|
57
|
-
last_sale_date: d.lastSaleDate || null,
|
|
58
61
|
granularity: d.granularity || null,
|
|
59
|
-
|
|
60
|
-
updated: d.updatedAt || null,
|
|
61
|
-
source: d.source ?? null,
|
|
62
|
-
note: d.message || null,
|
|
62
|
+
crop_prices: cropPrices(d.cropPrices),
|
|
63
63
|
zone_prices: zonePrices(d.zonePrices),
|
|
64
|
+
price_note: d.priceNote ?? null,
|
|
64
65
|
}, quota);
|
|
65
66
|
}
|
|
66
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 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
|
|
@@ -9,7 +9,8 @@ export function registerGetParcelSubparcels(server, client) {
|
|
|
9
9
|
"(cadastral, declaredCrop, landCover), a common use_class (arable, vineyard, olive, forest...), " +
|
|
10
10
|
"intensity, land type and class, source and, with include_geometry, its GeoJSON outline. " +
|
|
11
11
|
"Spain (Catastro, including Bizkaia, Alava, Navarre; Gipuzkoa without outlines), Austria, " +
|
|
12
|
-
"
|
|
12
|
+
"Germany, Czechia, the Netherlands, France, Portugal, Sweden, Switzerland, Finland, Belgium, " +
|
|
13
|
+
"Ireland, Slovenia, Estonia and Greece. One API call; free when the parcel has none. If the source does not " +
|
|
13
14
|
"answer it returns SUB_001: nothing is charged, retry in a few seconds. Translate codes with " +
|
|
14
15
|
"get_crop_catalog.",
|
|
15
16
|
inputSchema: {
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { COUNTRY_CODES_TEXT, CROP_LANGUAGES, SUPPORTED_COUNTRIES } from "../types/index.js";
|
|
2
|
+
import { COORDINATES_ONLY_MESSAGES, COUNTRY_CODES_TEXT, CROP_LANGUAGES, SUPPORTED_COUNTRIES, } from "../types/index.js";
|
|
3
3
|
import { compact, errorResult, handleToolError, jsonResult } from "./shared.js";
|
|
4
4
|
export function registerGetParcel(server, client) {
|
|
5
5
|
server.registerTool("get_parcel", {
|
|
6
6
|
title: "Get Parcel",
|
|
7
|
-
description: "Look up a
|
|
8
|
-
"foral cadastres) by its official cadastral reference or by WGS84 coordinates
|
|
7
|
+
description: "Look up a parcel in the official cadastre of 27 European countries (including the Basque Country and " +
|
|
8
|
+
"Navarre foral cadastres), by its official cadastral reference or by WGS84 coordinates, plus partial " +
|
|
9
|
+
"coverage in the United Kingdom (Scotland, coordinates only) and Sweden (agricultural blocks). Returns the " +
|
|
9
10
|
"reference, location, address, municipality, area, land use and the parcel outline when " +
|
|
10
11
|
"the official source provides them. The country is detected from the reference format or " +
|
|
11
12
|
"the point when omitted. Where the parcel has crop or land-use parts it also returns their count " +
|
|
12
13
|
"and a crop summary (crop and share of the area); the full list with outlines is " +
|
|
13
|
-
"get_parcel_subparcels.
|
|
14
|
+
"get_parcel_subparcels. Croatia: cadastral municipality code + parcel number (334553-6250/3) or " +
|
|
15
|
+
"'6250/3 k.o. Zabok'. Ireland: registered land only. Every result names its official source and licence " +
|
|
16
|
+
"in the source field. Codes: " + COUNTRY_CODES_TEXT + ".",
|
|
14
17
|
inputSchema: {
|
|
15
18
|
reference: z
|
|
16
19
|
.string()
|
|
@@ -29,7 +32,7 @@ export function registerGetParcel(server, client) {
|
|
|
29
32
|
try {
|
|
30
33
|
if (reference) {
|
|
31
34
|
if (country === "UK") {
|
|
32
|
-
return errorResult("MCP_002",
|
|
35
|
+
return errorResult("MCP_002", COORDINATES_ONLY_MESSAGES[country]);
|
|
33
36
|
}
|
|
34
37
|
const { data: d, quota } = await client.getParcelByReference(reference, country, lang);
|
|
35
38
|
return jsonResult(compact({
|
|
@@ -4,7 +4,8 @@ import { handleToolError, jsonResult } from "./shared.js";
|
|
|
4
4
|
export function registerGetValueHistory(server, client) {
|
|
5
5
|
server.registerTool("get_value_history", {
|
|
6
6
|
title: "Get Parcel History",
|
|
7
|
-
description: "
|
|
7
|
+
description: "Paid API plans only: with a Free-plan key it answers KEY_PLAN_001 and nothing is charged. " +
|
|
8
|
+
"Snapshots of a parcel as the official cadastre reported it over time: area and land use, " +
|
|
8
9
|
"at most one snapshot every 30 days. History starts the first time anyone looks the parcel " +
|
|
9
10
|
"up through CatastroGPS (get_parcel) and grows from there, so a parcel never queried before " +
|
|
10
11
|
"returns an empty list. The official cadastral value is not recorded yet (always null). " +
|
package/build/tools/shared.js
CHANGED
|
@@ -3,9 +3,9 @@ const log = (msg) => console.error(`[catastro-gps-mcp] ${msg}`);
|
|
|
3
3
|
const PRICING_URL = "https://www.parcelgps.com/developers";
|
|
4
4
|
const TOP_UP_URL = "https://parcelgps.com/app/developer";
|
|
5
5
|
const FRIENDLY_MESSAGES = {
|
|
6
|
-
KEY_AUTH_001: "Invalid API key format. Check CATASTROGPS_API_KEY.",
|
|
7
|
-
KEY_AUTH_002: "Unknown API key. Check CATASTROGPS_API_KEY.",
|
|
8
|
-
KEY_AUTH_003: "Invalid API key. Check CATASTROGPS_API_KEY.",
|
|
6
|
+
KEY_AUTH_001: "Invalid API key format. Check CATASTROGPS_API_KEY or the key of your remote connector.",
|
|
7
|
+
KEY_AUTH_002: "Unknown API key. Check CATASTROGPS_API_KEY or the key of your remote connector.",
|
|
8
|
+
KEY_AUTH_003: "Invalid API key. Check CATASTROGPS_API_KEY or the key of your remote connector.",
|
|
9
9
|
KEY_AUTH_004: `Monthly quota used up. Upgrade at ${PRICING_URL} or turn on prepaid overage and top up at ${TOP_UP_URL}`,
|
|
10
10
|
KEY_AUTH_005: "The API could not verify your organization. Try again later.",
|
|
11
11
|
KEY_RATE_001: "Too many requests. Slow down and retry.",
|
|
@@ -13,6 +13,8 @@ const FRIENDLY_MESSAGES = {
|
|
|
13
13
|
RATE_LIMIT_EXCEEDED: "Too many requests. Slow down and retry.",
|
|
14
14
|
UNAUTHORIZED: `Missing or invalid API key. Get one at ${PRICING_URL}`,
|
|
15
15
|
PRO_REQUIRED: `This endpoint needs a developer API key. Get one at ${PRICING_URL}`,
|
|
16
|
+
KEY_PLAN_001: `Price data (market and value history) is only available on paid API plans. Nothing was charged. Upgrade at ${PRICING_URL}`,
|
|
17
|
+
MKT_001: "No price can be estimated for this parcel: price data only covers rural land (agricultural parcels in Spain; small agricultural buildings such as sheds, ponds or greenhouses are allowed). Housing, industrial or any other non-agricultural property is not supported, and rural land without a price gives the same answer. Nothing was charged.",
|
|
16
18
|
NOT_FOUND: "Nothing found. Check the reference (or address) and the country code.",
|
|
17
19
|
VALIDATION_ERROR: "Invalid input. Check the reference format for this country.",
|
|
18
20
|
CNV_COVERAGE: "That reference or point is in a country that is not covered yet.",
|
|
@@ -20,6 +22,7 @@ const FRIENDLY_MESSAGES = {
|
|
|
20
22
|
CNV_PLACE_NAME: "That looks like a place name, not a cadastral reference. Use coordinates or search_address instead.",
|
|
21
23
|
SERVICE_UNAVAILABLE: "The official cadastre for this country is not responding. Try again in a few minutes.",
|
|
22
24
|
SUB_001: "The subparcels of this parcel could not be read right now. Nothing was charged; retry in a few seconds.",
|
|
25
|
+
SIG_001: "SIGPAC could not be read right now. Nothing was charged; retry in a few seconds.",
|
|
23
26
|
INTERNAL_ERROR: "Internal server error. Try again later.",
|
|
24
27
|
MCP_TIMEOUT: "The request timed out. Official cadastres can be slow; try again or raise CATASTROGPS_TIMEOUT.",
|
|
25
28
|
MCP_NETWORK: "Could not reach the CatastroGPS API. Check your connection or CATASTROGPS_API_URL.",
|
package/build/types/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type CountryCode = (typeof SUPPORTED_COUNTRIES)[number];
|
|
|
3
3
|
export declare const COORDINATES_ONLY_COUNTRIES: readonly ["UK"];
|
|
4
4
|
export declare const REFERENCE_COUNTRIES: readonly ["ES", "PV", "NA", "PT", "FR", "IT", "DE", "AT", "CH", "LI", "BE", "NL", "LU", "PL", "CZ", "SK", "SI", "HR", "BG", "GR", "CY", "DK", "SE", "NO", "FI", "IS", "EE", "LV", "LT", "IE"];
|
|
5
5
|
export type ReferenceCountryCode = (typeof REFERENCE_COUNTRIES)[number];
|
|
6
|
+
export declare const COORDINATES_ONLY_MESSAGES: Record<(typeof COORDINATES_ONLY_COUNTRIES)[number], string>;
|
|
6
7
|
export declare const ENRICHMENT_COUNTRIES: readonly ["ES", "PV", "NA", "PT", "FR", "IT", "DE"];
|
|
7
8
|
export type EnrichmentCountryCode = (typeof ENRICHMENT_COUNTRIES)[number];
|
|
8
9
|
export declare const VALUE_HISTORY_COUNTRIES: readonly ["ES", "PV", "NA", "PT", "FR", "IT", "DE", "AT"];
|
|
@@ -117,6 +118,53 @@ export interface SubparcelsData {
|
|
|
117
118
|
count: number;
|
|
118
119
|
subparcels: Subparcel[];
|
|
119
120
|
}
|
|
121
|
+
export declare const SIGPAC_COUNTRIES: readonly ["ES", "PV", "NA"];
|
|
122
|
+
export interface SIGPACParcelKey {
|
|
123
|
+
province: number;
|
|
124
|
+
municipality: number;
|
|
125
|
+
aggregate: number;
|
|
126
|
+
zone: number;
|
|
127
|
+
polygon: number;
|
|
128
|
+
parcel: number;
|
|
129
|
+
}
|
|
130
|
+
export interface SIGPACEnclosure extends SIGPACParcelKey {
|
|
131
|
+
id: string;
|
|
132
|
+
enclosure: number;
|
|
133
|
+
landUseCode: string;
|
|
134
|
+
landUse?: string;
|
|
135
|
+
cropCode?: string;
|
|
136
|
+
useClass?: string;
|
|
137
|
+
useClassName?: string;
|
|
138
|
+
areaHa: number;
|
|
139
|
+
irrigationPct: number | null;
|
|
140
|
+
meanSlopePct: number | null;
|
|
141
|
+
altitudeM: number | null;
|
|
142
|
+
pastureEligibilityPct: number | null;
|
|
143
|
+
capRegion: number | null;
|
|
144
|
+
incidents: Array<{
|
|
145
|
+
code: number;
|
|
146
|
+
description?: string;
|
|
147
|
+
}> | null;
|
|
148
|
+
geometry: unknown;
|
|
149
|
+
}
|
|
150
|
+
export interface SIGPACData {
|
|
151
|
+
reference: string;
|
|
152
|
+
country: string;
|
|
153
|
+
sigpacParcel: SIGPACParcelKey | null;
|
|
154
|
+
match?: "reference" | "point";
|
|
155
|
+
count: number;
|
|
156
|
+
totalAreaHa: number;
|
|
157
|
+
crs: string;
|
|
158
|
+
retrievedAt?: string;
|
|
159
|
+
source?: {
|
|
160
|
+
name?: string;
|
|
161
|
+
provider?: string;
|
|
162
|
+
license?: string;
|
|
163
|
+
attribution?: string;
|
|
164
|
+
url?: string;
|
|
165
|
+
};
|
|
166
|
+
enclosures: SIGPACEnclosure[] | null;
|
|
167
|
+
}
|
|
120
168
|
export interface CropReference {
|
|
121
169
|
code: string;
|
|
122
170
|
source: string;
|
|
@@ -425,6 +473,20 @@ export interface MarketData {
|
|
|
425
473
|
dataQuality?: string;
|
|
426
474
|
updatedAt?: string;
|
|
427
475
|
zonePrices?: ZonePrices;
|
|
476
|
+
cropPrices?: CropLandPrice[];
|
|
477
|
+
priceNote?: string;
|
|
478
|
+
}
|
|
479
|
+
export interface CropLandPrice {
|
|
480
|
+
cropGroup: string;
|
|
481
|
+
cropGroupName?: string;
|
|
482
|
+
landUseCodes?: string[];
|
|
483
|
+
basis?: string;
|
|
484
|
+
areaHa?: number;
|
|
485
|
+
pricePerHaEur: number;
|
|
486
|
+
salesCount?: number;
|
|
487
|
+
level?: string;
|
|
488
|
+
zone?: string;
|
|
489
|
+
period?: string;
|
|
428
490
|
}
|
|
429
491
|
export interface OfficialZonePrice {
|
|
430
492
|
pricePerM2Eur: number;
|
|
@@ -504,5 +566,6 @@ export interface ServerConfig {
|
|
|
504
566
|
apiKey: string;
|
|
505
567
|
apiUrl: string;
|
|
506
568
|
timeout: number;
|
|
569
|
+
userAgent?: string;
|
|
507
570
|
}
|
|
508
571
|
//# sourceMappingURL=index.d.ts.map
|
package/build/types/index.js
CHANGED
|
@@ -10,6 +10,9 @@ export const REFERENCE_COUNTRIES = [
|
|
|
10
10
|
"BE", "NL", "LU", "PL", "CZ", "SK", "SI", "HR", "BG", "GR",
|
|
11
11
|
"CY", "DK", "SE", "NO", "FI", "IS", "EE", "LV", "LT", "IE",
|
|
12
12
|
];
|
|
13
|
+
export const COORDINATES_ONLY_MESSAGES = {
|
|
14
|
+
UK: "United Kingdom parcels can only be looked up by coordinates, and only in Scotland.",
|
|
15
|
+
};
|
|
13
16
|
export const ENRICHMENT_COUNTRIES = ["ES", "PV", "NA", "PT", "FR", "IT", "DE"];
|
|
14
17
|
export const VALUE_HISTORY_COUNTRIES = ["ES", "PV", "NA", "PT", "FR", "IT", "DE", "AT"];
|
|
15
18
|
export const SITE_ANALYSIS_COUNTRIES = [
|
|
@@ -30,4 +33,5 @@ export const COUNTRY_CODES_TEXT = "ES Spain, PV Basque Country, NA Navarre, PT P
|
|
|
30
33
|
"PL Poland, CZ Czechia, SK Slovakia, SI Slovenia, HR Croatia, BG Bulgaria, GR Greece, " +
|
|
31
34
|
"CY Cyprus, DK Denmark, SE Sweden, NO Norway, FI Finland, IS Iceland, EE Estonia, " +
|
|
32
35
|
"LV Latvia, LT Lithuania, IE Ireland, UK United Kingdom";
|
|
36
|
+
export const SIGPAC_COUNTRIES = ["ES", "PV", "NA"];
|
|
33
37
|
//# sourceMappingURL=index.js.map
|
package/build/version.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const SERVER_NAME = "catastro-gps-mcp";
|
|
2
|
-
export declare const SERVER_VERSION = "2.
|
|
3
|
-
export declare const USER_AGENT = "catastro-gps-mcp/2.
|
|
2
|
+
export declare const SERVER_VERSION = "2.2.2";
|
|
3
|
+
export declare const USER_AGENT = "catastro-gps-mcp/2.2.2";
|
|
4
|
+
export declare const REMOTE_USER_AGENT = "catastro-gps-mcp-remote/2.2.2";
|
|
4
5
|
//# sourceMappingURL=version.d.ts.map
|
package/build/version.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const SERVER_NAME = "catastro-gps-mcp";
|
|
2
|
-
export const SERVER_VERSION = "2.
|
|
2
|
+
export const SERVER_VERSION = "2.2.2";
|
|
3
3
|
export const USER_AGENT = `${SERVER_NAME}/${SERVER_VERSION}`;
|
|
4
|
+
export const REMOTE_USER_AGENT = `${SERVER_NAME}-remote/${SERVER_VERSION}`;
|
|
4
5
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catastro-gps-mcp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"mcpName": "com.parcelgps/catastro-gps",
|
|
5
|
-
"description": "MCP server for cadastral parcels from
|
|
5
|
+
"description": "MCP server for cadastral parcels from the full official cadastre of 27 European countries (including the Basque Country and Navarre foral cadastres), plus Scotland and Swedish farm blocks: reference, coordinates, address search in 27 countries, dwellings of Spanish buildings, geometry, terrain, climate, ground motion, solar, agriculture, market, score and comparison",
|
|
6
6
|
"author": "The Hidden Panda <soporte@catastrogps.es>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"build": "tsc",
|
|
22
22
|
"dev": "tsc --watch",
|
|
23
23
|
"start": "node build/index.js",
|
|
24
|
-
"start:
|
|
24
|
+
"start:http": "node build/http.js",
|
|
25
25
|
"test": "vitest run",
|
|
26
26
|
"test:watch": "vitest",
|
|
27
27
|
"lint": "tsc --noEmit",
|
package/server.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
3
|
"name": "com.parcelgps/catastro-gps",
|
|
4
4
|
"title": "Catastro GPS",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Official cadastral parcels of 27 European countries by reference and coordinates, partial in UK, SE",
|
|
6
6
|
"websiteUrl": "https://www.catastrogps.es/developers",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "https://github.com/TheHiddenPandaDev/catastro_gps_mcp",
|
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
]
|
|
25
25
|
}
|
|
26
26
|
],
|
|
27
|
-
"version": "2.
|
|
27
|
+
"version": "2.2.2",
|
|
28
28
|
"packages": [
|
|
29
29
|
{
|
|
30
30
|
"registryType": "npm",
|
|
31
31
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
32
32
|
"identifier": "catastro-gps-mcp",
|
|
33
|
-
"version": "2.
|
|
33
|
+
"version": "2.2.2",
|
|
34
34
|
"transport": {
|
|
35
35
|
"type": "stdio"
|
|
36
36
|
},
|
|
37
37
|
"environmentVariables": [
|
|
38
38
|
{
|
|
39
39
|
"name": "CATASTROGPS_API_KEY",
|
|
40
|
-
"description": "Catastro GPS API key. Free tier:
|
|
40
|
+
"description": "Catastro GPS API key. Free tier: 25 calls/month; failed lookups are free at https://www.catastrogps.es/developers",
|
|
41
41
|
"isRequired": true,
|
|
42
42
|
"isSecret": true,
|
|
43
43
|
"format": "string"
|
|
@@ -58,5 +58,20 @@
|
|
|
58
58
|
}
|
|
59
59
|
]
|
|
60
60
|
}
|
|
61
|
+
],
|
|
62
|
+
"remotes": [
|
|
63
|
+
{
|
|
64
|
+
"type": "streamable-http",
|
|
65
|
+
"url": "https://mcp.parcelgps.com/mcp",
|
|
66
|
+
"headers": [
|
|
67
|
+
{
|
|
68
|
+
"name": "Authorization",
|
|
69
|
+
"description": "Bearer followed by your Parcel GPS API key. Free tier: 25 calls/month at https://www.parcelgps.com/developers",
|
|
70
|
+
"isRequired": true,
|
|
71
|
+
"isSecret": true,
|
|
72
|
+
"format": "string"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
61
76
|
]
|
|
62
77
|
}
|