@ignfab/geocontext 0.9.3 → 0.9.6

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.
Files changed (78) hide show
  1. package/README.md +62 -31
  2. package/dist/gpf/adminexpress.js +7 -27
  3. package/dist/gpf/adminexpress.js.map +1 -1
  4. package/dist/gpf/parcellaire-express.js +13 -33
  5. package/dist/gpf/parcellaire-express.js.map +1 -1
  6. package/dist/gpf/urbanisme.d.ts +4 -2
  7. package/dist/gpf/urbanisme.js +20 -61
  8. package/dist/gpf/urbanisme.js.map +1 -1
  9. package/dist/gpf/wfs.d.ts +2 -2
  10. package/dist/gpf/wfs.js +17 -71
  11. package/dist/gpf/wfs.js.map +1 -1
  12. package/dist/helpers/distance.d.ts +4 -2
  13. package/dist/helpers/distance.js +20 -5
  14. package/dist/helpers/distance.js.map +1 -1
  15. package/dist/helpers/http.d.ts +4 -0
  16. package/dist/helpers/http.js +103 -1
  17. package/dist/helpers/http.js.map +1 -1
  18. package/dist/helpers/jsonSchema.d.ts +9 -0
  19. package/dist/helpers/jsonSchema.js +14 -0
  20. package/dist/helpers/jsonSchema.js.map +1 -0
  21. package/dist/helpers/schemas.d.ts +13 -0
  22. package/dist/helpers/schemas.js +18 -0
  23. package/dist/helpers/schemas.js.map +1 -0
  24. package/dist/helpers/wfs.d.ts +27 -0
  25. package/dist/helpers/wfs.js +55 -0
  26. package/dist/helpers/wfs.js.map +1 -0
  27. package/dist/helpers/wfs_internal/compile.d.ts +55 -0
  28. package/dist/helpers/wfs_internal/compile.js +596 -0
  29. package/dist/helpers/wfs_internal/compile.js.map +1 -0
  30. package/dist/helpers/wfs_internal/request.d.ts +47 -0
  31. package/dist/helpers/wfs_internal/request.js +121 -0
  32. package/dist/helpers/wfs_internal/request.js.map +1 -0
  33. package/dist/helpers/wfs_internal/response.d.ts +29 -0
  34. package/dist/helpers/wfs_internal/response.js +59 -0
  35. package/dist/helpers/wfs_internal/response.js.map +1 -0
  36. package/dist/helpers/wfs_internal/schema.d.ts +167 -0
  37. package/dist/helpers/wfs_internal/schema.js +81 -0
  38. package/dist/helpers/wfs_internal/schema.js.map +1 -0
  39. package/dist/index.js +47 -25
  40. package/dist/index.js.map +1 -1
  41. package/dist/tools/AdminexpressTool.d.ts +52 -2
  42. package/dist/tools/AdminexpressTool.js +12 -14
  43. package/dist/tools/AdminexpressTool.js.map +1 -1
  44. package/dist/tools/AltitudeTool.d.ts +2 -2
  45. package/dist/tools/AltitudeTool.js +4 -13
  46. package/dist/tools/AltitudeTool.js.map +1 -1
  47. package/dist/tools/AssietteSupTool.d.ts +55 -3
  48. package/dist/tools/AssietteSupTool.js +13 -15
  49. package/dist/tools/AssietteSupTool.js.map +1 -1
  50. package/dist/tools/CadastreTool.d.ts +52 -2
  51. package/dist/tools/CadastreTool.js +14 -15
  52. package/dist/tools/CadastreTool.js.map +1 -1
  53. package/dist/tools/GeocodeTool.d.ts +2 -2
  54. package/dist/tools/GeocodeTool.js +6 -4
  55. package/dist/tools/GeocodeTool.js.map +1 -1
  56. package/dist/tools/GpfWfsDescribeTypeTool.d.ts +16 -16
  57. package/dist/tools/GpfWfsDescribeTypeTool.js +4 -3
  58. package/dist/tools/GpfWfsDescribeTypeTool.js.map +1 -1
  59. package/dist/tools/GpfWfsGetFeatureByIdTool.d.ts +110 -0
  60. package/dist/tools/GpfWfsGetFeatureByIdTool.js +156 -0
  61. package/dist/tools/GpfWfsGetFeatureByIdTool.js.map +1 -0
  62. package/dist/tools/GpfWfsGetFeaturesTool.d.ts +161 -44
  63. package/dist/tools/GpfWfsGetFeaturesTool.js +139 -114
  64. package/dist/tools/GpfWfsGetFeaturesTool.js.map +1 -1
  65. package/dist/tools/GpfWfsSearchTypesTool.d.ts +8 -2
  66. package/dist/tools/GpfWfsSearchTypesTool.js +12 -9
  67. package/dist/tools/GpfWfsSearchTypesTool.js.map +1 -1
  68. package/dist/tools/UrbanismeTool.d.ts +53 -3
  69. package/dist/tools/UrbanismeTool.js +10 -15
  70. package/dist/tools/UrbanismeTool.js.map +1 -1
  71. package/package.json +8 -7
  72. package/dist/resources/WfsCqlFilterResource.d.ts +0 -10
  73. package/dist/resources/WfsCqlFilterResource.js +0 -23
  74. package/dist/resources/WfsCqlFilterResource.js.map +0 -1
  75. package/dist/resources/content/wfs-cql-filter.md +0 -215
  76. package/dist/tools/GpfWfsListTypesTool.d.ts +0 -22
  77. package/dist/tools/GpfWfsListTypesTool.js +0 -26
  78. package/dist/tools/GpfWfsListTypesTool.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ignfab/geocontext",
