@ignfab/geocontext 0.9.5 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +349 -259
- package/dist/gpf/adminexpress.d.ts +17 -8
- package/dist/gpf/adminexpress.js +40 -17
- package/dist/gpf/adminexpress.js.map +1 -1
- package/dist/gpf/altitude.d.ts +21 -9
- package/dist/gpf/altitude.js +5 -5
- package/dist/gpf/altitude.js.map +1 -1
- package/dist/gpf/geocode.d.ts +25 -4
- package/dist/gpf/geocode.js +5 -5
- package/dist/gpf/geocode.js.map +1 -1
- package/dist/gpf/parcellaire-express.d.ts +19 -9
- package/dist/gpf/parcellaire-express.js +59 -26
- package/dist/gpf/parcellaire-express.js.map +1 -1
- package/dist/gpf/urbanisme.d.ts +24 -16
- package/dist/gpf/urbanisme.js +81 -33
- package/dist/gpf/urbanisme.js.map +1 -1
- package/dist/gpf/{wfs.js → wfs-schema-catalog.js} +1 -1
- package/dist/gpf/wfs-schema-catalog.js.map +1 -0
- package/dist/helpers/RateLimiter.d.ts +44 -0
- package/dist/helpers/RateLimiter.js +52 -0
- package/dist/helpers/RateLimiter.js.map +1 -0
- package/dist/helpers/distance.d.ts +2 -1
- package/dist/helpers/distance.js +2 -1
- package/dist/helpers/distance.js.map +1 -1
- package/dist/helpers/errors/toolError.d.ts +30 -0
- package/dist/helpers/errors/toolError.js +193 -0
- package/dist/helpers/errors/toolError.js.map +1 -0
- package/dist/helpers/errors/zodErrorMapFr.d.ts +20 -0
- package/dist/helpers/errors/zodErrorMapFr.js +191 -0
- package/dist/helpers/errors/zodErrorMapFr.js.map +1 -0
- package/dist/helpers/http.d.ts +67 -7
- package/dist/helpers/http.js +458 -84
- package/dist/helpers/http.js.map +1 -1
- package/dist/helpers/jsonSchema.d.ts +20 -2
- package/dist/helpers/jsonSchema.js +12 -0
- package/dist/helpers/jsonSchema.js.map +1 -1
- package/dist/helpers/schemas.d.ts +4 -4
- package/dist/helpers/wfs_engine/attributeFilter.d.ts +51 -0
- package/dist/helpers/wfs_engine/attributeFilter.js +258 -0
- package/dist/helpers/wfs_engine/attributeFilter.js.map +1 -0
- package/dist/helpers/wfs_engine/byId.d.ts +76 -0
- package/dist/helpers/wfs_engine/byId.js +106 -0
- package/dist/helpers/wfs_engine/byId.js.map +1 -0
- package/dist/helpers/wfs_engine/execution.d.ts +72 -0
- package/dist/helpers/wfs_engine/execution.js +95 -0
- package/dist/helpers/wfs_engine/execution.js.map +1 -0
- package/dist/helpers/wfs_engine/features.d.ts +64 -0
- package/dist/helpers/wfs_engine/features.js +138 -0
- package/dist/helpers/wfs_engine/features.js.map +1 -0
- package/dist/helpers/wfs_engine/geometry.d.ts +16 -0
- package/dist/helpers/wfs_engine/geometry.js +44 -0
- package/dist/helpers/wfs_engine/geometry.js.map +1 -0
- package/dist/helpers/wfs_engine/properties.d.ts +51 -0
- package/dist/helpers/wfs_engine/properties.js +128 -0
- package/dist/helpers/wfs_engine/properties.js.map +1 -0
- package/dist/helpers/wfs_engine/queryPreparation.d.ts +32 -0
- package/dist/helpers/wfs_engine/queryPreparation.js +149 -0
- package/dist/helpers/wfs_engine/queryPreparation.js.map +1 -0
- package/dist/helpers/wfs_engine/request.d.ts +94 -0
- package/dist/helpers/wfs_engine/request.js +197 -0
- package/dist/helpers/wfs_engine/request.js.map +1 -0
- package/dist/helpers/wfs_engine/response.d.ts +80 -0
- package/dist/helpers/wfs_engine/response.js +135 -0
- package/dist/helpers/wfs_engine/response.js.map +1 -0
- package/dist/helpers/wfs_engine/schema.d.ts +209 -0
- package/dist/helpers/{wfs_internal → wfs_engine}/schema.js +50 -10
- package/dist/helpers/wfs_engine/schema.js.map +1 -0
- package/dist/helpers/wfs_engine/spatialCql.d.ts +46 -0
- package/dist/helpers/wfs_engine/spatialCql.js +54 -0
- package/dist/helpers/wfs_engine/spatialCql.js.map +1 -0
- package/dist/helpers/wfs_engine/spatialFilter.d.ts +14 -0
- package/dist/helpers/wfs_engine/spatialFilter.js +131 -0
- package/dist/helpers/wfs_engine/spatialFilter.js.map +1 -0
- package/dist/index.js +65 -23
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +4 -1
- package/dist/logger.js.map +1 -1
- package/dist/tools/AdminexpressTool.d.ts +42 -33
- package/dist/tools/AdminexpressTool.js +19 -3
- package/dist/tools/AdminexpressTool.js.map +1 -1
- package/dist/tools/AltitudeTool.d.ts +35 -44
- package/dist/tools/AltitudeTool.js +19 -8
- package/dist/tools/AltitudeTool.js.map +1 -1
- package/dist/tools/AssietteSupTool.d.ts +51 -34
- package/dist/tools/AssietteSupTool.js +18 -2
- package/dist/tools/AssietteSupTool.js.map +1 -1
- package/dist/tools/BaseTool.d.ts +17 -0
- package/dist/tools/BaseTool.js +41 -0
- package/dist/tools/BaseTool.js.map +1 -0
- package/dist/tools/CadastreTool.d.ts +53 -33
- package/dist/tools/CadastreTool.js +18 -2
- package/dist/tools/CadastreTool.js.map +1 -1
- package/dist/tools/GeocodeTool.d.ts +53 -37
- package/dist/tools/GeocodeTool.js +17 -2
- package/dist/tools/GeocodeTool.js.map +1 -1
- package/dist/tools/GpfWfsDescribeTypeTool.d.ts +66 -94
- package/dist/tools/GpfWfsDescribeTypeTool.js +26 -15
- package/dist/tools/GpfWfsDescribeTypeTool.js.map +1 -1
- package/dist/tools/GpfWfsGetFeatureByIdTool.d.ts +89 -0
- package/dist/tools/GpfWfsGetFeatureByIdTool.js +99 -0
- package/dist/tools/GpfWfsGetFeatureByIdTool.js.map +1 -0
- package/dist/tools/GpfWfsGetFeaturesTool.d.ts +89 -123
- package/dist/tools/GpfWfsGetFeaturesTool.js +31 -144
- package/dist/tools/GpfWfsGetFeaturesTool.js.map +1 -1
- package/dist/tools/GpfWfsSearchTypesTool.d.ts +41 -32
- package/dist/tools/GpfWfsSearchTypesTool.js +18 -3
- package/dist/tools/GpfWfsSearchTypesTool.js.map +1 -1
- package/dist/tools/UrbanismeTool.d.ts +42 -33
- package/dist/tools/UrbanismeTool.js +18 -2
- package/dist/tools/UrbanismeTool.js.map +1 -1
- package/package.json +51 -24
- package/dist/gpf/wfs.js.map +0 -1
- package/dist/helpers/wfs.d.ts +0 -27
- package/dist/helpers/wfs.js +0 -55
- package/dist/helpers/wfs.js.map +0 -1
- package/dist/helpers/wfs_internal/compile.d.ts +0 -46
- package/dist/helpers/wfs_internal/compile.js +0 -595
- package/dist/helpers/wfs_internal/compile.js.map +0 -1
- package/dist/helpers/wfs_internal/request.d.ts +0 -38
- package/dist/helpers/wfs_internal/request.js +0 -92
- package/dist/helpers/wfs_internal/request.js.map +0 -1
- package/dist/helpers/wfs_internal/response.d.ts +0 -21
- package/dist/helpers/wfs_internal/response.js +0 -29
- package/dist/helpers/wfs_internal/response.js.map +0 -1
- package/dist/helpers/wfs_internal/schema.d.ts +0 -167
- package/dist/helpers/wfs_internal/schema.js.map +0 -1
- /package/dist/gpf/{wfs.d.ts → wfs-schema-catalog.d.ts} +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spatial input normalization helpers for the structured WFS query compiler.
|
|
3
|
+
*
|
|
4
|
+
* This module turns raw tool input parameters into normalized spatial filter
|
|
5
|
+
* objects that can then be compiled into CQL fragments.
|
|
6
|
+
*/
|
|
7
|
+
// --- Parameter Groups ---
|
|
8
|
+
const BBOX_PARAM_NAMES = ["bbox_west", "bbox_south", "bbox_east", "bbox_north"];
|
|
9
|
+
const INTERSECTS_POINT_PARAM_NAMES = ["intersects_lon", "intersects_lat"];
|
|
10
|
+
const DWITHIN_PARAM_NAMES = ["dwithin_lon", "dwithin_lat", "dwithin_distance_m"];
|
|
11
|
+
const INTERSECTS_FEATURE_PARAM_NAMES = ["intersects_feature_typename", "intersects_feature_id"];
|
|
12
|
+
// --- Parameter Detection ---
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether any property in a named group is defined on the raw input object.
|
|
15
|
+
*
|
|
16
|
+
* @param input Normalized tool input.
|
|
17
|
+
* @param keys Input keys to inspect.
|
|
18
|
+
* @returns `true` when at least one key from the group is present.
|
|
19
|
+
*/
|
|
20
|
+
function hasAny(input, keys) {
|
|
21
|
+
return keys.some((name) => input[name] !== undefined);
|
|
22
|
+
}
|
|
23
|
+
// --- Per-Mode Readers ---
|
|
24
|
+
/**
|
|
25
|
+
* Reads and validates the `bbox` spatial filter parameters.
|
|
26
|
+
*
|
|
27
|
+
* @param input Normalized tool input.
|
|
28
|
+
* @returns A normalized `bbox` spatial filter.
|
|
29
|
+
*/
|
|
30
|
+
function readBboxFilter(input) {
|
|
31
|
+
if (input.bbox_west === undefined || input.bbox_south === undefined || input.bbox_east === undefined || input.bbox_north === undefined) {
|
|
32
|
+
throw new Error("Le filtre spatial `bbox` exige `bbox_west`, `bbox_south`, `bbox_east` et `bbox_north`.");
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
operator: "bbox",
|
|
36
|
+
west: input.bbox_west,
|
|
37
|
+
south: input.bbox_south,
|
|
38
|
+
east: input.bbox_east,
|
|
39
|
+
north: input.bbox_north,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reads and validates the `intersects_point` spatial filter parameters.
|
|
44
|
+
*
|
|
45
|
+
* @param input Normalized tool input.
|
|
46
|
+
* @returns A normalized `intersects_point` spatial filter.
|
|
47
|
+
*/
|
|
48
|
+
function readIntersectsPointFilter(input) {
|
|
49
|
+
if (input.intersects_lon === undefined || input.intersects_lat === undefined) {
|
|
50
|
+
throw new Error("Le filtre spatial `intersects_point` exige `intersects_lon` et `intersects_lat`.");
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
operator: "intersects_point",
|
|
54
|
+
lon: input.intersects_lon,
|
|
55
|
+
lat: input.intersects_lat,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Reads and validates the `dwithin_point` spatial filter parameters.
|
|
60
|
+
*
|
|
61
|
+
* @param input Normalized tool input.
|
|
62
|
+
* @returns A normalized `dwithin_point` spatial filter.
|
|
63
|
+
*/
|
|
64
|
+
function readDwithinPointFilter(input) {
|
|
65
|
+
if (input.dwithin_lon === undefined || input.dwithin_lat === undefined || input.dwithin_distance_m === undefined) {
|
|
66
|
+
throw new Error("Le filtre spatial `dwithin_point` exige `dwithin_lon`, `dwithin_lat` et `dwithin_distance_m`.");
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
operator: "dwithin_point",
|
|
70
|
+
lon: input.dwithin_lon,
|
|
71
|
+
lat: input.dwithin_lat,
|
|
72
|
+
distance_m: input.dwithin_distance_m,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Reads and validates the `intersects_feature` spatial filter parameters.
|
|
77
|
+
*
|
|
78
|
+
* @param input Normalized tool input.
|
|
79
|
+
* @returns A normalized `intersects_feature` spatial filter.
|
|
80
|
+
*/
|
|
81
|
+
function readIntersectsFeatureFilter(input) {
|
|
82
|
+
if (!input.intersects_feature_typename || !input.intersects_feature_id) {
|
|
83
|
+
throw new Error("Le filtre spatial `intersects_feature` exige `intersects_feature_typename` et `intersects_feature_id`.");
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
operator: "intersects_feature",
|
|
87
|
+
typename: input.intersects_feature_typename,
|
|
88
|
+
feature_id: input.intersects_feature_id,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// --- Public Normalization ---
|
|
92
|
+
/**
|
|
93
|
+
* Normalizes the raw spatial input into a discriminated spatial filter object.
|
|
94
|
+
*
|
|
95
|
+
* @param input Normalized tool input.
|
|
96
|
+
* @returns A normalized spatial filter, or `undefined` when no spatial filter is requested.
|
|
97
|
+
*/
|
|
98
|
+
export function getSpatialFilter(input) {
|
|
99
|
+
const hasBboxParams = hasAny(input, BBOX_PARAM_NAMES);
|
|
100
|
+
const hasIntersectsPointParams = hasAny(input, INTERSECTS_POINT_PARAM_NAMES);
|
|
101
|
+
const hasDwithinParams = hasAny(input, DWITHIN_PARAM_NAMES);
|
|
102
|
+
const hasIntersectsFeatureParams = hasAny(input, INTERSECTS_FEATURE_PARAM_NAMES);
|
|
103
|
+
switch (input.spatial_operator) {
|
|
104
|
+
case undefined:
|
|
105
|
+
if (hasBboxParams || hasIntersectsPointParams || hasDwithinParams || hasIntersectsFeatureParams) {
|
|
106
|
+
throw new Error("Les paramètres spatiaux exigent `spatial_operator`.");
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
case "bbox":
|
|
110
|
+
if (hasIntersectsPointParams || hasDwithinParams || hasIntersectsFeatureParams) {
|
|
111
|
+
throw new Error("Le filtre spatial `bbox` n'accepte pas les paramètres d'un autre mode spatial.");
|
|
112
|
+
}
|
|
113
|
+
return readBboxFilter(input);
|
|
114
|
+
case "intersects_point":
|
|
115
|
+
if (hasBboxParams || hasDwithinParams || hasIntersectsFeatureParams) {
|
|
116
|
+
throw new Error("Le filtre spatial `intersects_point` n'accepte pas les paramètres d'un autre mode spatial.");
|
|
117
|
+
}
|
|
118
|
+
return readIntersectsPointFilter(input);
|
|
119
|
+
case "dwithin_point":
|
|
120
|
+
if (hasBboxParams || hasIntersectsPointParams || hasIntersectsFeatureParams) {
|
|
121
|
+
throw new Error("Le filtre spatial `dwithin_point` n'accepte pas les paramètres d'un autre mode spatial.");
|
|
122
|
+
}
|
|
123
|
+
return readDwithinPointFilter(input);
|
|
124
|
+
case "intersects_feature":
|
|
125
|
+
if (hasBboxParams || hasIntersectsPointParams || hasDwithinParams) {
|
|
126
|
+
throw new Error("Le filtre spatial `intersects_feature` n'accepte pas les paramètres d'un autre mode spatial.");
|
|
127
|
+
}
|
|
128
|
+
return readIntersectsFeatureFilter(input);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=spatialFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spatialFilter.js","sourceRoot":"","sources":["../../../src/helpers/wfs_engine/spat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AK,EAAE,8BAA8B,CAAC,CAAC;IAEjF,QAAQ,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/B,KAAK,SAAS;YACZ,IAAI,aAAa,IAAI,wBAAwB,IAAI,gBAAgB,IAAI,0BAA0B,EAAE,CAAC;gBAChG,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;YACzE,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,KAAK,MAAM;YACT,IAAI,wBAAwB,IAAI,gBAAgB,IAAI,0BAA0B,EAAE,CAAC;gBAC/E,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;YACpG,CAAC;YACD,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;QAC/B,KAAK,kBAAkB;YACrB,IAAI,aAAa,IAAI,gBAAgB,IAAI,0BAA0B,EAAE,CAAC;gBACpE,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;YAChH,CAAC;YACD,OAAO,yBAAyB,CAAC,KAAK,CAAC,CAAC;QAC1C,KAAK,eAAe;YAClB,IAAI,aAAa,IAAI,wBAAwB,IAAI,0BAA0B,EAAE,CAAC;gBAC5E,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAC;YAC7G,CAAC;YACD,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACvC,KAAK,oBAAoB;YACvB,IAAI,aAAa,IAAI,wBAAwB,IAAI,gBAAgB,EAAE,CAAC;gBAClE,MAAM,IAAI,KAAK,CAAC,8FAA8F,CAAC,CAAC;YAClH,CAAC;YACD,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,24 +3,15 @@ import { MCPServer } from "mcp-framework";
|
|
|
3
3
|
import { dirname, join } from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { readFileSync } from "fs";
|
|
6
|
+
import logger from "./logger.js";
|
|
6
7
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const TRANSPORTS = {
|
|
8
|
-
stdio: {
|
|
9
|
-
type: "stdio",
|
|
10
|
-
},
|
|
11
|
-
http: {
|
|
12
|
-
type: "http-stream",
|
|
13
|
-
options: {
|
|
14
|
-
port: 3000,
|
|
15
|
-
cors: {
|
|
16
|
-
allowOrigin: "*",
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
8
|
function isTransportType(value) {
|
|
22
|
-
return
|
|
9
|
+
return value === "stdio" || value === "http";
|
|
23
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Get the transport type from the environment variable TRANSPORT_TYPE.
|
|
13
|
+
* Valid values are "stdio" and "http". If not set, defaults to "stdio".
|
|
14
|
+
*/
|
|
24
15
|
function getTransportType() {
|
|
25
16
|
const transportType = process.env.TRANSPORT_TYPE ?? "stdio";
|
|
26
17
|
if (!isTransportType(transportType)) {
|
|
@@ -28,22 +19,73 @@ function getTransportType() {
|
|
|
28
19
|
}
|
|
29
20
|
return transportType;
|
|
30
21
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Get the HTTP port from the environment variable HTTP_PORT.
|
|
24
|
+
* The variable should be a decimal integer between 1 and 65535. If not set, defaults to 3000.
|
|
25
|
+
*/
|
|
26
|
+
function getHttpPort() {
|
|
27
|
+
const rawPort = process.env.HTTP_PORT?.trim();
|
|
28
|
+
const invalidHttpPortMessage = `Invalid HTTP_PORT: ${rawPort}. Expected a decimal integer between 1 and 65535.`;
|
|
29
|
+
if (!rawPort) {
|
|
30
|
+
return 3000;
|
|
31
|
+
}
|
|
32
|
+
if (!/^\d+$/.test(rawPort)) {
|
|
33
|
+
throw new Error(invalidHttpPortMessage);
|
|
34
|
+
}
|
|
35
|
+
const port = Number(rawPort);
|
|
36
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
37
|
+
throw new Error(invalidHttpPortMessage);
|
|
34
38
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
return port;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get CORS allowed origins from the environment variable HTTP_CORS_ALLOWED_ORIGINS.
|
|
43
|
+
* The variable should be a comma-separated list of origins .
|
|
44
|
+
*/
|
|
45
|
+
function getCorsAllowedOrigins() {
|
|
46
|
+
if (process.env.HTTP_CORS_ALLOWED_ORIGINS === undefined) {
|
|
47
|
+
logger.warn('Security : HTTP_CORS_ALLOWED_ORIGINS is not set. It is recommended to set this variable to prevent DNS rebinding attacks (e.g., HTTP_CORS_ALLOWED_ORIGINS="http://localhost:3000,https://geollm.beta.ign.fr".');
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const rawOrigins = process.env.HTTP_CORS_ALLOWED_ORIGINS?.trim();
|
|
51
|
+
const allowedOrigins = rawOrigins
|
|
52
|
+
?.split(",")
|
|
53
|
+
.map((origin) => origin.trim())
|
|
54
|
+
.filter(Boolean);
|
|
55
|
+
if (!allowedOrigins || allowedOrigins.length === 0) {
|
|
56
|
+
logger.warn('Security : HTTP_CORS_ALLOWED_ORIGINS is empty. It is recommended to set this variable to prevent DNS rebinding attacks (e.g., HTTP_CORS_ALLOWED_ORIGINS="http://localhost:3000,https://geollm.beta.ign.fr".');
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return allowedOrigins;
|
|
60
|
+
}
|
|
61
|
+
function buildTransport(transportType) {
|
|
62
|
+
// Handle stdio transport configuration
|
|
63
|
+
if (transportType === "stdio") {
|
|
64
|
+
return {
|
|
65
|
+
type: "stdio",
|
|
66
|
+
};
|
|
38
67
|
}
|
|
68
|
+
// Handle HTTP transport configuration
|
|
69
|
+
const host = process.env.HTTP_HOST?.trim() || '127.0.0.1';
|
|
70
|
+
const endpoint = process.env.HTTP_MCP_ENDPOINT?.trim() || '/mcp';
|
|
71
|
+
const port = getHttpPort();
|
|
39
72
|
return {
|
|
40
|
-
|
|
73
|
+
type: "http-stream",
|
|
41
74
|
options: {
|
|
42
|
-
|
|
75
|
+
port: port,
|
|
76
|
+
endpoint,
|
|
77
|
+
responseMode: "stream",
|
|
78
|
+
cors: {
|
|
79
|
+
allowOrigin: "*",
|
|
80
|
+
allowedOrigins: getCorsAllowedOrigins(),
|
|
81
|
+
},
|
|
43
82
|
host,
|
|
44
83
|
},
|
|
45
84
|
};
|
|
46
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Get the version from package.json for the MCP server metadata.
|
|
88
|
+
*/
|
|
47
89
|
function getVersion() {
|
|
48
90
|
const pkgMetadata = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
|
|
49
91
|
if (!pkgMetadata?.version || typeof pkgMetadata.version !== "string") {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAI1D,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB;IACvB,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,OAA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ACjB,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC;QAC9B,IAAI,EAAE,YAAY;QAClB,OAAO;QACP,QAAQ,EAAE,SAAS;QACnB,SAAS;KACV,CAAC,CAAC;IAEH,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CACX,wBAAwB,EACxB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACrD,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/logger.d.ts
CHANGED
package/dist/logger.js
CHANGED
|
@@ -4,8 +4,11 @@ const formats = {
|
|
|
4
4
|
json: format.json(),
|
|
5
5
|
simple: format.simple()
|
|
6
6
|
};
|
|
7
|
+
function isLogFormat(value) {
|
|
8
|
+
return Object.keys(formats).includes(value);
|
|
9
|
+
}
|
|
7
10
|
const LOG_FORMAT = process.env.LOG_FORMAT ? process.env.LOG_FORMAT : 'simple';
|
|
8
|
-
if (!
|
|
11
|
+
if (!isLogFormat(LOG_FORMAT)) {
|
|
9
12
|
throw new Error(`LOG_FORMAT=${LOG_FORMAT} not found!`);
|
|
10
13
|
}
|
|
11
14
|
const logger = createLogger({
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE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
-
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exposing administrative units that cover a given point.
|
|
3
|
+
*/
|
|
4
|
+
import BaseTool from "./BaseTool.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
declare const adminexpressInputSchema: z.ZodObject<{
|
|
4
7
|
lon: z.ZodNumber;
|
|
5
8
|
lat: z.ZodNumber;
|
|
6
9
|
}, "strict", z.ZodTypeAny, {
|
|
7
|
-
lon
|
|
8
|
-
lat
|
|
10
|
+
lon: number;
|
|
11
|
+
lat: number;
|
|
9
12
|
}, {
|
|
10
|
-
lon
|
|
11
|
-
lat
|
|
13
|
+
lon: number;
|
|
14
|
+
lat: number;
|
|
12
15
|
}>;
|
|
13
16
|
type AdminexpressInput = z.infer<typeof adminexpressInputSchema>;
|
|
14
|
-
declare class AdminexpressTool extends
|
|
17
|
+
declare class AdminexpressTool extends BaseTool<AdminexpressInput> {
|
|
15
18
|
name: string;
|
|
16
19
|
title: string;
|
|
17
20
|
annotations: {
|
|
@@ -30,11 +33,11 @@ declare class AdminexpressTool extends MCPTool<AdminexpressInput> {
|
|
|
30
33
|
typename: z.ZodString;
|
|
31
34
|
feature_id: z.ZodString;
|
|
32
35
|
}, "strip", z.ZodTypeAny, {
|
|
33
|
-
typename
|
|
34
|
-
feature_id
|
|
36
|
+
typename: string;
|
|
37
|
+
feature_id: string;
|
|
35
38
|
}, {
|
|
36
|
-
typename
|
|
37
|
-
feature_id
|
|
39
|
+
typename: string;
|
|
40
|
+
feature_id: string;
|
|
38
41
|
}>;
|
|
39
42
|
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
40
43
|
type: z.ZodString;
|
|
@@ -44,11 +47,11 @@ declare class AdminexpressTool extends MCPTool<AdminexpressInput> {
|
|
|
44
47
|
typename: z.ZodString;
|
|
45
48
|
feature_id: z.ZodString;
|
|
46
49
|
}, "strip", z.ZodTypeAny, {
|
|
47
|
-
typename
|
|
48
|
-
feature_id
|
|
50
|
+
typename: string;
|
|
51
|
+
feature_id: string;
|
|
49
52
|
}, {
|
|
50
|
-
typename
|
|
51
|
-
feature_id
|
|
53
|
+
typename: string;
|
|
54
|
+
feature_id: string;
|
|
52
55
|
}>;
|
|
53
56
|
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
54
57
|
type: z.ZodString;
|
|
@@ -58,15 +61,15 @@ declare class AdminexpressTool extends MCPTool<AdminexpressInput> {
|
|
|
58
61
|
typename: z.ZodString;
|
|
59
62
|
feature_id: z.ZodString;
|
|
60
63
|
}, "strip", z.ZodTypeAny, {
|
|
61
|
-
typename
|
|
62
|
-
feature_id
|
|
64
|
+
typename: string;
|
|
65
|
+
feature_id: string;
|
|
63
66
|
}, {
|
|
64
|
-
typename
|
|
65
|
-
feature_id
|
|
67
|
+
typename: string;
|
|
68
|
+
feature_id: string;
|
|
66
69
|
}>;
|
|
67
70
|
}, z.ZodUnknown, "strip">>, "many">;
|
|
68
71
|
}, "strip", z.ZodTypeAny, {
|
|
69
|
-
results
|
|
72
|
+
results: z.objectOutputType<{
|
|
70
73
|
type: z.ZodString;
|
|
71
74
|
id: z.ZodString;
|
|
72
75
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
@@ -74,15 +77,15 @@ declare class AdminexpressTool extends MCPTool<AdminexpressInput> {
|
|
|
74
77
|
typename: z.ZodString;
|
|
75
78
|
feature_id: z.ZodString;
|
|
76
79
|
}, "strip", z.ZodTypeAny, {
|
|
77
|
-
typename
|
|
78
|
-
feature_id
|
|
80
|
+
typename: string;
|
|
81
|
+
feature_id: string;
|
|
79
82
|
}, {
|
|
80
|
-
typename
|
|
81
|
-
feature_id
|
|
83
|
+
typename: string;
|
|
84
|
+
feature_id: string;
|
|
82
85
|
}>;
|
|
83
86
|
}, z.ZodUnknown, "strip">[];
|
|
84
87
|
}, {
|
|
85
|
-
results
|
|
88
|
+
results: z.objectInputType<{
|
|
86
89
|
type: z.ZodString;
|
|
87
90
|
id: z.ZodString;
|
|
88
91
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
@@ -90,11 +93,11 @@ declare class AdminexpressTool extends MCPTool<AdminexpressInput> {
|
|
|
90
93
|
typename: z.ZodString;
|
|
91
94
|
feature_id: z.ZodString;
|
|
92
95
|
}, "strip", z.ZodTypeAny, {
|
|
93
|
-
typename
|
|
94
|
-
feature_id
|
|
96
|
+
typename: string;
|
|
97
|
+
feature_id: string;
|
|
95
98
|
}, {
|
|
96
|
-
typename
|
|
97
|
-
feature_id
|
|
99
|
+
typename: string;
|
|
100
|
+
feature_id: string;
|
|
98
101
|
}>;
|
|
99
102
|
}, z.ZodUnknown, "strip">[];
|
|
100
103
|
}>;
|
|
@@ -102,14 +105,20 @@ declare class AdminexpressTool extends MCPTool<AdminexpressInput> {
|
|
|
102
105
|
lon: z.ZodNumber;
|
|
103
106
|
lat: z.ZodNumber;
|
|
104
107
|
}, "strict", z.ZodTypeAny, {
|
|
105
|
-
lon
|
|
106
|
-
lat
|
|
108
|
+
lon: number;
|
|
109
|
+
lat: number;
|
|
107
110
|
}, {
|
|
108
|
-
lon
|
|
109
|
-
lat
|
|
111
|
+
lon: number;
|
|
112
|
+
lat: number;
|
|
110
113
|
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Looks up the administrative units covering the requested point.
|
|
116
|
+
*
|
|
117
|
+
* @param input Normalized tool input.
|
|
118
|
+
* @returns The matching administrative units enriched with reusable `feature_ref` metadata.
|
|
119
|
+
*/
|
|
111
120
|
execute(input: AdminexpressInput): Promise<{
|
|
112
|
-
results:
|
|
121
|
+
results: import("../helpers/wfs_engine/response.js").FlatItem[];
|
|
113
122
|
}>;
|
|
114
123
|
}
|
|
115
124
|
export default AdminexpressTool;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exposing administrative units that cover a given point.
|
|
3
|
+
*/
|
|
4
|
+
import BaseTool from "./BaseTool.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
import { getAdminUnits, ADMINEXPRESS_TYPES, ADMINEXPRESS_SOURCE } from "../gpf/adminexpress.js";
|
|
4
7
|
import { READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS } from "../helpers/toolAnnotations.js";
|
|
5
8
|
import { featureRefSchema, lonSchema, latSchema } from "../helpers/schemas.js";
|
|
9
|
+
import logger from "../logger.js";
|
|
10
|
+
// --- Schema ---
|
|
6
11
|
const adminexpressInputSchema = z.object({
|
|
7
12
|
lon: lonSchema,
|
|
8
13
|
lat: latSchema,
|
|
@@ -18,19 +23,30 @@ const adminexpressResultSchema = z
|
|
|
18
23
|
const adminexpressOutputSchema = z.object({
|
|
19
24
|
results: z.array(adminexpressResultSchema).describe("La liste des unités administratives couvrant le point demandé."),
|
|
20
25
|
});
|
|
21
|
-
|
|
26
|
+
// --- Tool ---
|
|
27
|
+
class AdminexpressTool extends BaseTool {
|
|
22
28
|
name = "adminexpress";
|
|
23
29
|
title = "Unités administratives";
|
|
24
30
|
annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
|
|
25
31
|
description = [
|
|
26
32
|
`Renvoie, pour un point donné par sa \`longitude\` et sa \`latitude\`, la liste des unités administratives (${ADMINEXPRESS_TYPES.join(", ")}) qui le couvrent, sous forme d'objets typés contenant leurs propriétés administratives.`,
|
|
27
33
|
"Les résultats incluent un `feature_ref` WFS réutilisable. Les propriétés incluent notamment le code INSEE.",
|
|
28
|
-
"Le `feature_ref` de chaque unité administrative est directement réutilisable dans `gpf_wfs_get_features` avec `spatial_operator=\"intersects_feature\"` pour interroger
|
|
34
|
+
"Le `feature_ref` de chaque unité administrative est directement réutilisable dans `gpf_wfs_get_features` avec `spatial_operator=\"intersects_feature\"` pour interroger d'autres données sur cette emprise.",
|
|
35
|
+
"Pour récupérer exactement l'objet correspondant au `feature_ref`, utiliser `gpf_wfs_get_feature_by_id`.",
|
|
29
36
|
`(source : ${ADMINEXPRESS_SOURCE}).`
|
|
30
37
|
].join("\n");
|
|
31
38
|
outputSchemaShape = adminexpressOutputSchema;
|
|
32
39
|
schema = adminexpressInputSchema;
|
|
40
|
+
/**
|
|
41
|
+
* Looks up the administrative units covering the requested point.
|
|
42
|
+
*
|
|
43
|
+
* @param input Normalized tool input.
|
|
44
|
+
* @returns The matching administrative units enriched with reusable `feature_ref` metadata.
|
|
45
|
+
*/
|
|
33
46
|
async execute(input) {
|
|
47
|
+
logger.info(`[tool] execute ${this.name} ...`, {
|
|
48
|
+
input: input
|
|
49
|
+
});
|
|
34
50
|
return {
|
|
35
51
|
results: await getAdminUnits(input.lon, input.lat),
|
|
36
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminexpressTool.js","sourceRoot":"","sources":["../../src/tools/AdminexpressTool.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AdminexpressTool.js","sourceRoot":"","sources":["../../src/tools/AdminexpressTool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,qCAAqC,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,iBAAiB;AAEjB,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;CACf,CAAC,CAAC,MAAM,EAAE,CAAC;AAMZ,MAAM,wBAAwB,GAAG,CAAC;KAC/B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,kBAAkB,CAAC,IA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gB,CAAC"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exposing altitude lookup for a single geographic position.
|
|
3
|
+
*/
|
|
4
|
+
import BaseTool from "./BaseTool.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
declare const altitudeInputSchema: z.ZodObject<{
|
|
4
7
|
lon: z.ZodNumber;
|
|
5
8
|
lat: z.ZodNumber;
|
|
6
9
|
}, "strict", z.ZodTypeAny, {
|
|
7
|
-
lon
|
|
8
|
-
lat
|
|
10
|
+
lon: number;
|
|
11
|
+
lat: number;
|
|
9
12
|
}, {
|
|
10
|
-
lon
|
|
11
|
-
lat
|
|
13
|
+
lon: number;
|
|
14
|
+
lat: number;
|
|
12
15
|
}>;
|
|
13
16
|
type AltitudeInput = z.infer<typeof altitudeInputSchema>;
|
|
14
|
-
declare class AltitudeTool extends
|
|
17
|
+
declare class AltitudeTool extends BaseTool<AltitudeInput> {
|
|
15
18
|
name: string;
|
|
16
19
|
title: string;
|
|
17
20
|
annotations: {
|
|
@@ -22,54 +25,42 @@ declare class AltitudeTool extends MCPTool<AltitudeInput> {
|
|
|
22
25
|
};
|
|
23
26
|
description: string;
|
|
24
27
|
protected outputSchemaShape: z.ZodObject<{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
accuracy: z.ZodString;
|
|
30
|
-
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
lon?: number;
|
|
32
|
-
lat?: number;
|
|
33
|
-
altitude?: number;
|
|
34
|
-
accuracy?: string;
|
|
35
|
-
}, {
|
|
36
|
-
lon?: number;
|
|
37
|
-
lat?: number;
|
|
38
|
-
altitude?: number;
|
|
39
|
-
accuracy?: string;
|
|
40
|
-
}>;
|
|
28
|
+
lon: z.ZodNumber;
|
|
29
|
+
lat: z.ZodNumber;
|
|
30
|
+
altitude: z.ZodNumber;
|
|
31
|
+
accuracy: z.ZodString;
|
|
41
32
|
}, "strip", z.ZodTypeAny, {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
accuracy?: string;
|
|
47
|
-
};
|
|
33
|
+
lon: number;
|
|
34
|
+
lat: number;
|
|
35
|
+
altitude: number;
|
|
36
|
+
accuracy: string;
|
|
48
37
|
}, {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
accuracy?: string;
|
|
54
|
-
};
|
|
38
|
+
lon: number;
|
|
39
|
+
lat: number;
|
|
40
|
+
altitude: number;
|
|
41
|
+
accuracy: string;
|
|
55
42
|
}>;
|
|
56
43
|
schema: z.ZodObject<{
|
|
57
44
|
lon: z.ZodNumber;
|
|
58
45
|
lat: z.ZodNumber;
|
|
59
46
|
}, "strict", z.ZodTypeAny, {
|
|
60
|
-
lon
|
|
61
|
-
lat
|
|
47
|
+
lon: number;
|
|
48
|
+
lat: number;
|
|
62
49
|
}, {
|
|
63
|
-
lon
|
|
64
|
-
lat
|
|
50
|
+
lon: number;
|
|
51
|
+
lat: number;
|
|
65
52
|
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Resolves the altitude information for the requested position.
|
|
55
|
+
*
|
|
56
|
+
* @param input Normalized tool input.
|
|
57
|
+
* @returns The altitude payload returned by the upstream service.
|
|
58
|
+
*/
|
|
66
59
|
execute(input: AltitudeInput): Promise<{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
accuracy: any;
|
|
72
|
-
};
|
|
60
|
+
lon: number;
|
|
61
|
+
lat: number;
|
|
62
|
+
altitude: number;
|
|
63
|
+
accuracy: string;
|
|
73
64
|
}>;
|
|
74
65
|
}
|
|
75
66
|
export default AltitudeTool;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exposing altitude lookup for a single geographic position.
|
|
3
|
+
*/
|
|
4
|
+
import BaseTool from "./BaseTool.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
import { ALTITUDE_SOURCE, getAltitudeByLocation } from "../gpf/altitude.js";
|
|
4
7
|
import { READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS } from "../helpers/toolAnnotations.js";
|
|
5
8
|
import { lonSchema, latSchema } from "../helpers/schemas.js";
|
|
9
|
+
import logger from "../logger.js";
|
|
10
|
+
// --- Schema ---
|
|
6
11
|
const altitudeInputSchema = z.object({
|
|
7
12
|
lon: lonSchema,
|
|
8
13
|
lat: latSchema,
|
|
@@ -13,20 +18,26 @@ const altitudeResultSchema = z.object({
|
|
|
13
18
|
altitude: z.number().describe("L'altitude du point."),
|
|
14
19
|
accuracy: z.string().describe("L'information de précision associée à l'altitude."),
|
|
15
20
|
});
|
|
16
|
-
const altitudeOutputSchema =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class AltitudeTool extends MCPTool {
|
|
21
|
+
const altitudeOutputSchema = altitudeResultSchema;
|
|
22
|
+
// --- Tool ---
|
|
23
|
+
class AltitudeTool extends BaseTool {
|
|
20
24
|
name = "altitude";
|
|
21
25
|
title = "Altitude d’une position";
|
|
22
26
|
annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
|
|
23
27
|
description = `Renvoie l'altitude (en mètres) et la précision de la mesure (accuracy) d'un point géographique à partir de sa longitude et de sa latitude. (source : ${ALTITUDE_SOURCE}).`;
|
|
24
28
|
outputSchemaShape = altitudeOutputSchema;
|
|
25
29
|
schema = altitudeInputSchema;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves the altitude information for the requested position.
|
|
32
|
+
*
|
|
33
|
+
* @param input Normalized tool input.
|
|
34
|
+
* @returns The altitude payload returned by the upstream service.
|
|
35
|
+
*/
|
|
26
36
|
async execute(input) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
37
|
+
logger.info(`[tool] execute ${this.name} ...`, {
|
|
38
|
+
input: input
|
|
39
|
+
});
|
|
40
|
+
return await getAltitudeByLocation(input.lon, input.lat);
|
|
30
41
|
}
|
|
31
42
|
}
|
|
32
43
|
export default AltitudeTool;
|