@ignfab/geocontext 0.9.6 → 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 +334 -257
- 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 +16 -4
- package/dist/helpers/jsonSchema.js +7 -1
- 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_internal → wfs_engine}/request.d.ts +49 -2
- package/dist/helpers/{wfs_internal → wfs_engine}/request.js +77 -1
- 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 +17 -2
- 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 +17 -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 +17 -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 +25 -14
- package/dist/tools/GpfWfsDescribeTypeTool.js.map +1 -1
- package/dist/tools/GpfWfsGetFeatureByIdTool.d.ts +52 -73
- package/dist/tools/GpfWfsGetFeatureByIdTool.js +50 -107
- package/dist/tools/GpfWfsGetFeatureByIdTool.js.map +1 -1
- package/dist/tools/GpfWfsGetFeaturesTool.d.ts +89 -114
- package/dist/tools/GpfWfsGetFeaturesTool.js +29 -120
- 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 +17 -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 -55
- package/dist/helpers/wfs_internal/compile.js +0 -596
- package/dist/helpers/wfs_internal/compile.js.map +0 -1
- package/dist/helpers/wfs_internal/request.js.map +0 -1
- package/dist/helpers/wfs_internal/response.d.ts +0 -29
- package/dist/helpers/wfs_internal/response.js +0 -59
- 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
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exposing nearby servitudes d'utilité publique for a given point.
|
|
3
|
+
*/
|
|
4
|
+
import BaseTool from "./BaseTool.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
declare const assietteSupInputSchema: 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 AssietteSupInput = z.infer<typeof assietteSupInputSchema>;
|
|
14
|
-
declare class AssietteSupTool extends
|
|
17
|
+
declare class AssietteSupTool extends BaseTool<AssietteSupInput> {
|
|
15
18
|
name: string;
|
|
16
19
|
title: string;
|
|
17
20
|
annotations: {
|
|
@@ -30,11 +33,11 @@ declare class AssietteSupTool extends MCPTool<AssietteSupInput> {
|
|
|
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
|
distance: z.ZodNumber;
|
|
40
43
|
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
@@ -45,11 +48,11 @@ declare class AssietteSupTool extends MCPTool<AssietteSupInput> {
|
|
|
45
48
|
typename: z.ZodString;
|
|
46
49
|
feature_id: z.ZodString;
|
|
47
50
|
}, "strip", z.ZodTypeAny, {
|
|
48
|
-
typename
|
|
49
|
-
feature_id
|
|
51
|
+
typename: string;
|
|
52
|
+
feature_id: string;
|
|
50
53
|
}, {
|
|
51
|
-
typename
|
|
52
|
-
feature_id
|
|
54
|
+
typename: string;
|
|
55
|
+
feature_id: string;
|
|
53
56
|
}>>;
|
|
54
57
|
distance: z.ZodNumber;
|
|
55
58
|
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
@@ -60,16 +63,16 @@ declare class AssietteSupTool extends MCPTool<AssietteSupInput> {
|
|
|
60
63
|
typename: z.ZodString;
|
|
61
64
|
feature_id: z.ZodString;
|
|
62
65
|
}, "strip", z.ZodTypeAny, {
|
|
63
|
-
typename
|
|
64
|
-
feature_id
|
|
66
|
+
typename: string;
|
|
67
|
+
feature_id: string;
|
|
65
68
|
}, {
|
|
66
|
-
typename
|
|
67
|
-
feature_id
|
|
69
|
+
typename: string;
|
|
70
|
+
feature_id: string;
|
|
68
71
|
}>>;
|
|
69
72
|
distance: z.ZodNumber;
|
|
70
73
|
}, z.ZodUnknown, "strip">>, "many">;
|
|
71
74
|
}, "strip", z.ZodTypeAny, {
|
|
72
|
-
results
|
|
75
|
+
results: z.objectOutputType<{
|
|
73
76
|
type: z.ZodString;
|
|
74
77
|
id: z.ZodString;
|
|
75
78
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
@@ -77,16 +80,16 @@ declare class AssietteSupTool extends MCPTool<AssietteSupInput> {
|
|
|
77
80
|
typename: z.ZodString;
|
|
78
81
|
feature_id: z.ZodString;
|
|
79
82
|
}, "strip", z.ZodTypeAny, {
|
|
80
|
-
typename
|
|
81
|
-
feature_id
|
|
83
|
+
typename: string;
|
|
84
|
+
feature_id: string;
|
|
82
85
|
}, {
|
|
83
|
-
typename
|
|
84
|
-
feature_id
|
|
86
|
+
typename: string;
|
|
87
|
+
feature_id: string;
|
|
85
88
|
}>>;
|
|
86
89
|
distance: z.ZodNumber;
|
|
87
90
|
}, z.ZodUnknown, "strip">[];
|
|
88
91
|
}, {
|
|
89
|
-
results
|
|
92
|
+
results: z.objectInputType<{
|
|
90
93
|
type: z.ZodString;
|
|
91
94
|
id: z.ZodString;
|
|
92
95
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
@@ -94,11 +97,11 @@ declare class AssietteSupTool extends MCPTool<AssietteSupInput> {
|
|
|
94
97
|
typename: z.ZodString;
|
|
95
98
|
feature_id: z.ZodString;
|
|
96
99
|
}, "strip", z.ZodTypeAny, {
|
|
97
|
-
typename
|
|
98
|
-
feature_id
|
|
100
|
+
typename: string;
|
|
101
|
+
feature_id: string;
|
|
99
102
|
}, {
|
|
100
|
-
typename
|
|
101
|
-
feature_id
|
|
103
|
+
typename: string;
|
|
104
|
+
feature_id: string;
|
|
102
105
|
}>>;
|
|
103
106
|
distance: z.ZodNumber;
|
|
104
107
|
}, z.ZodUnknown, "strip">[];
|
|
@@ -107,16 +110,30 @@ declare class AssietteSupTool extends MCPTool<AssietteSupInput> {
|
|
|
107
110
|
lon: z.ZodNumber;
|
|
108
111
|
lat: z.ZodNumber;
|
|
109
112
|
}, "strict", z.ZodTypeAny, {
|
|
110
|
-
lon
|
|
111
|
-
lat
|
|
113
|
+
lon: number;
|
|
114
|
+
lat: number;
|
|
112
115
|
}, {
|
|
113
|
-
lon
|
|
114
|
-
lat
|
|
116
|
+
lon: number;
|
|
117
|
+
lat: number;
|
|
115
118
|
}>;
|
|
119
|
+
/**
|
|
120
|
+
* Looks up nearby SUP footprints relevant to the requested point.
|
|
121
|
+
*
|
|
122
|
+
* @param input Normalized tool input.
|
|
123
|
+
* @returns The list of nearby assiettes with optional reusable `feature_ref` metadata.
|
|
124
|
+
*/
|
|
116
125
|
execute(input: AssietteSupInput): Promise<{
|
|
117
|
-
results: {
|
|
126
|
+
results: (Record<string, unknown> & {
|
|
127
|
+
type: string;
|
|
128
|
+
id: string;
|
|
129
|
+
bbox?: number[];
|
|
130
|
+
feature_ref?: {
|
|
131
|
+
typename: string;
|
|
132
|
+
feature_id: string;
|
|
133
|
+
};
|
|
134
|
+
} & {
|
|
118
135
|
distance: number;
|
|
119
|
-
}[];
|
|
136
|
+
})[];
|
|
120
137
|
}>;
|
|
121
138
|
}
|
|
122
139
|
export default AssietteSupTool;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exposing nearby servitudes d'utilité publique for a given point.
|
|
3
|
+
*/
|
|
4
|
+
import BaseTool from "./BaseTool.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
import { getAssiettesServitudes, URBANISME_SOURCE } from "../gpf/urbanisme.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 assietteSupInputSchema = z.object({
|
|
7
12
|
lon: lonSchema,
|
|
8
13
|
lat: latSchema,
|
|
@@ -19,7 +24,8 @@ const assietteSupResultSchema = z
|
|
|
19
24
|
const assietteSupOutputSchema = z.object({
|
|
20
25
|
results: z.array(assietteSupResultSchema).describe("La liste des assiettes de servitudes d'utilité publique pertinentes pour le point demandé."),
|
|
21
26
|
});
|
|
22
|
-
|
|
27
|
+
// --- Tool ---
|
|
28
|
+
class AssietteSupTool extends BaseTool {
|
|
23
29
|
name = "assiette_sup";
|
|
24
30
|
title = "Servitudes d’utilité publique";
|
|
25
31
|
annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
|
|
@@ -32,7 +38,16 @@ class AssietteSupTool extends MCPTool {
|
|
|
32
38
|
].join("\n");
|
|
33
39
|
outputSchemaShape = assietteSupOutputSchema;
|
|
34
40
|
schema = assietteSupInputSchema;
|
|
41
|
+
/**
|
|
42
|
+
* Looks up nearby SUP footprints relevant to the requested point.
|
|
43
|
+
*
|
|
44
|
+
* @param input Normalized tool input.
|
|
45
|
+
* @returns The list of nearby assiettes with optional reusable `feature_ref` metadata.
|
|
46
|
+
*/
|
|
35
47
|
async execute(input) {
|
|
48
|
+
logger.info(`[tool] execute ${this.name} ...`, {
|
|
49
|
+
input: input
|
|
50
|
+
});
|
|
36
51
|
return {
|
|
37
52
|
results: await getAssiettesServitudes(input.lon, input.lat),
|
|
38
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssietteSupTool.js","sourceRoot":"","sources":["../../src/tools/AssietteSupTool.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AssietteSupTool.js","sourceRoot":"","sources":["../../src/tools/AssietteSupTool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,qCAAqC,EAAE,MAAM,+BAA+B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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACH,iBAAiB,GAAG,uBAAuB,CAAC;IAEtD,MAAM,GAAG,sBAAsB,CAAC;IAEhC;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,KAAuB;QACnC,MAAM,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,IAAI,MAAM,EAAE;YAC7C,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE,MAAM,sBAAsB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;SAC5D,CAAC;IACJ,CAAC;CACF;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MCPTool } from "mcp-framework";
|
|
2
|
+
export default abstract class BaseTool<TInput extends Record<string, any> = any> extends MCPTool<TInput> {
|
|
3
|
+
toolCall(request: {
|
|
4
|
+
params: {
|
|
5
|
+
name: string;
|
|
6
|
+
arguments?: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
}): Promise<import("mcp-framework").ToolResponse>;
|
|
9
|
+
protected createErrorResponse(error: unknown): {
|
|
10
|
+
content: {
|
|
11
|
+
type: "text";
|
|
12
|
+
text: string;
|
|
13
|
+
}[];
|
|
14
|
+
structuredContent: Record<string, unknown>;
|
|
15
|
+
isError: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { MCPTool } from "mcp-framework";
|
|
3
|
+
import { normalizeToolError } from "../helpers/errors/toolError.js";
|
|
4
|
+
import logger from "../logger.js";
|
|
5
|
+
const toolInputStorage = new AsyncLocalStorage();
|
|
6
|
+
export default class BaseTool extends MCPTool {
|
|
7
|
+
async toolCall(request) {
|
|
8
|
+
return toolInputStorage.run(request.params.arguments || {}, () => super.toolCall(request));
|
|
9
|
+
}
|
|
10
|
+
createErrorResponse(error) {
|
|
11
|
+
const payload = normalizeToolError(error);
|
|
12
|
+
const metadata = {
|
|
13
|
+
tool: this.name,
|
|
14
|
+
problem_type: payload.type,
|
|
15
|
+
problem_title: payload.title,
|
|
16
|
+
error_codes: payload.errors.map((item) => item.code),
|
|
17
|
+
};
|
|
18
|
+
const toolInput = toolInputStorage.getStore();
|
|
19
|
+
if (toolInput !== undefined) {
|
|
20
|
+
metadata.input = toolInput;
|
|
21
|
+
}
|
|
22
|
+
if (payload.upstream?.status !== undefined) {
|
|
23
|
+
metadata.upstream_status = payload.upstream.status;
|
|
24
|
+
}
|
|
25
|
+
if (error instanceof Error && error.name && error.name !== "Error") {
|
|
26
|
+
metadata.error_name = error.name;
|
|
27
|
+
}
|
|
28
|
+
logger.error(`[tool] failed ${this.name}: ${payload.detail}`, metadata);
|
|
29
|
+
return {
|
|
30
|
+
content: [
|
|
31
|
+
{
|
|
32
|
+
type: "text",
|
|
33
|
+
text: payload.detail,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
structuredContent: payload,
|
|
37
|
+
isError: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=BaseTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseTool.js","sourceRoot":"","sources":["../../src/tools/BaseTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,EAA2B,CAAC;AAE1E,MAAM,CAAC,OAAO,OAAgB,QAAmD,SAAQ,OAAe;IACtG,KAAK,CAAC,QAAQ,CAAC,OAKd;QACC,OAAO,gBAAgB,CAAC,GAAG,CAAC,OAAO,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CACF"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exposing nearby cadastral objects for a given point.
|
|
3
|
+
*/
|
|
4
|
+
import BaseTool from "./BaseTool.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
declare const cadastreInputSchema: 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 CadastreInput = z.infer<typeof cadastreInputSchema>;
|
|
14
|
-
declare class CadastreTool extends
|
|
17
|
+
declare class CadastreTool extends BaseTool<CadastreInput> {
|
|
15
18
|
name: string;
|
|
16
19
|
title: string;
|
|
17
20
|
annotations: {
|
|
@@ -30,11 +33,11 @@ declare class CadastreTool extends MCPTool<CadastreInput> {
|
|
|
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
|
distance: z.ZodNumber;
|
|
40
43
|
source: z.ZodString;
|
|
@@ -46,11 +49,11 @@ declare class CadastreTool extends MCPTool<CadastreInput> {
|
|
|
46
49
|
typename: z.ZodString;
|
|
47
50
|
feature_id: z.ZodString;
|
|
48
51
|
}, "strip", z.ZodTypeAny, {
|
|
49
|
-
typename
|
|
50
|
-
feature_id
|
|
52
|
+
typename: string;
|
|
53
|
+
feature_id: string;
|
|
51
54
|
}, {
|
|
52
|
-
typename
|
|
53
|
-
feature_id
|
|
55
|
+
typename: string;
|
|
56
|
+
feature_id: string;
|
|
54
57
|
}>;
|
|
55
58
|
distance: z.ZodNumber;
|
|
56
59
|
source: z.ZodString;
|
|
@@ -62,17 +65,17 @@ declare class CadastreTool extends MCPTool<CadastreInput> {
|
|
|
62
65
|
typename: z.ZodString;
|
|
63
66
|
feature_id: z.ZodString;
|
|
64
67
|
}, "strip", z.ZodTypeAny, {
|
|
65
|
-
typename
|
|
66
|
-
feature_id
|
|
68
|
+
typename: string;
|
|
69
|
+
feature_id: string;
|
|
67
70
|
}, {
|
|
68
|
-
typename
|
|
69
|
-
feature_id
|
|
71
|
+
typename: string;
|
|
72
|
+
feature_id: string;
|
|
70
73
|
}>;
|
|
71
74
|
distance: z.ZodNumber;
|
|
72
75
|
source: z.ZodString;
|
|
73
76
|
}, z.ZodUnknown, "strip">>, "many">;
|
|
74
77
|
}, "strip", z.ZodTypeAny, {
|
|
75
|
-
results
|
|
78
|
+
results: z.objectOutputType<{
|
|
76
79
|
type: z.ZodString;
|
|
77
80
|
id: z.ZodString;
|
|
78
81
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
@@ -80,17 +83,17 @@ declare class CadastreTool extends MCPTool<CadastreInput> {
|
|
|
80
83
|
typename: z.ZodString;
|
|
81
84
|
feature_id: z.ZodString;
|
|
82
85
|
}, "strip", z.ZodTypeAny, {
|
|
83
|
-
typename
|
|
84
|
-
feature_id
|
|
86
|
+
typename: string;
|
|
87
|
+
feature_id: string;
|
|
85
88
|
}, {
|
|
86
|
-
typename
|
|
87
|
-
feature_id
|
|
89
|
+
typename: string;
|
|
90
|
+
feature_id: string;
|
|
88
91
|
}>;
|
|
89
92
|
distance: z.ZodNumber;
|
|
90
93
|
source: z.ZodString;
|
|
91
94
|
}, z.ZodUnknown, "strip">[];
|
|
92
95
|
}, {
|
|
93
|
-
results
|
|
96
|
+
results: z.objectInputType<{
|
|
94
97
|
type: z.ZodString;
|
|
95
98
|
id: z.ZodString;
|
|
96
99
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
@@ -98,11 +101,11 @@ declare class CadastreTool extends MCPTool<CadastreInput> {
|
|
|
98
101
|
typename: z.ZodString;
|
|
99
102
|
feature_id: z.ZodString;
|
|
100
103
|
}, "strip", z.ZodTypeAny, {
|
|
101
|
-
typename
|
|
102
|
-
feature_id
|
|
104
|
+
typename: string;
|
|
105
|
+
feature_id: string;
|
|
103
106
|
}, {
|
|
104
|
-
typename
|
|
105
|
-
feature_id
|
|
107
|
+
typename: string;
|
|
108
|
+
feature_id: string;
|
|
106
109
|
}>;
|
|
107
110
|
distance: z.ZodNumber;
|
|
108
111
|
source: z.ZodString;
|
|
@@ -112,14 +115,31 @@ declare class CadastreTool extends MCPTool<CadastreInput> {
|
|
|
112
115
|
lon: z.ZodNumber;
|
|
113
116
|
lat: z.ZodNumber;
|
|
114
117
|
}, "strict", z.ZodTypeAny, {
|
|
115
|
-
lon
|
|
116
|
-
lat
|
|
118
|
+
lon: number;
|
|
119
|
+
lat: number;
|
|
117
120
|
}, {
|
|
118
|
-
lon
|
|
119
|
-
lat
|
|
121
|
+
lon: number;
|
|
122
|
+
lat: number;
|
|
120
123
|
}>;
|
|
124
|
+
/**
|
|
125
|
+
* Returns the nearest cadastral objects around the requested point.
|
|
126
|
+
*
|
|
127
|
+
* @param input Normalized tool input.
|
|
128
|
+
* @returns The nearest cadastral objects, at most one per cadastral type.
|
|
129
|
+
*/
|
|
121
130
|
execute(input: CadastreInput): Promise<{
|
|
122
|
-
results:
|
|
131
|
+
results: (Record<string, unknown> & {
|
|
132
|
+
type: string;
|
|
133
|
+
id: string;
|
|
134
|
+
bbox?: number[];
|
|
135
|
+
feature_ref?: {
|
|
136
|
+
typename: string;
|
|
137
|
+
feature_id: string;
|
|
138
|
+
};
|
|
139
|
+
} & {
|
|
140
|
+
distance: number;
|
|
141
|
+
source: string;
|
|
142
|
+
})[];
|
|
123
143
|
}>;
|
|
124
144
|
}
|
|
125
145
|
export default CadastreTool;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exposing nearby cadastral objects for a given point.
|
|
3
|
+
*/
|
|
4
|
+
import BaseTool from "./BaseTool.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
import { getParcellaireExpress, PARCELLAIRE_EXPRESS_TYPES, PARCELLAIRE_EXPRESS_SOURCE } from "../gpf/parcellaire-express.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 cadastreInputSchema = z.object({
|
|
7
12
|
lon: lonSchema,
|
|
8
13
|
lat: latSchema,
|
|
@@ -20,7 +25,8 @@ const cadastreResultSchema = z
|
|
|
20
25
|
const cadastreOutputSchema = z.object({
|
|
21
26
|
results: z.array(cadastreResultSchema).describe("La liste des objets cadastraux les plus proches du point demandé."),
|
|
22
27
|
});
|
|
23
|
-
|
|
28
|
+
// --- Tool ---
|
|
29
|
+
class CadastreTool extends BaseTool {
|
|
24
30
|
name = "cadastre";
|
|
25
31
|
title = "Informations cadastrales";
|
|
26
32
|
annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
|
|
@@ -34,7 +40,16 @@ class CadastreTool extends MCPTool {
|
|
|
34
40
|
].join("\n");
|
|
35
41
|
outputSchemaShape = cadastreOutputSchema;
|
|
36
42
|
schema = cadastreInputSchema;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the nearest cadastral objects around the requested point.
|
|
45
|
+
*
|
|
46
|
+
* @param input Normalized tool input.
|
|
47
|
+
* @returns The nearest cadastral objects, at most one per cadastral type.
|
|
48
|
+
*/
|
|
37
49
|
async execute(input) {
|
|
50
|
+
logger.info(`[tool] execute ${this.name} ...`, {
|
|
51
|
+
input: input
|
|
52
|
+
});
|
|
38
53
|
return {
|
|
39
54
|
results: await getParcellaireExpress(input.lon, input.lat),
|
|
40
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CadastreTool.js","sourceRoot":"","sources":["../../src/tools/CadastreTool.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CadastreTool.js","sourceRoot":"","sources":["../../src/tools/CadastreTool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC7H,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,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;CACf,CAAC,CAAC,MAAM,EAAE,CAAC;AAMZ,MAAM,oBAAoB,GAAG,CAAC;KAC3B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACjG,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IAC9D,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,2CAA2C,CAAC,CAAC,QAAQ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+
/**
|
|
2
|
+
* MCP tool exposing free-text geocoding and autocomplete.
|
|
3
|
+
*/
|
|
4
|
+
import BaseTool from "./BaseTool.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
declare const geocodeInputSchema: z.ZodObject<{
|
|
4
7
|
text: z.ZodString;
|
|
5
8
|
maximumResponses: z.ZodOptional<z.ZodNumber>;
|
|
6
9
|
}, "strict", z.ZodTypeAny, {
|
|
7
|
-
text
|
|
8
|
-
maximumResponses?: number;
|
|
10
|
+
text: string;
|
|
11
|
+
maximumResponses?: number | undefined;
|
|
9
12
|
}, {
|
|
10
|
-
text
|
|
11
|
-
maximumResponses?: number;
|
|
13
|
+
text: string;
|
|
14
|
+
maximumResponses?: number | undefined;
|
|
12
15
|
}>;
|
|
13
16
|
type GeocodeInput = z.infer<typeof geocodeInputSchema>;
|
|
14
|
-
declare class GeocodeTool extends
|
|
17
|
+
declare class GeocodeTool extends BaseTool<GeocodeInput> {
|
|
15
18
|
name: string;
|
|
16
19
|
title: string;
|
|
17
20
|
annotations: {
|
|
@@ -30,51 +33,64 @@ declare class GeocodeTool extends MCPTool<GeocodeInput> {
|
|
|
30
33
|
city: z.ZodOptional<z.ZodString>;
|
|
31
34
|
zipcode: z.ZodOptional<z.ZodString>;
|
|
32
35
|
}, "strip", z.ZodTypeAny, {
|
|
33
|
-
lon
|
|
34
|
-
lat
|
|
35
|
-
fulltext
|
|
36
|
-
kind?: string;
|
|
37
|
-
city?: string;
|
|
38
|
-
zipcode?: string;
|
|
36
|
+
lon: number;
|
|
37
|
+
lat: number;
|
|
38
|
+
fulltext: string;
|
|
39
|
+
kind?: string | undefined;
|
|
40
|
+
city?: string | undefined;
|
|
41
|
+
zipcode?: string | undefined;
|
|
39
42
|
}, {
|
|
40
|
-
lon
|
|
41
|
-
lat
|
|
42
|
-
fulltext
|
|
43
|
-
kind?: string;
|
|
44
|
-
city?: string;
|
|
45
|
-
zipcode?: string;
|
|
43
|
+
lon: number;
|
|
44
|
+
lat: number;
|
|
45
|
+
fulltext: string;
|
|
46
|
+
kind?: string | undefined;
|
|
47
|
+
city?: string | undefined;
|
|
48
|
+
zipcode?: string | undefined;
|
|
46
49
|
}>, "many">;
|
|
47
50
|
}, "strip", z.ZodTypeAny, {
|
|
48
|
-
results
|
|
49
|
-
lon
|
|
50
|
-
lat
|
|
51
|
-
fulltext
|
|
52
|
-
kind?: string;
|
|
53
|
-
city?: string;
|
|
54
|
-
zipcode?: string;
|
|
51
|
+
results: {
|
|
52
|
+
lon: number;
|
|
53
|
+
lat: number;
|
|
54
|
+
fulltext: string;
|
|
55
|
+
kind?: string | undefined;
|
|
56
|
+
city?: string | undefined;
|
|
57
|
+
zipcode?: string | undefined;
|
|
55
58
|
}[];
|
|
56
59
|
}, {
|
|
57
|
-
results
|
|
58
|
-
lon
|
|
59
|
-
lat
|
|
60
|
-
fulltext
|
|
61
|
-
kind?: string;
|
|
62
|
-
city?: string;
|
|
63
|
-
zipcode?: string;
|
|
60
|
+
results: {
|
|
61
|
+
lon: number;
|
|
62
|
+
lat: number;
|
|
63
|
+
fulltext: string;
|
|
64
|
+
kind?: string | undefined;
|
|
65
|
+
city?: string | undefined;
|
|
66
|
+
zipcode?: string | undefined;
|
|
64
67
|
}[];
|
|
65
68
|
}>;
|
|
66
69
|
schema: z.ZodObject<{
|
|
67
70
|
text: z.ZodString;
|
|
68
71
|
maximumResponses: z.ZodOptional<z.ZodNumber>;
|
|
69
72
|
}, "strict", z.ZodTypeAny, {
|
|
70
|
-
text
|
|
71
|
-
maximumResponses?: number;
|
|
73
|
+
text: string;
|
|
74
|
+
maximumResponses?: number | undefined;
|
|
72
75
|
}, {
|
|
73
|
-
text
|
|
74
|
-
maximumResponses?: number;
|
|
76
|
+
text: string;
|
|
77
|
+
maximumResponses?: number | undefined;
|
|
75
78
|
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Geocodes a free-text query and returns the ordered candidate list.
|
|
81
|
+
*
|
|
82
|
+
* @param input Normalized tool input.
|
|
83
|
+
* @returns The ordered list of geocoded candidates.
|
|
84
|
+
*/
|
|
76
85
|
execute(input: GeocodeInput): Promise<{
|
|
77
|
-
results:
|
|
86
|
+
results: {
|
|
87
|
+
lon: number;
|
|
88
|
+
lat: number;
|
|
89
|
+
fulltext: string;
|
|
90
|
+
kind: string;
|
|
91
|
+
city: string;
|
|
92
|
+
zipcode: string;
|
|
93
|
+
}[];
|
|
78
94
|
}>;
|
|
79
95
|
}
|
|
80
96
|
export default GeocodeTool;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exposing free-text geocoding and autocomplete.
|
|
3
|
+
*/
|
|
4
|
+
import BaseTool from "./BaseTool.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
import { geocode, GEOCODE_SOURCE } from "../gpf/geocode.js";
|
|
4
7
|
import { READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS } from "../helpers/toolAnnotations.js";
|
|
8
|
+
import logger from "../logger.js";
|
|
9
|
+
// --- Schema ---
|
|
5
10
|
const geocodeInputSchema = z.object({
|
|
6
11
|
text: z
|
|
7
12
|
.string()
|
|
@@ -27,7 +32,8 @@ const geocodeResultSchema = z.object({
|
|
|
27
32
|
const geocodeOutputSchema = z.object({
|
|
28
33
|
results: z.array(geocodeResultSchema).describe("La liste ordonnée des résultats géocodés."),
|
|
29
34
|
});
|
|
30
|
-
|
|
35
|
+
// --- Tool ---
|
|
36
|
+
class GeocodeTool extends BaseTool {
|
|
31
37
|
name = "geocode";
|
|
32
38
|
title = "Géocodage de lieux et d’adresses";
|
|
33
39
|
annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
|
|
@@ -38,7 +44,16 @@ class GeocodeTool extends MCPTool {
|
|
|
38
44
|
].join("\n");
|
|
39
45
|
outputSchemaShape = geocodeOutputSchema;
|
|
40
46
|
schema = geocodeInputSchema;
|
|
47
|
+
/**
|
|
48
|
+
* Geocodes a free-text query and returns the ordered candidate list.
|
|
49
|
+
*
|
|
50
|
+
* @param input Normalized tool input.
|
|
51
|
+
* @returns The ordered list of geocoded candidates.
|
|
52
|
+
*/
|
|
41
53
|
async execute(input) {
|
|
54
|
+
logger.info(`[tool] execute ${this.name} ...`, {
|
|
55
|
+
input: input
|
|
56
|
+
});
|
|
42
57
|
return {
|
|
43
58
|
results: await geocode(input.text, input.maximumResponses),
|
|
44
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeocodeTool.js","sourceRoot":"","sources":["../../src/tools/GeocodeTool.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"GeocodeTool.js","sourceRoot":"","sources":["../../src/tools/GeocodeTool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,iBAAiB;AAEjB,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,EAAE,gCAAgC,CAAC;SACxC,QAAQ,CAAC,0CAA0C,CAAC;IACvD,gBAAgB,EAAE,CAAC;SAChB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,EAAE,CAAC;SACP,QAAQ,EAAE;SACV,QAAQ,CAAC,yEAAyE,CAAC;CACvF,CAAC,CAAC,MAAM,EAAE,CAAC;AAMZ,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QA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