3
- "version": "0.9.3",
3
+ "version": "0.9.6",
4
4
  "description": "An experimental MCP server providing access to the services and data of the french Geoplateform",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,9 +27,8 @@
27
27
  },
28
28
  "homepage": "https://github.com/ignfab/geocontext#readme",
29
29
  "scripts": {
30
- "clean:dist": "rm -rf dist",
31
- "copy:resources": "mkdir -p dist/resources/content && cp -R src/resources/content/. dist/resources/content/",
32
- "build": "npm run clean:dist && tsc && npx mcp-build && npm run copy:resources",
30
+ "clean:dist": "node scripts/dist-clean.js",
31
+ "build": "npm run clean:dist && tsc && npx mcp-build",
33
32
  "watch": "tsc --watch",
34
33
  "start": "node dist/index.js",
35
34
  "test": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js",
@@ -38,12 +37,14 @@
38
37
  "fresh": "npm run reset && npm cache verify && npm install && npm run build && npm test"
39
38
  },
40
39
  "dependencies": {
41
- "@camptocamp/ogc-client": "^1.3.0",
42
- "@ignfab/gpf-schema-store": "^0.1.1",
40
+ "@ignfab/gpf-schema-store": "^0.1.5",
41
+ "@rgrove/parse-xml": "^4.2.0",
42
+ "@turf/distance": "^7.3.4",
43
+ "@turf/helpers": "^7.3.4",
43
44
  "https-proxy-agent": "^7.0.6",
44
45
  "jsts": "^2.12.1",
45
46
  "lodash": "^4.17.21",
46
- "mcp-framework": "^0.2.21",
47
+ "mcp-framework": "^0.2.22",
47
48
  "node-fetch": "^3.3.2",
48
49
  "winston": "^3.18.3",
49
50
  "zod": "^3.25.76"
@@ -1,10 +0,0 @@
1
- import { MCPResource, ResourceContent } from "mcp-framework";
2
- declare class WfsCqlFilterResource extends MCPResource {
3
- uri: string;
4
- name: string;
5
- description: string;
6
- mimeType: string;
7
- protected title: string;
8
- read(): Promise<ResourceContent[]>;
9
- }
10
- export default WfsCqlFilterResource;
@@ -1,23 +0,0 @@
1
- import { MCPResource } from "mcp-framework";
2
- import { readFile } from "fs/promises";
3
- import { dirname, join } from "path";
4
- import { fileURLToPath } from "url";
5
- class WfsCqlFilterResource extends MCPResource {
6
- uri = "geocontext://wfs-cql-filter";
7
- name = "geocontext-wfs-cql-filter";
8
- description = "Aide-mémoire pour construire des cql_filter GeoServer utilisables avec les tools WFS.";
9
- mimeType = "text/markdown";
10
- title = "Cheatsheet cql_filter";
11
- async read() {
12
- const text = await readFile(join(dirname(fileURLToPath(import.meta.url)), "content", "wfs-cql-filter.md"), "utf-8");
13
- return [
14
- {
15
- uri: this.uri,
16
- mimeType: this.mimeType,
17
- text,
18
- },
19
- ];
20
- }
21
- }
22
- export default WfsCqlFilterResource;
23
- //# sourceMappingURL=WfsCqlFilterResource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WfsCqlFilterResource.js","sourceRoot":"","sources":["../../src/resources/WfsCqlFilterResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,oBAAqB,SAAQ,WAAW;IAC5C,GAAG,GAAG,6BAA6B,CAAC;IACpC,IAAI,GAAG,2BAA2B,CAAC;IACnC,WAAW,GAAG,uFAAuF,CAAC;IACtG,QAAQ,GAAG,eAAe,CAAC;IACjB,KAAK,GAAG,uBAAuB,CAAC;IAE1C,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,GAAG,MAAM,QAAQ,CACzB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,mBAAmB,CAAC,EAC7E,OAAO,CACR,CAAC;QAEF,OAAO;YACL;gBACE,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,IAAI;aACL;SACF,CAAC;IACJ,CAAC;CACF;AAED,eAAe,oBAAoB,CAAC"}
@@ -1,215 +0,0 @@
1
- # cql_filter GeoServer
2
-
3
- Utiliser `cql_filter` avec `gpf_wfs_get_features` pour restreindre les objets renvoyés.
4
-
5
- ## Checklist
6
-
7
- Avant d'écrire un `cql_filter` :
8
-
9
- 1. Appeler `gpf_wfs_describe_type`.
10
- 2. Identifier le champ géométrique.
11
- 3. Lire son `defaultCrs`.
12
- 4. Si `defaultCrs = EPSG:4326`, écrire les coordonnées en `lat lon`.
13
- 5. Si `defaultCrs = EPSG:2154`, écrire les coordonnées en `x y`.
14
- 6. Fournir `cql_filter` en texte brut, sans URL encoding manuel.
15
- 7. Utiliser `cql_filter` pour choisir quels objets sont renvoyés, et `property_names` pour choisir quelles propriétés de ces objets sont renvoyées.
16
-
17
- ## Champ géométrique
18
-
19
- Règles pratiques :
20
-
21
- - Un type WFS expose en pratique au plus un seul champ géométrique.
22
- - Le repère le plus fiable est la présence de `defaultCrs`.
23
- - Utiliser le nom exact du champ renvoyé par `gpf_wfs_describe_type`, par exemple `geom`, `geometrie` ou `the_geom`.
24
- - Le `type` du champ géométrique peut être `geometry`, `point`, `linestring`, `polygon`, `multipolygon`, etc.
25
-
26
- Exemple :
27
-
28
- ```json
29
- {
30
- "name": "geom",
31
- "type": "multipolygon",
32
- "defaultCrs": "EPSG:4326"
33
- }
34
- ```
35
-
36
- ## Ordre des coordonnées
37
-
38
- ### `EPSG:4326`
39
-
40
- Utiliser `lat lon`.
41
-
42
- Exemples :
43
-
44
- - `POINT(48.8566 2.3522)`
45
- - `POLYGON((48.85 2.34,48.86 2.34,48.86 2.36,48.85 2.36,48.85 2.34))`
46
-
47
- ### `EPSG:2154`
48
-
49
- Utiliser `x y`, c'est-à-dire `easting northing`.
50
-
51
- Exemples :
52
-
53
- - `POINT(700000 6600000)`
54
- - `POLYGON((700000 6600000,700500 6600000,700500 6600500,700000 6600500,700000 6600000))`
55
-
56
- ## URL encoding
57
-
58
- Ne pas encoder manuellement `cql_filter`.
59
-
60
- Le tool `gpf_wfs_get_features` encode déjà les paramètres d'URL avec `URLSearchParams`.
61
-
62
- Conséquences :
63
-
64
- - écrire `cql_filter` sous forme lisible
65
- - ne pas remplacer les espaces par `%20`
66
- - ne pas encoder `(`, `)`, `,`, `'`
67
- - si `result_type = "url"`, l'URL renvoyée sera déjà encodée
68
-
69
- Correct :
70
-
71
- ```text
72
- INTERSECTS(geom,POINT(48.8566 2.3522))
73
- ```
74
-
75
- À éviter :
76
-
77
- ```text
78
- INTERSECTS%28geom%2CPOINT%2848.8566%202.3522%29%29
79
- ```
80
-
81
- ## Templates
82
-
83
- ### Égalité
84
-
85
- ```text
86
- code_insee = '75056'
87
- ```
88
-
89
- ### Comparaison numérique
90
-
91
- ```text
92
- population > 100000
93
- ```
94
-
95
- ### Liste de valeurs
96
-
97
- ```text
98
- nature IN ('route', 'chemin', 'sentier')
99
- ```
100
-
101
- ### Intervalle
102
-
103
- ```text
104
- surface BETWEEN 1000 AND 5000
105
- ```
106
-
107
- ### LIKE
108
-
109
- ```text
110
- nom LIKE 'Saint-%'
111
- ```
112
-
113
- ### INTERSECTS avec point en `EPSG:4326`
114
-
115
- ```text
116
- INTERSECTS(geom,POINT(48.8566 2.3522))
117
- ```
118
-
119
- ### INTERSECTS avec point en `EPSG:2154`
120
-
121
- ```text
122
- INTERSECTS(geom,POINT(700000 6600000))
123
- ```
124
-
125
- ### BBOX recommandé en `EPSG:4326`
126
-
127
- ```text
128
- BBOX(geom, 48.80, 2.20, 48.90, 2.45)
129
- ```
130
-
131
- ### BBOX recommandé en `EPSG:2154`
132
-
133
- ```text
134
- BBOX(geom, 699000, 6599000, 701000, 6601000)
135
- ```
136
-
137
- ### POLYGON en `EPSG:4326`
138
-
139
- ```text
140
- INTERSECTS(geom,POLYGON((48.85 2.34,48.86 2.34,48.86 2.36,48.85 2.36,48.85 2.34)))
141
- ```
142
-
143
- ### POLYGON en `EPSG:2154`
144
-
145
- ```text
146
- INTERSECTS(geom,POLYGON((700000 6600000,700500 6600000,700500 6600500,700000 6600500,700000 6600000)))
147
- ```
148
-
149
- ### Distance
150
-
151
- ```text
152
- DWITHIN(geom,POINT(48.8566 2.3522),100,meters)
153
- ```
154
-
155
- ### Attributaire + spatial
156
-
157
- ```text
158
- type = 'hopital' AND BBOX(geom, 48.80, 2.20, 48.90, 2.45)
159
- ```
160
-
161
- ## Filtres attributaires
162
-
163
- Exemples fréquents :
164
-
165
- - `statut = 'actif'`
166
- - `population >= 100000`
167
- - `surface < 5000`
168
- - `etat <> 'supprime'`
169
- - `code_insee IN ('75056', '69123', '31555')`
170
- - `population BETWEEN 100000 AND 500000`
171
- - `nom LIKE '%Paris%'`
172
- - `nature = 'route' AND importance >= 3`
173
-
174
- ## Filtres spatiaux
175
-
176
- Bon premier choix pour un LLM :
177
-
178
- - préférer `BBOX(...)` quand un rectangle suffit
179
- - utiliser `INTERSECTS(...)` pour un point ou un polygone explicite
180
- - utiliser `DWITHIN(...)` pour une recherche par distance
181
-
182
- Exemples :
183
-
184
- - `BBOX(geom, 48.80, 2.20, 48.90, 2.45)`
185
- - `INTERSECTS(geom,POINT(48.8566 2.3522))`
186
- - `INTERSECTS(geom,POLYGON((48.85 2.34,48.86 2.34,48.86 2.36,48.85 2.36,48.85 2.34)))`
187
- - `DWITHIN(geom,POINT(48.8566 2.3522),100,meters)`
188
-
189
- ## Erreurs à éviter
190
-
191
- - Inventer un nom de propriété.
192
- - Oublier d'appeler `gpf_wfs_describe_type`.
193
- - Confondre `lat lon` et `lon lat` en `EPSG:4326`.
194
- - Utiliser `x y` sur un type en `EPSG:4326`.
195
- - Pré-encoder `cql_filter`.
196
- - Utiliser `cql_filter` pour limiter les champs au lieu de `property_names`.
197
- - Construire un `POLYGON` non fermé.
198
-
199
- ## Bonnes pratiques pour un LLM
200
-
201
- - Commencer par un filtre simple.
202
- - Préférer `BBOX(...)` si la zone de recherche est rectangulaire.
203
- - Vérifier systématiquement `defaultCrs` avant toute géométrie.
204
- - Utiliser des apostrophes pour les chaînes.
205
- - Garder le filtre lisible et minimal.
206
- - Ajouter ensuite les conditions supplémentaires si nécessaire.
207
-
208
- ## Procédure recommandée
209
-
210
- 1. Trouver le type avec `gpf_wfs_search_types`.
211
- 2. Lire les propriétés avec `gpf_wfs_describe_type`.
212
- 3. Identifier le champ géométrique via `defaultCrs`.
213
- 4. Choisir l'ordre des coordonnées selon le CRS.
214
- 5. Écrire un premier filtre simple.
215
- 6. Ajouter ensuite les contraintes attributaires ou spatiales.
@@ -1,22 +0,0 @@
1
- import { MCPTool } from "mcp-framework";
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> {
6
- name: string;
7
- title: string;
8
- annotations: {
9
- readOnlyHint: boolean;
10
- destructiveHint: boolean;
11
- idempotentHint: boolean;
12
- openWorldHint: boolean;
13
- };
14
- description: string;
15
- schema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
16
- execute(input: GpfWfsListTypesInput): Promise<{
17
- id: string;
18
- title: string;
19
- description: string;
20
- }[]>;
21
- }
22
- export default GpfWfsListTypesTool;
@@ -1,26 +0,0 @@
1
- import { MCPTool } from "mcp-framework";
2
- import { z } from "zod";
3
- import { READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS } from "../helpers/toolAnnotations.js";
4
- import { wfsClient } from "../gpf/wfs.js";
5
- const gpfWfsListTypesInputSchema = z.object({});
6
- class GpfWfsListTypesTool extends MCPTool {
7
- name = "gpf_wfs_list_types";
8
- title = "Liste complète des types WFS";
9
- annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
10
- description = [
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.",
14
- ].join("\r\n");
15
- schema = gpfWfsListTypesInputSchema;
16
- async execute(input) {
17
- const featureTypes = await wfsClient.getFeatureTypes();
18
- return featureTypes.map((featureType) => ({
19
- id: featureType.id,
20
- title: featureType.title,
21
- description: featureType.description,
22
- }));
23
- }
24
- }
25
- export default GpfWfsListTypesTool;
26
- //# sourceMappingURL=GpfWfsListTypesTool.js.map
@@ -1 +0,0 @@
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,+BAA+B,CAAC;AACtF,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"}