Skip to main content
Glama

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
NameRequiredDescriptionDefault
textYesLe texte devant être completé et géocodé

Implementation Reference

  • 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); }
  • 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é", }, };
  • 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;
  • 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 }}); }
  • Constant GEOCODE_SOURCE used in the tool description to credit the data source.
    export const GEOCODE_SOURCE = "Géoplateforme (service d'autocomplétion)";

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ignfab/geocontext'

If you have feedback or need assistance with the MCP directory API, please join our Discord server