Skip to main content
Glama

geolocation-from-address

Convert Zaragoza addresses into precise latitude and longitude coordinates to locate bus stops, tram stations, and Bizi stations.

Instructions

Get the geolocation (latitude and longitude) from an address and the formatted address that was found, only for Zaragoza. Can be used to find a bus stops, tram stations or bizi stations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes

Implementation Reference

  • Handler function that uses Google Maps Geocoding API to convert an address (appended with 'Zaragoza, Spain') to latitude, longitude, confidence, and formatted address. Requires GOOGLE_MAPS_API_KEY env var. Returns JSON string of location or error message.
    async ({ address }) => { const GOOGLE_MAPS_API_KEY = process.env.GOOGLE_MAPS_API_KEY; if (!GOOGLE_MAPS_API_KEY) { return { content: [ { type: "text", text: "You should configure the GOOGLE_MAPS_API_KEY for MCP DNDzgz", }, ], }; } const encodedAddress = encodeURIComponent(`${address}, Zaragoza, Spain`); const url = `https://maps.googleapis.com/maps/api/geocode/json?address=${encodedAddress}&key=${GOOGLE_MAPS_API_KEY}`; const response = await fetch(url); if (response.ok) { const data = await response.json(); if (data.status === "OK" && data.results.length > 0) { const location = data.results[0].geometry.location; location.confindence = data.results[0].geometry.location_type; location.formatted_address = data.results[0].formatted_address; return { content: [{ type: "text", text: JSON.stringify(location) }], }; } else { return { content: [ { type: "text", text: `No geolocation found for the address: ${address}`, }, ], }; } } else { return { content: [ { type: "text", text: `Failed to fetch geolocation for the address: ${address}`, }, ], }; } }
  • Input schema defined with Zod: requires a single 'address' parameter as string.
    { address: z.string(), },
  • index.js:200-253 (registration)
    Registration of the 'geolocation-from-address' tool using server.tool(), including name, description, input schema, and inline handler function.
    server.tool( "geolocation-from-address", "Get the geolocation (latitude and longitude) from an address and the formatted address that was found, only for Zaragoza. Can be used to find a bus stops, tram stations or bizi stations", { address: z.string(), }, async ({ address }) => { const GOOGLE_MAPS_API_KEY = process.env.GOOGLE_MAPS_API_KEY; if (!GOOGLE_MAPS_API_KEY) { return { content: [ { type: "text", text: "You should configure the GOOGLE_MAPS_API_KEY for MCP DNDzgz", }, ], }; } const encodedAddress = encodeURIComponent(`${address}, Zaragoza, Spain`); const url = `https://maps.googleapis.com/maps/api/geocode/json?address=${encodedAddress}&key=${GOOGLE_MAPS_API_KEY}`; const response = await fetch(url); if (response.ok) { const data = await response.json(); if (data.status === "OK" && data.results.length > 0) { const location = data.results[0].geometry.location; location.confindence = data.results[0].geometry.location_type; location.formatted_address = data.results[0].formatted_address; return { content: [{ type: "text", text: JSON.stringify(location) }], }; } else { return { content: [ { type: "text", text: `No geolocation found for the address: ${address}`, }, ], }; } } else { return { content: [ { type: "text", text: `Failed to fetch geolocation for the address: ${address}`, }, ], }; } } );

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/danilat/mcp-dndzgz'

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