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
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CROP_LANGUAGES, REFERENCE_COUNTRIES } from "../types/index.js";
|
|
3
|
+
import { compact, handleToolError, jsonResult } from "./shared.js";
|
|
4
|
+
export function registerGetParcelSubparcels(server, client) {
|
|
5
|
+
server.registerTool("get_parcel_subparcels", {
|
|
6
|
+
title: "Get Parcel Subparcels",
|
|
7
|
+
description: "What is on each part of a parcel: every crop or land-use subparcel with a stable crop_code, the " +
|
|
8
|
+
"crop name in the requested language, the original label of the source, area in m2, kind " +
|
|
9
|
+
"(cadastral, declaredCrop, landCover), a common use_class (arable, vineyard, olive, forest...), " +
|
|
10
|
+
"intensity, land type and class, source and, with include_geometry, its GeoJSON outline. " +
|
|
11
|
+
"Spain (Catastro, including Bizkaia, Alava, Navarre; Gipuzkoa without outlines), Austria, " +
|
|
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 " +
|
|
14
|
+
"answer it returns SUB_001: nothing is charged, retry in a few seconds. Translate codes with " +
|
|
15
|
+
"get_crop_catalog.",
|
|
16
|
+
inputSchema: {
|
|
17
|
+
reference: z.string().min(1).describe("Official cadastral reference of the parcel"),
|
|
18
|
+
country: z
|
|
19
|
+
.enum(REFERENCE_COUNTRIES)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Optional country code (ES, PV, NA, AT, EE, GR...). Omit to auto-detect."),
|
|
22
|
+
lang: z.enum(CROP_LANGUAGES).optional().describe("Language of crop names (default English)"),
|
|
23
|
+
include_geometry: z
|
|
24
|
+
.boolean()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Include the GeoJSON outline of each subparcel (large). Default false."),
|
|
27
|
+
},
|
|
28
|
+
}, async ({ reference, country, lang, include_geometry }) => {
|
|
29
|
+
try {
|
|
30
|
+
const { data: d, quota } = await client.getSubparcels(reference, country, lang);
|
|
31
|
+
return jsonResult({
|
|
32
|
+
reference: d.reference,
|
|
33
|
+
country: d.country ?? country ?? null,
|
|
34
|
+
parcel_area_m2: d.parcelArea ?? null,
|
|
35
|
+
count: d.count,
|
|
36
|
+
subparcels: (d.subparcels ?? []).map((row) => compact({
|
|
37
|
+
id: row.id,
|
|
38
|
+
crop_code: row.cropCode,
|
|
39
|
+
crop: row.crop,
|
|
40
|
+
crop_original: row.cropOriginal,
|
|
41
|
+
area_m2: row.area,
|
|
42
|
+
kind: row.kind,
|
|
43
|
+
use_class: row.useClass,
|
|
44
|
+
use_class_name: row.useClassName,
|
|
45
|
+
intensity: row.intensity,
|
|
46
|
+
land_type: row.landType,
|
|
47
|
+
land_class: row.landClass,
|
|
48
|
+
source: row.source,
|
|
49
|
+
geometry: include_geometry ? row.geometry : undefined,
|
|
50
|
+
})),
|
|
51
|
+
}, quota);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return handleToolError(error);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=get-parcel-subparcels.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { COUNTRY_CODES_TEXT, SUPPORTED_COUNTRIES } from "../types/index.js";
|
|
2
|
+
import { 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", {
|
|
@@ -8,7 +8,9 @@ export function registerGetParcel(server, client) {
|
|
|
8
8
|
"foral cadastres) by its official cadastral reference or by WGS84 coordinates. Returns the " +
|
|
9
9
|
"reference, location, address, municipality, area, land use and the parcel outline when " +
|
|
10
10
|
"the official source provides them. The country is detected from the reference format or " +
|
|
11
|
-
"the point when omitted.
|
|
11
|
+
"the point when omitted. Where the parcel has crop or land-use parts it also returns their count " +
|
|
12
|
+
"and a crop summary (crop and share of the area); the full list with outlines is " +
|
|
13
|
+
"get_parcel_subparcels. United Kingdom: coordinates only. Codes: " + COUNTRY_CODES_TEXT + ".",
|
|
12
14
|
inputSchema: {
|
|
13
15
|
reference: z
|
|
14
16
|
.string()
|
|
@@ -21,30 +23,40 @@ export function registerGetParcel(server, client) {
|
|
|
21
23
|
.enum(SUPPORTED_COUNTRIES)
|
|
22
24
|
.optional()
|
|
23
25
|
.describe("Optional country code. Omit to auto-detect. PV and NA are the Spanish foral cadastres."),
|
|
26
|
+
lang: z.enum(CROP_LANGUAGES).optional().describe("Language of crop names (default English)"),
|
|
24
27
|
},
|
|
25
|
-
}, async ({ reference, latitude, longitude, country }) => {
|
|
28
|
+
}, async ({ reference, latitude, longitude, country, lang }) => {
|
|
26
29
|
try {
|
|
27
30
|
if (reference) {
|
|
28
31
|
if (country === "UK") {
|
|
29
32
|
return errorResult("MCP_002", "United Kingdom parcels can only be looked up by coordinates.");
|
|
30
33
|
}
|
|
31
|
-
const { data: d, quota } = await client.getParcelByReference(reference, country);
|
|
34
|
+
const { data: d, quota } = await client.getParcelByReference(reference, country, lang);
|
|
32
35
|
return jsonResult(compact({
|
|
33
|
-
reference: d.
|
|
34
|
-
country: d.
|
|
35
|
-
latitude: d.
|
|
36
|
-
longitude: d.
|
|
37
|
-
address: d.
|
|
38
|
-
postal_code: d.
|
|
39
|
-
municipality: d.
|
|
40
|
-
|
|
41
|
-
area_m2: d.
|
|
42
|
-
built_area_m2: d.
|
|
43
|
-
land_use: d.
|
|
44
|
-
land_class: d.
|
|
45
|
-
construction_year: d.
|
|
46
|
-
source: d.
|
|
47
|
-
outline_lat_lng: d.
|
|
36
|
+
reference: d.reference,
|
|
37
|
+
country: d.country || country,
|
|
38
|
+
latitude: d.latitude,
|
|
39
|
+
longitude: d.longitude,
|
|
40
|
+
address: d.address,
|
|
41
|
+
postal_code: d.postalCode,
|
|
42
|
+
municipality: d.municipality,
|
|
43
|
+
region: d.region,
|
|
44
|
+
area_m2: d.parcelArea,
|
|
45
|
+
built_area_m2: d.builtArea,
|
|
46
|
+
land_use: d.use,
|
|
47
|
+
land_class: d.landClass,
|
|
48
|
+
construction_year: d.yearBuilt,
|
|
49
|
+
source: d.source,
|
|
50
|
+
outline_lat_lng: d.polygon,
|
|
51
|
+
subparcel_count: d.subparcelCount,
|
|
52
|
+
crop_summary: d.cropSummary?.map((crop) => compact({
|
|
53
|
+
crop_code: crop.cropCode,
|
|
54
|
+
crop: crop.crop,
|
|
55
|
+
crop_original: crop.cropOriginal,
|
|
56
|
+
use_class: crop.useClass,
|
|
57
|
+
area_m2: crop.area,
|
|
58
|
+
share: crop.share,
|
|
59
|
+
})),
|
|
48
60
|
google_maps_url: d.googleMapsUrl,
|
|
49
61
|
}), quota);
|
|
50
62
|
}
|
|
@@ -53,16 +65,17 @@ export function registerGetParcel(server, client) {
|
|
|
53
65
|
}
|
|
54
66
|
const { data: d, quota } = await client.getParcelByCoordinates(latitude, longitude, country);
|
|
55
67
|
return jsonResult(compact({
|
|
56
|
-
reference: d.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
reference: d.reference,
|
|
69
|
+
parcel_reference: d.parcelReference,
|
|
70
|
+
country: d.country || country,
|
|
71
|
+
latitude: d.latitude,
|
|
72
|
+
longitude: d.longitude,
|
|
73
|
+
address: d.address,
|
|
74
|
+
postal_code: d.postalCode,
|
|
75
|
+
municipality: d.municipality,
|
|
76
|
+
region: d.region,
|
|
77
|
+
area_m2: d.parcelArea,
|
|
78
|
+
property_type: d.propertyType,
|
|
66
79
|
google_maps_url: d.googleMapsUrl,
|
|
67
80
|
}), quota);
|
|
68
81
|
}
|
package/build/tools/get-score.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { ENRICHMENT_COUNTRIES } from "../types/index.js";
|
|
3
3
|
import { handleToolError, jsonResult } from "./shared.js";
|
|
4
|
-
const FACTOR_NAMES =
|
|
5
|
-
viabilidad_solar: "solar",
|
|
6
|
-
potencial_agricola: "agriculture",
|
|
7
|
-
valor_mercado: "market",
|
|
8
|
-
demanda_terreno: "accessibility",
|
|
9
|
-
estabilidad_politica: "risk",
|
|
10
|
-
};
|
|
4
|
+
const FACTOR_NAMES = ["solar", "agriculture", "market", "accessibility", "risk"];
|
|
11
5
|
const HIGH_FROM = 7;
|
|
12
6
|
const MEDIUM_FROM = 4;
|
|
13
7
|
export function factorLevel(value) {
|
|
@@ -21,16 +15,16 @@ export function factorLevel(value) {
|
|
|
21
15
|
}
|
|
22
16
|
export function qualitativeFactors(components) {
|
|
23
17
|
const factors = {};
|
|
24
|
-
for (const
|
|
25
|
-
factors[name] = factorLevel(components?.[
|
|
18
|
+
for (const name of FACTOR_NAMES) {
|
|
19
|
+
factors[name] = factorLevel(components?.[name]);
|
|
26
20
|
}
|
|
27
21
|
return factors;
|
|
28
22
|
}
|
|
29
23
|
export function registerGetScore(server, client) {
|
|
30
24
|
server.registerTool("get_investment_score", {
|
|
31
25
|
title: "Get Investment Score",
|
|
32
|
-
description: "Investment score (0-100) for a parcel with a rating (
|
|
33
|
-
"
|
|
26
|
+
description: "Investment score (0-100) for a parcel with a rating (excellent, good, moderate, low, " +
|
|
27
|
+
"very_low or no_data) and qualitative factor levels (high/medium/low/not_available), never the formula. " +
|
|
34
28
|
"Built from the data the API can gather for that country: solar potential (PVGIS) and " +
|
|
35
29
|
"agricultural use in ES, PV, NA, PT, FR, IT and DE; the market factor only in France, Italy " +
|
|
36
30
|
"and Germany (North Rhine-Westphalia). Accessibility and risk are not computed yet and come " +
|
|
@@ -46,16 +40,16 @@ export function registerGetScore(server, client) {
|
|
|
46
40
|
}, async ({ reference, country }) => {
|
|
47
41
|
try {
|
|
48
42
|
const { data, quota } = await client.getInvestmentScore(reference, country);
|
|
49
|
-
const s = data
|
|
43
|
+
const s = data;
|
|
50
44
|
return jsonResult({
|
|
51
45
|
reference,
|
|
52
46
|
country: country ?? null,
|
|
53
|
-
score: s.
|
|
54
|
-
rating: s.
|
|
55
|
-
recommendation: s.
|
|
56
|
-
factors: qualitativeFactors(s.
|
|
57
|
-
risk_factors: s.
|
|
58
|
-
opportunity_factors: s.
|
|
47
|
+
score: s.score,
|
|
48
|
+
rating: s.rating,
|
|
49
|
+
recommendation: s.recommendation ?? null,
|
|
50
|
+
factors: qualitativeFactors(s.components),
|
|
51
|
+
risk_factors: s.riskFactors ?? [],
|
|
52
|
+
opportunity_factors: s.opportunityFactors ?? [],
|
|
59
53
|
note: "Score based on the data available for this parcel. Factor levels are qualitative.",
|
|
60
54
|
}, quota);
|
|
61
55
|
}
|
package/build/tools/get-solar.js
CHANGED
|
@@ -18,19 +18,19 @@ export function registerGetSolar(server, client) {
|
|
|
18
18
|
try {
|
|
19
19
|
const { data: d, quota } = await client.getSolarPotential(reference, country);
|
|
20
20
|
return jsonResult({
|
|
21
|
-
available: d.
|
|
22
|
-
status: d.
|
|
23
|
-
installable_kwp: d.
|
|
24
|
-
production_kwh_year: d.
|
|
25
|
-
savings_eur_year: d.
|
|
26
|
-
payback_years: d.
|
|
27
|
-
installation_cost_eur: d.
|
|
28
|
-
co2_avoided_kg_year: d.
|
|
29
|
-
mean_irradiation: d.
|
|
30
|
-
solar_grade: d.
|
|
31
|
-
optimal_orientation: d.
|
|
32
|
-
optimal_tilt_deg: d.
|
|
33
|
-
source: d.
|
|
21
|
+
available: d.available,
|
|
22
|
+
status: d.status,
|
|
23
|
+
installable_kwp: d.installableKw,
|
|
24
|
+
production_kwh_year: d.annualProductionKwh,
|
|
25
|
+
savings_eur_year: d.annualSavingsEur,
|
|
26
|
+
payback_years: d.paybackYears,
|
|
27
|
+
installation_cost_eur: d.installationCostEur ?? null,
|
|
28
|
+
co2_avoided_kg_year: d.co2AvoidedKg,
|
|
29
|
+
mean_irradiation: d.irradiationKwhM2,
|
|
30
|
+
solar_grade: d.solarGrade,
|
|
31
|
+
optimal_orientation: d.optimalOrientation ?? null,
|
|
32
|
+
optimal_tilt_deg: d.tiltAngleDeg ?? null,
|
|
33
|
+
source: d.source ?? "PVGIS",
|
|
34
34
|
}, quota);
|
|
35
35
|
}
|
|
36
36
|
catch (error) {
|
|
@@ -31,12 +31,12 @@ export function registerGetTerrain(server, client) {
|
|
|
31
31
|
try {
|
|
32
32
|
const { data, quota } = await client.getTerrain(reference, country, point);
|
|
33
33
|
return jsonResult({
|
|
34
|
-
reference: data.
|
|
34
|
+
reference: data.reference,
|
|
35
35
|
country: data.country,
|
|
36
36
|
relief: data.relief,
|
|
37
|
-
protected_areas: data.
|
|
37
|
+
protected_areas: data.protectedAreas,
|
|
38
38
|
climate: data.climate ?? null,
|
|
39
|
-
calculated_at: data.
|
|
39
|
+
calculated_at: data.calculatedAt,
|
|
40
40
|
}, quota);
|
|
41
41
|
}
|
|
42
42
|
catch (caught) {
|
package/build/tools/get-units.js
CHANGED
|
@@ -3,25 +3,25 @@ import { UNITS_COUNTRIES } from "../types/index.js";
|
|
|
3
3
|
import { compact, handleToolError, jsonResult } from "./shared.js";
|
|
4
4
|
function unit(item) {
|
|
5
5
|
return compact({
|
|
6
|
-
reference: item.
|
|
7
|
-
stair: item.
|
|
8
|
-
floor: item.
|
|
9
|
-
door: item.
|
|
10
|
-
use: item.
|
|
11
|
-
area_m2: item.
|
|
12
|
-
participation_pct: item.
|
|
13
|
-
year: item.
|
|
14
|
-
description: item.
|
|
6
|
+
reference: item.reference,
|
|
7
|
+
stair: item.staircase,
|
|
8
|
+
floor: item.floor,
|
|
9
|
+
door: item.door,
|
|
10
|
+
use: item.use,
|
|
11
|
+
area_m2: item.area,
|
|
12
|
+
participation_pct: item.ownershipShare,
|
|
13
|
+
year: item.yearBuilt,
|
|
14
|
+
description: item.description,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
function construction(item) {
|
|
18
18
|
return compact({
|
|
19
|
-
stair: item.
|
|
20
|
-
floor: item.
|
|
21
|
-
door: item.
|
|
22
|
-
use: item.
|
|
23
|
-
area_m2: item.
|
|
24
|
-
description: item.
|
|
19
|
+
stair: item.staircase,
|
|
20
|
+
floor: item.floor,
|
|
21
|
+
door: item.door,
|
|
22
|
+
use: item.use,
|
|
23
|
+
area_m2: item.area,
|
|
24
|
+
description: item.description,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
export function registerGetUnits(server, client) {
|
|
@@ -45,19 +45,19 @@ export function registerGetUnits(server, client) {
|
|
|
45
45
|
}, async ({ reference, country, cursor }) => {
|
|
46
46
|
try {
|
|
47
47
|
const { data, quota } = await client.getUnits(reference, country, cursor);
|
|
48
|
-
const units = data.
|
|
48
|
+
const units = data.units ?? [];
|
|
49
49
|
return jsonResult(compact({
|
|
50
|
-
reference: data.
|
|
51
|
-
address: data.
|
|
52
|
-
postal_code: data.
|
|
53
|
-
municipality: data.
|
|
54
|
-
|
|
55
|
-
general_use: data.
|
|
56
|
-
construction_year: data.
|
|
57
|
-
total_units_in_finca: data.
|
|
50
|
+
reference: data.reference,
|
|
51
|
+
address: data.address,
|
|
52
|
+
postal_code: data.postalCode,
|
|
53
|
+
municipality: data.municipality,
|
|
54
|
+
region: data.region,
|
|
55
|
+
general_use: data.mainUse,
|
|
56
|
+
construction_year: data.yearBuilt,
|
|
57
|
+
total_units_in_finca: data.propertyUnitCount ?? units.length,
|
|
58
58
|
units_in_page: units.length,
|
|
59
59
|
units: units.map(unit),
|
|
60
|
-
constructions: (data.
|
|
60
|
+
constructions: (data.constructions ?? []).map(construction),
|
|
61
61
|
truncated: data.truncated ?? false,
|
|
62
62
|
next_cursor: data.truncated ? data.nextCursor : undefined,
|
|
63
63
|
data_source: data.dataSource,
|
|
@@ -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). " +
|
|
@@ -22,17 +23,17 @@ export function registerGetValueHistory(server, client) {
|
|
|
22
23
|
const { data, quota } = await client.getValueHistory(reference, country);
|
|
23
24
|
const entries = data.entries ?? [];
|
|
24
25
|
return jsonResult({
|
|
25
|
-
reference: data.
|
|
26
|
+
reference: data.reference ?? reference,
|
|
26
27
|
country: data.country ?? country ?? null,
|
|
27
28
|
snapshots: entries.map((entry) => ({
|
|
28
|
-
date: entry.
|
|
29
|
-
area_m2: entry.
|
|
30
|
-
land_use: entry.
|
|
31
|
-
cadastral_value_eur: entry.
|
|
32
|
-
source: entry.
|
|
29
|
+
date: entry.capturedOn ?? null,
|
|
30
|
+
area_m2: entry.area ?? null,
|
|
31
|
+
land_use: entry.use || null,
|
|
32
|
+
cadastral_value_eur: entry.cadastralValueEur ? entry.cadastralValueEur : null,
|
|
33
|
+
source: entry.source ?? null,
|
|
33
34
|
})),
|
|
34
35
|
total: data.totalEntries ?? entries.length,
|
|
35
|
-
change_pct: data.
|
|
36
|
+
change_pct: data.areaChangePct ?? null,
|
|
36
37
|
}, quota);
|
|
37
38
|
}
|
|
38
39
|
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 registerListMunicipalities(server: McpServer, client: CatastroGPSClient): void;
|
|
4
|
+
//# sourceMappingURL=list-municipalities.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { handleToolError, jsonResult } from "./shared.js";
|
|
3
|
+
export function registerListMunicipalities(server, client) {
|
|
4
|
+
server.registerTool("list_municipalities", {
|
|
5
|
+
title: "List Spanish Municipalities",
|
|
6
|
+
description: "Municipalities of one Spanish province, with the cadastre code and the INE code. Spain only " +
|
|
7
|
+
"(common territory). Take the province name from list_provinces. One API call.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
region: z.string().trim().min(1).describe("Province name as returned by list_provinces (e.g. CIUDAD REAL)"),
|
|
10
|
+
},
|
|
11
|
+
}, async ({ region }) => {
|
|
12
|
+
try {
|
|
13
|
+
const { data, quota } = await client.listMunicipalities(region);
|
|
14
|
+
return jsonResult({ region, total: data.total, municipalities: data.municipalities ?? [] }, quota);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return handleToolError(error);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=list-municipalities.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 registerListProvinces(server: McpServer, client: CatastroGPSClient): void;
|
|
4
|
+
//# sourceMappingURL=list-provinces.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { handleToolError, jsonResult } from "./shared.js";
|
|
2
|
+
export function registerListProvinces(server, client) {
|
|
3
|
+
server.registerTool("list_provinces", {
|
|
4
|
+
title: "List Spanish Provinces",
|
|
5
|
+
description: "Provinces of the Spanish cadastre, with the names that list_municipalities and list_streets " +
|
|
6
|
+
"expect as region. Spain only (common territory: the Basque Country and Navarre have their own " +
|
|
7
|
+
"cadastres and are not listed). One API call.",
|
|
8
|
+
inputSchema: {},
|
|
9
|
+
}, async () => {
|
|
10
|
+
try {
|
|
11
|
+
const { data, quota } = await client.listProvinces();
|
|
12
|
+
return jsonResult({ total: data.total, provinces: data.provinces ?? [] }, quota);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return handleToolError(error);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=list-provinces.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 registerListStreets(server: McpServer, client: CatastroGPSClient): void;
|
|
4
|
+
//# sourceMappingURL=list-streets.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { handleToolError, jsonResult } from "./shared.js";
|
|
3
|
+
export function registerListStreets(server, client) {
|
|
4
|
+
server.registerTool("list_streets", {
|
|
5
|
+
title: "List Spanish Streets",
|
|
6
|
+
description: "Streets of one Spanish municipality as the cadastre writes them (type code such as CL or AV, " +
|
|
7
|
+
"name and full name), optionally filtered by part of the name. Spain only (common territory). " +
|
|
8
|
+
"Take region from list_provinces and municipality from list_municipalities. One API call.",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
region: z.string().trim().min(1).describe("Province name as returned by list_provinces"),
|
|
11
|
+
municipality: z.string().trim().min(1).describe("Municipality name as returned by list_municipalities"),
|
|
12
|
+
name: z.string().trim().min(1).optional().describe("Part of the street name to filter by"),
|
|
13
|
+
},
|
|
14
|
+
}, async ({ region, municipality, name }) => {
|
|
15
|
+
try {
|
|
16
|
+
const { data, quota } = await client.listStreets(region, municipality, name);
|
|
17
|
+
return jsonResult({ region, municipality, total: data.total, streets: data.streets ?? [] }, quota);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return handleToolError(error);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=list-streets.js.map
|
|
@@ -5,21 +5,21 @@ const DEFAULT_LIMIT = 5;
|
|
|
5
5
|
const MAX_LIMIT = 10;
|
|
6
6
|
function candidate(item) {
|
|
7
7
|
return compact({
|
|
8
|
-
reference: item.
|
|
9
|
-
country: item.
|
|
10
|
-
address: item.
|
|
11
|
-
number: item.
|
|
12
|
-
postal_code: item.
|
|
13
|
-
municipality: item.
|
|
14
|
-
|
|
15
|
-
latitude: item.
|
|
16
|
-
longitude: item.
|
|
17
|
-
confidence: item.
|
|
18
|
-
number_matches: item.
|
|
19
|
-
municipality_matches: item.
|
|
20
|
-
use: item.
|
|
21
|
-
dwellings: item.
|
|
22
|
-
construction_year: item.
|
|
8
|
+
reference: item.reference,
|
|
9
|
+
country: item.country,
|
|
10
|
+
address: item.address,
|
|
11
|
+
number: item.number,
|
|
12
|
+
postal_code: item.postalCode,
|
|
13
|
+
municipality: item.municipality,
|
|
14
|
+
region: item.region,
|
|
15
|
+
latitude: item.latitude,
|
|
16
|
+
longitude: item.longitude,
|
|
17
|
+
confidence: item.confidence,
|
|
18
|
+
number_matches: item.numberMatches,
|
|
19
|
+
municipality_matches: item.municipalityMatches,
|
|
20
|
+
use: item.use,
|
|
21
|
+
dwellings: item.dwellings,
|
|
22
|
+
construction_year: item.yearBuilt,
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
export function registerSearchAddress(server, client) {
|
|
@@ -50,9 +50,9 @@ export function registerSearchAddress(server, client) {
|
|
|
50
50
|
}, async ({ address, country, limit }) => {
|
|
51
51
|
try {
|
|
52
52
|
const { data, quota } = await client.searchAddressCandidates(address, country, limit);
|
|
53
|
-
const candidates = data.
|
|
53
|
+
const candidates = data.candidates ?? [];
|
|
54
54
|
return jsonResult({
|
|
55
|
-
query: data.
|
|
55
|
+
query: data.query?.text ?? address,
|
|
56
56
|
country: country ?? "ES",
|
|
57
57
|
total: candidates.length,
|
|
58
58
|
candidates: candidates.map(candidate),
|
package/build/tools/shared.js
CHANGED
|
@@ -13,12 +13,16 @@ 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.",
|
|
19
21
|
CNV_AMBIGUOUS: "The reference matches several countries. Call again with one of the candidate country codes.",
|
|
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.",
|
|
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.",
|
|
22
26
|
INTERNAL_ERROR: "Internal server error. Try again later.",
|
|
23
27
|
MCP_TIMEOUT: "The request timed out. Official cadastres can be slow; try again or raise CATASTROGPS_TIMEOUT.",
|
|
24
28
|
MCP_NETWORK: "Could not reach the CatastroGPS API. Check your connection or CATASTROGPS_API_URL.",
|