geocode
Convert location names to geographic coordinates using France's Géoplateforme autocompletion service for spatial data integration.
Instructions
Renvoie les coordonnées (lon,lat) d'un lieu en complétant les informations (source : Géoplateforme (service d'autocomplétion)).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Le texte devant être completé et géocodé |
Implementation Reference
- src/tools/GeocodeTool.ts:22-25 (handler)The execute method implementing the core logic of the 'geocode' tool by calling the geocode helper function with the input text.async execute(input: GeocodeInput) { logger.info(`geocode(${input.text})...`); return geocode(input.text); }
- src/tools/GeocodeTool.ts:7-20 (schema)Input schema definition including TypeScript interface GeocodeInput and Zod validation schema for the 'text' parameter.interface GeocodeInput { text: string; } class GeocodeTool extends MCPTool<GeocodeInput> { name = "geocode"; description = `Renvoie les coordonnées (lon,lat) d'un lieu en complétant les informations (source : ${GEOCODE_SOURCE}).`; schema = { text: { type: z.string(), description: "Le texte devant être completé et géocodé", }, };
- src/tools/GeocodeTool.ts:11-28 (registration)The GeocodeTool class registration, extending MCPTool, setting name to 'geocode', description, schema, and execute handler.class GeocodeTool extends MCPTool<GeocodeInput> { name = "geocode"; description = `Renvoie les coordonnées (lon,lat) d'un lieu en complétant les informations (source : ${GEOCODE_SOURCE}).`; schema = { text: { type: z.string(), description: "Le texte devant être completé et géocodé", }, }; async execute(input: GeocodeInput) { logger.info(`geocode(${input.text})...`); return geocode(input.text); } } export default GeocodeTool;
- src/gpf/geocode.js:14-28 (helper)Helper function geocode that performs the actual geocoding by querying the Géoplateforme API and transforming results to lon/lat/fulltext format.export async function geocode(text) { logger.info(`geocode(${JSON.stringify(text)})...`); const url = 'https://data.geopf.fr/geocodage/completion/?' + new URLSearchParams({ text: text, maximumResponses: 3 }).toString(); const json = await fetchJSON(url); return json.results.map((item)=>{return { lon: item.x, lat: item.y, fulltext: item.fulltext }}); }
- src/gpf/geocode.js:4-4 (helper)Constant GEOCODE_SOURCE used in the tool description to credit the data source.export const GEOCODE_SOURCE = "Géoplateforme (service d'autocomplétion)";