ign_wfs_geoportail
Query French geographic WFS layers by intersecting with a geometry to retrieve spatial data like communes, buildings, or administrative boundaries in GeoJSON format.
Instructions
Generic query interface for Geoportail WFS layers.
This tool provides access to various WFS layers from the IGN Geoportail. It allows querying any WFS layer by intersection with a geometry.
Args:
source (string): WFS data source name (e.g., "BDTOPO_V3:commune", "LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune")
geom (string): GeoJSON geometry to intersect (required, in WGS84/EPSG:4326)
_limit (number): Max results (1-1000)
_start (number): Pagination offset
Returns: GeoJSON FeatureCollection with features from the requested layer.
Note: Only WGS84 (EPSG:4326) geometries are supported.
Examples:
"Get BDTOPO communes at this point" -> source="BDTOPO_V3:commune", geom={"type":"Point","coordinates":[2.35,48.85]}
"Find buildings in this area" -> source="BDTOPO_V3:batiment", geom=...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | WFS data source name (e.g., 'BDTOPO_V3:commune') | |
| geom | Yes | GeoJSON geometry (required, in WGS84/EPSG:4326) | |
| _limit | No | Maximum number of results (1-1000) | |
| _start | No | Starting position for pagination | |
| response_format | No | Output format: 'markdown' for human-readable or 'json' for machine-readable | markdown |
Implementation Reference
- src/index.ts:616-639 (handler)Handler function that processes input parameters, queries the external WFS Geoportail API endpoint via apiRequest, and returns formatted GeoJSON response as JSON or Markdown.async (params) => { const { source, response_format, ...queryParams } = params; const data = await apiRequest<unknown>("/wfs-geoportail/search", { params: { source, ...queryParams } as Record<string, string | number | boolean | undefined>, }); if (response_format === ResponseFormat.JSON) { return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } const markdown = formatGeoJSONToMarkdown( data as import("./types.js").GeoJSONFeatureCollection, `WFS Geoportail - ${source}` ); return { content: [{ type: "text", text: truncateResponse(markdown, CHARACTER_LIMIT) }], }; }
- src/index.ts:603-608 (schema)Zod input schema defining parameters: source (WFS layer), geom (GeoJSON), pagination (_limit, _start), and response_format.inputSchema: z.object({ source: z.string().describe("WFS data source name (e.g., 'BDTOPO_V3:commune')"), geom: GeometrySchema.describe("GeoJSON geometry (required, in WGS84/EPSG:4326)"), ...PaginationSchema, response_format: ResponseFormatSchema, }).strict(),
- src/index.ts:581-640 (registration)Registers the 'ign_wfs_geoportail' MCP tool with metadata, schema, and inline handler function.server.registerTool( "ign_wfs_geoportail", { title: "Query WFS Geoportail layers", description: `Generic query interface for Geoportail WFS layers. This tool provides access to various WFS layers from the IGN Geoportail. It allows querying any WFS layer by intersection with a geometry. Args: - source (string): WFS data source name (e.g., "BDTOPO_V3:commune", "LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune") - geom (string): GeoJSON geometry to intersect (required, in WGS84/EPSG:4326) - _limit (number): Max results (1-1000) - _start (number): Pagination offset Returns: GeoJSON FeatureCollection with features from the requested layer. Note: Only WGS84 (EPSG:4326) geometries are supported. Examples: - "Get BDTOPO communes at this point" -> source="BDTOPO_V3:commune", geom={"type":"Point","coordinates":[2.35,48.85]} - "Find buildings in this area" -> source="BDTOPO_V3:batiment", geom=...`, inputSchema: z.object({ source: z.string().describe("WFS data source name (e.g., 'BDTOPO_V3:commune')"), geom: GeometrySchema.describe("GeoJSON geometry (required, in WGS84/EPSG:4326)"), ...PaginationSchema, response_format: ResponseFormatSchema, }).strict(), annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, }, async (params) => { const { source, response_format, ...queryParams } = params; const data = await apiRequest<unknown>("/wfs-geoportail/search", { params: { source, ...queryParams } as Record<string, string | number | boolean | undefined>, }); if (response_format === ResponseFormat.JSON) { return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } const markdown = formatGeoJSONToMarkdown( data as import("./types.js").GeoJSONFeatureCollection, `WFS Geoportail - ${source}` ); return { content: [{ type: "text", text: truncateResponse(markdown, CHARACTER_LIMIT) }], }; } );