@ignfab/geocontext 0.8.2 → 0.9.1
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 +50 -11
- package/dist/gpf/adminexpress.d.ts +2 -1
- package/dist/gpf/adminexpress.js +7 -3
- package/dist/gpf/adminexpress.js.map +1 -1
- package/dist/gpf/altitude.d.ts +2 -1
- package/dist/gpf/altitude.js +13 -19
- package/dist/gpf/altitude.js.map +1 -1
- package/dist/gpf/geocode.d.ts +3 -1
- package/dist/gpf/geocode.js +19 -8
- package/dist/gpf/geocode.js.map +1 -1
- package/dist/gpf/parcellaire-express.d.ts +2 -1
- package/dist/gpf/parcellaire-express.js +8 -4
- package/dist/gpf/parcellaire-express.js.map +1 -1
- package/dist/gpf/urbanisme.d.ts +4 -2
- package/dist/gpf/urbanisme.js +32 -5
- package/dist/gpf/urbanisme.js.map +1 -1
- package/dist/gpf/wfs.d.ts +11 -14
- package/dist/gpf/wfs.js +138 -43
- package/dist/gpf/wfs.js.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/resources/WfsCqlFilterResource.d.ts +10 -0
- package/dist/resources/WfsCqlFilterResource.js +21 -0
- package/dist/resources/WfsCqlFilterResource.js.map +1 -0
- package/dist/resources/readMarkdownResource.d.ts +1 -0
- package/dist/resources/readMarkdownResource.js +21 -0
- package/dist/resources/readMarkdownResource.js.map +1 -0
- package/dist/tools/AdminexpressTool.d.ts +58 -15
- package/dist/tools/AdminexpressTool.js +33 -13
- package/dist/tools/AdminexpressTool.js.map +1 -1
- package/dist/tools/AltitudeTool.d.ts +64 -16
- package/dist/tools/AltitudeTool.js +30 -12
- package/dist/tools/AltitudeTool.js.map +1 -1
- package/dist/tools/AssietteSupTool.d.ts +64 -16
- package/dist/tools/AssietteSupTool.js +34 -13
- package/dist/tools/AssietteSupTool.js.map +1 -1
- package/dist/tools/CadastreTool.d.ts +68 -15
- package/dist/tools/CadastreTool.js +35 -13
- package/dist/tools/CadastreTool.js.map +1 -1
- package/dist/tools/GeocodeTool.d.ts +73 -10
- package/dist/tools/GeocodeTool.js +35 -9
- package/dist/tools/GeocodeTool.js.map +1 -1
- package/dist/tools/GpfWfsDescribeTypeTool.d.ts +114 -22
- package/dist/tools/GpfWfsDescribeTypeTool.js +38 -15
- package/dist/tools/GpfWfsDescribeTypeTool.js.map +1 -1
- package/dist/tools/GpfWfsGetFeaturesTool.d.ts +65 -28
- package/dist/tools/GpfWfsGetFeaturesTool.js +117 -47
- package/dist/tools/GpfWfsGetFeaturesTool.js.map +1 -1
- package/dist/tools/GpfWfsListTypesTool.d.ts +18 -6
- package/dist/tools/GpfWfsListTypesTool.js +16 -8
- package/dist/tools/GpfWfsListTypesTool.js.map +1 -1
- package/dist/tools/GpfWfsSearchTypesTool.d.ts +61 -14
- package/dist/tools/GpfWfsSearchTypesTool.js +38 -17
- package/dist/tools/GpfWfsSearchTypesTool.js.map +1 -1
- package/dist/tools/UrbanismeTool.d.ts +63 -15
- package/dist/tools/UrbanismeTool.js +42 -13
- package/dist/tools/UrbanismeTool.js.map +1 -1
- package/dist/tools/toolAnnotations.d.ts +6 -0
- package/dist/tools/toolAnnotations.js +7 -0
- package/dist/tools/toolAnnotations.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,31 +1,54 @@
|
|
|
1
1
|
import { MCPTool } from "mcp-framework";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { wfsClient } from "../gpf/wfs.js";
|
|
4
|
+
import { READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS } from "./toolAnnotations.js";
|
|
5
|
+
const gpfWfsDescribeTypeInputSchema = z.object({
|
|
6
|
+
typename: z
|
|
7
|
+
.string()
|
|
8
|
+
.trim()
|
|
9
|
+
.min(1, "le nom du type ne doit pas être vide")
|
|
10
|
+
.describe("Le nom du type (ex : BDTOPO_V3:batiment)"),
|
|
11
|
+
});
|
|
12
|
+
const gpfWfsPropertySchema = z.object({
|
|
13
|
+
name: z.string().describe("Le nom de la propriété."),
|
|
14
|
+
type: z.string().describe("Le type de la propriété."),
|
|
15
|
+
title: z.string().describe("Le titre lisible de la propriété.").optional(),
|
|
16
|
+
description: z.string().describe("La description de la propriété.").optional(),
|
|
17
|
+
enum: z.array(z.string()).describe("Les valeurs possibles de la propriété.").optional(),
|
|
18
|
+
defaultCrs: z.string().describe("Le système de coordonnées par défaut si la propriété est géométrique.").optional(),
|
|
19
|
+
});
|
|
20
|
+
const gpfWfsDescribeTypeOutputSchema = z.object({
|
|
21
|
+
result: z.object({
|
|
22
|
+
id: z.string().describe("L'identifiant complet du type WFS."),
|
|
23
|
+
namespace: z.string().describe("L'espace de nommage du type WFS."),
|
|
24
|
+
name: z.string().describe("Le nom court du type WFS."),
|
|
25
|
+
title: z.string().describe("Le titre lisible du type WFS."),
|
|
26
|
+
description: z.string().describe("La description du type WFS."),
|
|
27
|
+
properties: z.array(gpfWfsPropertySchema).describe("La liste des propriétés du type WFS."),
|
|
28
|
+
}).describe("La description détaillée du type WFS."),
|
|
29
|
+
});
|
|
4
30
|
class GpfWfsDescribeTypeTool extends MCPTool {
|
|
5
31
|
name = "gpf_wfs_describe_type";
|
|
32
|
+
title = "Description d’un type WFS";
|
|
33
|
+
annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
|
|
6
34
|
description = [
|
|
7
|
-
"Renvoie
|
|
35
|
+
"Renvoie le schéma détaillé d'un type WFS à partir de son identifiant (`typename`) : identifiants, description et liste des propriétés.",
|
|
36
|
+
"Utiliser ce tool après `gpf_wfs_search_types` pour inspecter les propriétés disponibles avant d'appeler `gpf_wfs_get_features`.",
|
|
37
|
+
"La sortie inclut notamment le type des propriétés, leur description, et leurs valeurs possibles (`enum`) lorsqu'elles existent.",
|
|
8
38
|
].join("\r\n");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type: z.string(),
|
|
12
|
-
description: "Le nom du type (ex : BDTOPO_V3:batiment)",
|
|
13
|
-
},
|
|
14
|
-
};
|
|
39
|
+
outputSchemaShape = gpfWfsDescribeTypeOutputSchema;
|
|
40
|
+
schema = gpfWfsDescribeTypeInputSchema;
|
|
15
41
|
async execute(input) {
|
|
16
42
|
try {
|
|
17
43
|
const featureType = await wfsClient.getFeatureType(input.typename);
|
|
18
|
-
// remove useless fields outputFormats and otherCrs
|
|
19
|
-
const { outputFormats, otherCrs, ...result } = featureType;
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
44
|
return {
|
|
24
|
-
|
|
25
|
-
message: e.message,
|
|
26
|
-
help: `Utiliser gpf_get_feature_types pour trouver les types disponibles`
|
|
45
|
+
result: featureType,
|
|
27
46
|
};
|
|
28
47
|
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
50
|
+
throw new Error(`${message}. Utiliser gpf_wfs_search_types pour trouver un type valide.`);
|
|
51
|
+
}
|
|
29
52
|
}
|
|
30
53
|
}
|
|
31
54
|
export default GpfWfsDescribeTypeTool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GpfWfsDescribeTypeTool.js","sourceRoot":"","sources":["../../src/tools/GpfWfsDescribeTypeTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"GpfWfsDescribeTypeTool.js","sourceRoot":"","sources":["../../src/tools/GpfWfsDescribeTypeTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,qCAAqC,EAAE,MAAM,sBAAsB,CAAC;AAE7E,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,QAAQ,EAAE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AA6B,CAAC;QAC/D,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,sCAAsC,CAAC;KAC3F,CAAC,CAAC,QAAQ,CAAC,uCAAuC,CAAC;CACrD,CAAC,CAAC;AAEH,MAAM,sBAAuB,SAAQ,OAAgC;IACnE,IAAI,GAAG,uBAAuB,CAAC;IAC/B,KAAK,GAAG,2BAA2B,CAAC;IACpC,WAAW,GAAG,qCAAqC,CAAC;IACpD,WAAW,GAAG;QACZ,wIAAwI;QACxI,iIAAiI;QACjI,iIAAiI;KAClI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACL,iBAAiB,GAAG,8BAA8B,CAAC;IAE7D,MAAM,GAAG,6BAA6B,CAAC;IAEvC,KAAK,CAAC,OAAO,CAAC,KAA8B;QAC1C,IAAI,CAAC;YACH,MAAM,WAAW,GAAe,MAAM,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC/E,OAAO;gBACL,MAAM,EAAE,WAAW;aACpB,CAAC;QACJ,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,8DAA8D,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;CACF;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -1,40 +1,77 @@
|
|
|
1
1
|
import { MCPTool } from "mcp-framework";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
typename:
|
|
3
|
+
declare const gpfWfsGetFeaturesInputSchema: z.ZodObject<{
|
|
4
|
+
typename: z.ZodString;
|
|
5
|
+
property_names: z.ZodOptional<z.ZodString>;
|
|
6
|
+
sort_by: z.ZodOptional<z.ZodString>;
|
|
7
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
cql_filter: z.ZodOptional<z.ZodString>;
|
|
9
|
+
result_type: z.ZodOptional<z.ZodEnum<["results", "hits", "url"]>>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
cql_filter?: string;
|
|
12
|
+
typename?: string;
|
|
5
13
|
property_names?: string;
|
|
6
|
-
count?: number;
|
|
7
14
|
sort_by?: string;
|
|
15
|
+
count?: number;
|
|
16
|
+
result_type?: "results" | "hits" | "url";
|
|
17
|
+
}, {
|
|
8
18
|
cql_filter?: string;
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
typename?: string;
|
|
20
|
+
property_names?: string;
|
|
21
|
+
sort_by?: string;
|
|
22
|
+
count?: number;
|
|
23
|
+
result_type?: "results" | "hits" | "url";
|
|
24
|
+
}>;
|
|
25
|
+
type GpfWfsGetFeaturesInput = z.infer<typeof gpfWfsGetFeaturesInputSchema>;
|
|
11
26
|
declare class GpfWfsGetFeaturesTool extends MCPTool<GpfWfsGetFeaturesInput> {
|
|
12
27
|
name: string;
|
|
28
|
+
title: string;
|
|
29
|
+
annotations: {
|
|
30
|
+
readonly readOnlyHint: true;
|
|
31
|
+
readonly destructiveHint: false;
|
|
32
|
+
readonly idempotentHint: true;
|
|
33
|
+
readonly openWorldHint: true;
|
|
34
|
+
};
|
|
13
35
|
description: string;
|
|
14
|
-
schema: {
|
|
15
|
-
typename:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
schema: z.ZodObject<{
|
|
37
|
+
typename: z.ZodString;
|
|
38
|
+
property_names: z.ZodOptional<z.ZodString>;
|
|
39
|
+
sort_by: z.ZodOptional<z.ZodString>;
|
|
40
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
cql_filter: z.ZodOptional<z.ZodString>;
|
|
42
|
+
result_type: z.ZodOptional<z.ZodEnum<["results", "hits", "url"]>>;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
cql_filter?: string;
|
|
45
|
+
typename?: string;
|
|
46
|
+
property_names?: string;
|
|
47
|
+
sort_by?: string;
|
|
48
|
+
count?: number;
|
|
49
|
+
result_type?: "results" | "hits" | "url";
|
|
50
|
+
}, {
|
|
51
|
+
cql_filter?: string;
|
|
52
|
+
typename?: string;
|
|
53
|
+
property_names?: string;
|
|
54
|
+
sort_by?: string;
|
|
55
|
+
count?: number;
|
|
56
|
+
result_type?: "results" | "hits" | "url";
|
|
57
|
+
}>;
|
|
58
|
+
protected createSuccessResponse(data: unknown): import("mcp-framework").ToolResponse | {
|
|
59
|
+
content: {
|
|
60
|
+
type: "text";
|
|
61
|
+
text: string;
|
|
62
|
+
}[];
|
|
63
|
+
structuredContent: {
|
|
64
|
+
result_type?: "hits";
|
|
65
|
+
totalFeatures?: number;
|
|
34
66
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
67
|
+
} | {
|
|
68
|
+
content: {
|
|
69
|
+
type: "text";
|
|
70
|
+
text: string;
|
|
71
|
+
}[];
|
|
72
|
+
structuredContent: {
|
|
73
|
+
url?: string;
|
|
74
|
+
result_type?: "url";
|
|
38
75
|
};
|
|
39
76
|
};
|
|
40
77
|
execute(input: GpfWfsGetFeaturesInput): Promise<any>;
|
|
@@ -1,41 +1,111 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MCPTool } from "mcp-framework";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { GPF_WFS_URL } from "../gpf/wfs.js";
|
|
4
4
|
import { fetchJSON } from "../helpers/http.js";
|
|
5
|
+
import logger from "../logger.js";
|
|
6
|
+
import { READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS } from "./toolAnnotations.js";
|
|
7
|
+
// This tool intentionally does not expose a single outputSchemaShape.
|
|
8
|
+
// - `result_type="results"` can return a large FeatureCollection, and we
|
|
9
|
+
// avoid duplicating that payload into structuredContent.
|
|
10
|
+
// - Compact modes (`hits`, `url`) are handled explicitly in createSuccessResponse().
|
|
11
|
+
const gpfWfsGetFeaturesInputSchema = z.object({
|
|
12
|
+
typename: z
|
|
13
|
+
.string()
|
|
14
|
+
.trim()
|
|
15
|
+
.min(1, "le nom du type ne doit pas être vide")
|
|
16
|
+
.describe("L'identifiant exact du type WFS à interroger (ex : `BDTOPO_V3:batiment`). Ce paramètre détermine la collection interrogée et doit correspondre à un type valide. Utiliser `gpf_wfs_search_types` pour trouver un `typename` pertinent, puis `gpf_wfs_describe_type` pour inspecter ses propriétés avant la requête."),
|
|
17
|
+
property_names: z
|
|
18
|
+
.string()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("La liste des propriétés à inclure dans chaque objet renvoyé, séparées par des virgules (ex : \"code_insee,nom_officiel,geometrie\"). Ce paramètre limite les champs présents dans la réponse, sans filtrer les objets eux-mêmes. Les noms doivent correspondre exactement aux propriétés du type WFS ; utiliser `gpf_wfs_describe_type` pour les connaître."),
|
|
21
|
+
sort_by: z
|
|
22
|
+
.string()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("Les propriétés à utiliser pour trier les objets renvoyés, avec la syntaxe `field [A|D]` où `A` signifie tri ascendant et `D` tri descendant. Plusieurs critères peuvent être séparés par des virgules (ex : `nom_officiel A, population D`). Les noms doivent correspondre exactement aux propriétés du type WFS ; utiliser `gpf_wfs_describe_type` pour les connaître."),
|
|
25
|
+
count: z
|
|
26
|
+
.number()
|
|
27
|
+
.int()
|
|
28
|
+
.min(1)
|
|
29
|
+
.max(1000)
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("Le nombre maximum d'objets à retourner dans la réponse (entre 1 et 1000). Ce paramètre limite les résultats renvoyés, sans modifier le nombre total d'objets correspondant à la requête. Il est surtout utile avec `result_type=\"results\"`."),
|
|
32
|
+
cql_filter: z
|
|
33
|
+
.string()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe([
|
|
36
|
+
"Un filtre `cql_filter` GeoServer pour restreindre les objets renvoyés par la requête.",
|
|
37
|
+
"Il faut utiliser les noms exacts des propriétés du type WFS ; utiliser `gpf_wfs_describe_type` pour les connaître.",
|
|
38
|
+
"Attention : en `EPSG:4326`, les coordonnées des géométries doivent être exprimées en `lat lon` (y x), y compris pour les points, lignes et polygones.",
|
|
39
|
+
"Exemples :",
|
|
40
|
+
"- filtre attributaire : `code_insee = '75056'`",
|
|
41
|
+
"- filtre spatial point : `DWITHIN(geom,Point(48.8566 2.3522),100,meters)`",
|
|
42
|
+
"- filtre spatial polygone : `INTERSECTS(geom,POLYGON((48.85 2.34,48.86 2.34,48.86 2.36,48.85 2.36,48.85 2.34)))`",
|
|
43
|
+
].join("\r\n")),
|
|
44
|
+
result_type: z
|
|
45
|
+
.enum(["results", "hits", "url"])
|
|
46
|
+
.optional()
|
|
47
|
+
.describe([
|
|
48
|
+
"Choisit le type de résultat renvoyé par le tool :",
|
|
49
|
+
"- `results` : retourne les objets trouvés sous forme de `FeatureCollection` GeoJSON complète (défaut)",
|
|
50
|
+
"- `hits` : retourne uniquement le nombre total d'objets correspondant à la requête",
|
|
51
|
+
"- `url` : retourne uniquement l'URL WFS construite pour la requête, utile pour inspection, débogage ou réutilisation côté client",
|
|
52
|
+
].join("\r\n"))
|
|
53
|
+
});
|
|
54
|
+
const gpfWfsGetFeaturesHitsOutputSchema = z.object({
|
|
55
|
+
result_type: z.literal("hits").describe("Indique que la réponse contient uniquement un comptage."),
|
|
56
|
+
totalFeatures: z.number().describe("Le nombre total d'objets correspondant à la requête."),
|
|
57
|
+
});
|
|
58
|
+
const gpfWfsGetFeaturesUrlOutputSchema = z.object({
|
|
59
|
+
result_type: z.literal("url").describe("Indique que la réponse contient uniquement l'URL de la requête."),
|
|
60
|
+
url: z.string().describe("L'URL WFS générée pour la requête."),
|
|
61
|
+
});
|
|
5
62
|
class GpfWfsGetFeaturesTool extends MCPTool {
|
|
6
63
|
name = "gpf_wfs_get_features";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
64
|
+
title = "Lecture d’objets WFS";
|
|
65
|
+
annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
|
|
66
|
+
description = [
|
|
67
|
+
"Récupère les objets d'un type WFS à partir d'un `typename` valide, avec filtres, tri et sélection de propriétés optionnels.",
|
|
68
|
+
"Exécute une requête WFS sur un type connu (`typename`) et renvoie soit les objets trouvés, soit leur nombre total, soit l'URL WFS correspondante.",
|
|
69
|
+
"Utiliser `gpf_wfs_search_types` puis `gpf_wfs_describe_type` avant ce tool lorsque le type ou ses propriétés ne sont pas connus.",
|
|
70
|
+
"Le paramètre `result_type` permet de récupérer soit les données complètes (`results`), soit uniquement le comptage (`hits`), soit l'URL WFS générée (`url`).",
|
|
71
|
+
"Les paramètres optionnels permettent de filtrer, trier ou restreindre les champs et le nombre d'objets renvoyés.",
|
|
72
|
+
].join("\r\n");
|
|
73
|
+
schema = gpfWfsGetFeaturesInputSchema;
|
|
74
|
+
createSuccessResponse(data) {
|
|
75
|
+
if (typeof data === "object" &&
|
|
76
|
+
data !== null &&
|
|
77
|
+
"result_type" in data &&
|
|
78
|
+
data.result_type === "hits" &&
|
|
79
|
+
"totalFeatures" in data &&
|
|
80
|
+
typeof data.totalFeatures === "number") {
|
|
81
|
+
return {
|
|
82
|
+
content: [
|
|
83
|
+
{
|
|
84
|
+
type: "text",
|
|
85
|
+
text: JSON.stringify(data.totalFeatures),
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
structuredContent: gpfWfsGetFeaturesHitsOutputSchema.parse(data),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (typeof data === "object" &&
|
|
92
|
+
data !== null &&
|
|
93
|
+
"result_type" in data &&
|
|
94
|
+
data.result_type === "url" &&
|
|
95
|
+
"url" in data &&
|
|
96
|
+
typeof data.url === "string") {
|
|
97
|
+
return {
|
|
98
|
+
content: [
|
|
99
|
+
{
|
|
100
|
+
type: "text",
|
|
101
|
+
text: data.url,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
structuredContent: gpfWfsGetFeaturesUrlOutputSchema.parse(data),
|
|
105
|
+
};
|
|
37
106
|
}
|
|
38
|
-
|
|
107
|
+
return super.createSuccessResponse(data);
|
|
108
|
+
}
|
|
39
109
|
async execute(input) {
|
|
40
110
|
const params = {
|
|
41
111
|
service: 'WFS',
|
|
@@ -48,7 +118,7 @@ class GpfWfsGetFeaturesTool extends MCPTool {
|
|
|
48
118
|
params.cql_filter = input.cql_filter;
|
|
49
119
|
}
|
|
50
120
|
if (input.count) {
|
|
51
|
-
params.count = input.count;
|
|
121
|
+
params.count = String(input.count);
|
|
52
122
|
}
|
|
53
123
|
if (input.sort_by) {
|
|
54
124
|
params.sortBy = input.sort_by;
|
|
@@ -57,32 +127,32 @@ class GpfWfsGetFeaturesTool extends MCPTool {
|
|
|
57
127
|
params.propertyName = input.property_names;
|
|
58
128
|
}
|
|
59
129
|
// Si result_type est 'hits', on utilise count=1 pour récupérer juste le totalFeatures
|
|
130
|
+
// On fait cela parce que Geoserver ne renvoie pas de json avec resultType=hits
|
|
131
|
+
// On est obligé de faire une requete getfeature pour récupérer le totalFeatures...
|
|
60
132
|
if (input.result_type === 'hits') {
|
|
61
|
-
params.count = 1;
|
|
133
|
+
params.count = "1";
|
|
62
134
|
// On n'a pas besoin des propriétés détaillées pour un comptage
|
|
63
135
|
delete params.propertyName;
|
|
64
136
|
}
|
|
65
137
|
const url = `${GPF_WFS_URL}?` + new URLSearchParams(params).toString();
|
|
66
138
|
logger.info(`[gpf_wfs_get_features] ${url}`);
|
|
67
139
|
if (input.result_type === 'url') {
|
|
68
|
-
return
|
|
140
|
+
return {
|
|
141
|
+
result_type: "url",
|
|
142
|
+
url,
|
|
143
|
+
};
|
|
69
144
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return featureCollection.totalFeatures;
|
|
145
|
+
const featureCollection = await fetchJSON(url);
|
|
146
|
+
if (input.result_type === 'hits') {
|
|
147
|
+
if (typeof featureCollection?.totalFeatures !== "number") {
|
|
148
|
+
throw new Error("Le service WFS n'a pas retourné de comptage exploitable");
|
|
75
149
|
}
|
|
76
|
-
return featureCollection;
|
|
77
|
-
}
|
|
78
|
-
catch (e) {
|
|
79
|
-
logger.error(`[gpf_wfs_get_features] ${e}`);
|
|
80
150
|
return {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
details: `${e}`
|
|
151
|
+
result_type: "hits",
|
|
152
|
+
totalFeatures: featureCollection.totalFeatures,
|
|
84
153
|
};
|
|
85
154
|
}
|
|
155
|
+
return featureCollection;
|
|
86
156
|
}
|
|
87
157
|
}
|
|
88
158
|
export default GpfWfsGetFeaturesTool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GpfWfsGetFeaturesTool.js","sourceRoot":"","sources":["../../src/tools/GpfWfsGetFeaturesTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"GpfWfsGetFeaturesTool.js","sourceRoot":"","sources":["../../src/tools/GpfWfsGetFeaturesTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,CAAC,E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F;QACnF,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;YACjC,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;YACnB,+DAA+D;YAC/D,OAAO,MAAM,CAAC,YAAY,CAAC;QAC7B,CAAC;QAGD,MAAM,GAAG,GAAG,GAAG,WAAW,GAAG,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QACvE,MAAM,CAAC,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAC;QAE7C,IAAK,KAAK,CAAC,WAAW,KAAK,KAAK,EAAG,CAAC;YAClC,OAAO;gBACL,WAAW,EAAE,KAAc;gBAC3B,GAAG;aACJ,CAAC;QACJ,CAAC;QAED,MAAM,iBAAiB,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;QAE/C,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;YACjC,IAAI,OAAO,iBAAiB,EAAE,aAAa,KAAK,QAAQ,EAAE,CAAC;gBACzD,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;YAC7E,CAAC;YACD,OAAO;gBACL,WAAW,EAAE,MAAe;gBAC5B,aAAa,EAAE,iBAAiB,CAAC,aAAa;aAC/C,CAAC;QACJ,CAAC;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { MCPTool } from "mcp-framework";
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
declare const gpfWfsListTypesInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
4
|
+
type GpfWfsListTypesInput = z.infer<typeof gpfWfsListTypesInputSchema>;
|
|
5
|
+
declare class GpfWfsListTypesTool extends MCPTool<GpfWfsListTypesInput> {
|
|
5
6
|
name: string;
|
|
7
|
+
title: string;
|
|
8
|
+
annotations: {
|
|
9
|
+
readonly readOnlyHint: true;
|
|
10
|
+
readonly destructiveHint: false;
|
|
11
|
+
readonly idempotentHint: true;
|
|
12
|
+
readonly openWorldHint: true;
|
|
13
|
+
};
|
|
6
14
|
description: string;
|
|
7
|
-
schema: {}
|
|
8
|
-
execute(input:
|
|
15
|
+
schema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
16
|
+
execute(input: GpfWfsListTypesInput): Promise<{
|
|
17
|
+
id: string;
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
}[]>;
|
|
9
21
|
}
|
|
10
|
-
export default
|
|
22
|
+
export default GpfWfsListTypesTool;
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { MCPTool } from "mcp-framework";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS } from "./toolAnnotations.js";
|
|
2
4
|
import { wfsClient } from "../gpf/wfs.js";
|
|
3
|
-
|
|
5
|
+
const gpfWfsListTypesInputSchema = z.object({});
|
|
6
|
+
class GpfWfsListTypesTool extends MCPTool {
|
|
4
7
|
name = "gpf_wfs_list_types";
|
|
8
|
+
title = "Liste complète des types WFS";
|
|
9
|
+
annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
|
|
5
10
|
description = [
|
|
6
|
-
"Renvoie la liste des types WFS de la Géoplateforme (GPF).
|
|
7
|
-
"
|
|
8
|
-
"
|
|
11
|
+
"Renvoie la liste complète des types WFS de la Géoplateforme (GPF).",
|
|
12
|
+
"Utiliser ce tool pour un inventaire exhaustif ou une exploration globale du catalogue.",
|
|
13
|
+
"Pour trouver rapidement un type pertinent à partir de mots-clés, utiliser de préférence gpf_wfs_search_types.",
|
|
9
14
|
].join("\r\n");
|
|
10
|
-
schema =
|
|
15
|
+
schema = gpfWfsListTypesInputSchema;
|
|
11
16
|
async execute(input) {
|
|
12
17
|
const featureTypes = await wfsClient.getFeatureTypes();
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
return featureTypes.map((featureType) => ({
|
|
19
|
+
id: featureType.id,
|
|
20
|
+
title: featureType.title,
|
|
21
|
+
description: featureType.description,
|
|
22
|
+
}));
|
|
15
23
|
}
|
|
16
24
|
}
|
|
17
|
-
export default
|
|
25
|
+
export default GpfWfsListTypesTool;
|
|
18
26
|
//# sourceMappingURL=GpfWfsListTypesTool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GpfWfsListTypesTool.js","sourceRoot":"","sources":["../../src/tools/GpfWfsListTypesTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"GpfWfsListTypesTool.js","sourceRoot":"","sources":["../../src/tools/GpfWfsListTypesTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qCAAqC,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAIhD,MAAM,mBAAoB,SAAQ,OAA6B;IAC7D,IAAI,GAAG,oBAAoB,CAAC;IAC5B,KAAK,GAAG,8BAA8B,CAAC;IACvC,WAAW,GAAG,qCAAqC,CAAC;IACpD,WAAW,GAAG;QACZ,oEAAoE;QACpE,wFAAwF;QACxF,+GAA+G;KAChH,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACf,MAAM,GAAG,0BAA0B,CAAC;IAEpC,KAAK,CAAC,OAAO,CAAC,KAA2B;QACvC,MAAM,YAAY,GAAG,MAAM,SAAS,CAAC,eAAe,EAAE,CAAC;QACvD,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YACxC,EAAE,EAAE,WAAW,CAAC,EAAE;YAClB,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,WAAW,EAAE,WAAW,CAAC,WAAW;SACrC,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,22 +1,69 @@
|
|
|
1
1
|
import { MCPTool } from "mcp-framework";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
query:
|
|
5
|
-
max_results:
|
|
6
|
-
}
|
|
3
|
+
declare const gpfWfsSearchTypesInputSchema: z.ZodObject<{
|
|
4
|
+
query: z.ZodString;
|
|
5
|
+
max_results: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
query?: string;
|
|
8
|
+
max_results?: number;
|
|
9
|
+
}, {
|
|
10
|
+
query?: string;
|
|
11
|
+
max_results?: number;
|
|
12
|
+
}>;
|
|
13
|
+
type GpfWfsSearchTypesInput = z.infer<typeof gpfWfsSearchTypesInputSchema>;
|
|
7
14
|
declare class GpfWfsSearchTypesTool extends MCPTool<GpfWfsSearchTypesInput> {
|
|
8
15
|
name: string;
|
|
16
|
+
title: string;
|
|
17
|
+
annotations: {
|
|
18
|
+
readonly readOnlyHint: true;
|
|
19
|
+
readonly destructiveHint: false;
|
|
20
|
+
readonly idempotentHint: true;
|
|
21
|
+
readonly openWorldHint: true;
|
|
22
|
+
};
|
|
9
23
|
description: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
24
|
+
protected outputSchemaShape: z.ZodObject<{
|
|
25
|
+
results: z.ZodArray<z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
title: z.ZodString;
|
|
28
|
+
description: z.ZodString;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
id?: string;
|
|
31
|
+
title?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
}, {
|
|
34
|
+
id?: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
}>, "many">;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
results?: {
|
|
40
|
+
id?: string;
|
|
41
|
+
title?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
}[];
|
|
44
|
+
}, {
|
|
45
|
+
results?: {
|
|
46
|
+
id?: string;
|
|
47
|
+
title?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
}[];
|
|
50
|
+
}>;
|
|
51
|
+
schema: z.ZodObject<{
|
|
52
|
+
query: z.ZodString;
|
|
53
|
+
max_results: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
query?: string;
|
|
56
|
+
max_results?: number;
|
|
57
|
+
}, {
|
|
58
|
+
query?: string;
|
|
59
|
+
max_results?: number;
|
|
60
|
+
}>;
|
|
61
|
+
execute(input: GpfWfsSearchTypesInput): Promise<{
|
|
62
|
+
results: {
|
|
63
|
+
id: string;
|
|
64
|
+
title: string;
|
|
13
65
|
description: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type: z.ZodOptional<z.ZodNumber>;
|
|
17
|
-
description: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
execute(input: GpfWfsSearchTypesInput): Promise<string[]>;
|
|
66
|
+
}[];
|
|
67
|
+
}>;
|
|
21
68
|
}
|
|
22
69
|
export default GpfWfsSearchTypesTool;
|
|
@@ -1,30 +1,51 @@
|
|
|
1
1
|
import { MCPTool } from "mcp-framework";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS } from "./toolAnnotations.js";
|
|
3
4
|
import { wfsClient } from "../gpf/wfs.js";
|
|
5
|
+
const gpfWfsSearchTypesInputSchema = z.object({
|
|
6
|
+
query: z
|
|
7
|
+
.string()
|
|
8
|
+
.trim()
|
|
9
|
+
.min(1, "la requête de recherche ne doit pas être vide")
|
|
10
|
+
.describe("La requête de recherche"),
|
|
11
|
+
max_results: z
|
|
12
|
+
.number()
|
|
13
|
+
.int()
|
|
14
|
+
.min(1)
|
|
15
|
+
.max(50)
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Le nombre maximum de résultats à retourner (entre 1 et 50). Défaut : 10."),
|
|
18
|
+
});
|
|
19
|
+
const gpfWfsSearchTypeResultSchema = z.object({
|
|
20
|
+
id: z.string().describe("L'identifiant complet du type WFS."),
|
|
21
|
+
title: z.string().describe("Le titre lisible du type WFS."),
|
|
22
|
+
description: z.string().describe("La description du type WFS."),
|
|
23
|
+
});
|
|
24
|
+
const gpfWfsSearchTypesOutputSchema = z.object({
|
|
25
|
+
results: z.array(gpfWfsSearchTypeResultSchema).describe("La liste ordonnée des types WFS trouvés."),
|
|
26
|
+
});
|
|
4
27
|
class GpfWfsSearchTypesTool extends MCPTool {
|
|
5
28
|
name = "gpf_wfs_search_types";
|
|
29
|
+
title = "Recherche de types WFS";
|
|
30
|
+
annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
|
|
6
31
|
description = [
|
|
7
|
-
"Recherche
|
|
8
|
-
"
|
|
9
|
-
"-
|
|
10
|
-
"
|
|
11
|
-
"- Le paramètre max_results permet de changer le nombre de résultats (par exemple pour trouver toutes les tables BDTOPO ou toutes les tables communes)",
|
|
32
|
+
"Recherche des types WFS de la Géoplateforme (GPF) à partir de mots-clés afin de trouver un identifiant de type (`typename`) valide.",
|
|
33
|
+
"Utiliser ce tool avant `gpf_wfs_describe_type` ou `gpf_wfs_get_features` lorsque le nom exact du type n'est pas connu.",
|
|
34
|
+
"La recherche est textuelle (mini-search) et retourne une liste ordonnée de candidats avec leur identifiant, leur titre et leur description.",
|
|
35
|
+
"Le paramètre `max_results` permet d'élargir le nombre de candidats retournés (10 par défaut).",
|
|
12
36
|
].join("\r\n");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type: z.string(),
|
|
16
|
-
description: "La requête de recherche",
|
|
17
|
-
},
|
|
18
|
-
max_results: {
|
|
19
|
-
type: z.number().optional(),
|
|
20
|
-
description: "Le nombre de résultats (10 par défaut)",
|
|
21
|
-
},
|
|
22
|
-
};
|
|
37
|
+
outputSchemaShape = gpfWfsSearchTypesOutputSchema;
|
|
38
|
+
schema = gpfWfsSearchTypesInputSchema;
|
|
23
39
|
async execute(input) {
|
|
24
40
|
const maxResults = input.max_results || 10;
|
|
25
41
|
const featureTypes = await wfsClient.searchFeatureTypes(input.query, maxResults);
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
return {
|
|
43
|
+
results: featureTypes.map((featureType) => ({
|
|
44
|
+
id: featureType.id,
|
|
45
|
+
title: featureType.title,
|
|
46
|
+
description: featureType.description,
|
|
47
|
+
})),
|
|
48
|
+
};
|
|
28
49
|
}
|
|
29
50
|
}
|
|
30
51
|
export default GpfWfsSearchTypesTool;
|