Skip to main content
Glama

zaragoza-bus-stops

Retrieve nearby bus stops in Zaragoza by providing latitude and longitude coordinates, enabling easy access to public transport locations for planning routes or travel.

Instructions

Get all bus stops in Zaragoza

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes
longitudeYes

Implementation Reference

  • index.js:80-98 (handler)
    Handler function that fetches all bus stops from the API, filters top nearest using latitude/longitude, and returns JSON or error.
    async ({ latitude, longitude }) => { const response = await fetch("https://dndzgz.herokuapp.com/services/bus"); if (response.ok) { const data = await response.json(); const nearestPositions = getTopNearestPositions( data.locations, latitude, longitude ); return { content: [{ type: "text", text: JSON.stringify(nearestPositions) }], }; } else { return { content: [ { type: "text", text: "It was not possible to get the bus stops" }, ], }; }
  • Zod schema for input parameters: latitude and longitude as numbers.
    { latitude: z.number(), longitude: z.number(), },
  • index.js:73-100 (registration)
    McpServer tool registration for 'zaragoza-bus-stops' including name, description, schema, and handler.
    server.tool( "zaragoza-bus-stops", "Get all bus stops in Zaragoza", { latitude: z.number(), longitude: z.number(), }, async ({ latitude, longitude }) => { const response = await fetch("https://dndzgz.herokuapp.com/services/bus"); if (response.ok) { const data = await response.json(); const nearestPositions = getTopNearestPositions( data.locations, latitude, longitude ); return { content: [{ type: "text", text: JSON.stringify(nearestPositions) }], }; } else { return { content: [ { type: "text", text: "It was not possible to get the bus stops" }, ], }; } } );
  • Helper to get top N nearest positions by distance, used in the handler.
    function getTopNearestPositions(positions, latitude, longitude, size = 10) { return getOrderedPositionsByDistance(positions, latitude, longitude).slice( 0, size );
  • Haversine formula implementation for distance calculation in meters, used in sorting positions.
    function haversineDistanceInMeters(position1, position2) { const toRadians = (degrees) => degrees * (Math.PI / 180); const radiusOfEarth = 6371; const dLat = toRadians(position2.lat - position1.lat); const dLon = toRadians(position2.lon - position1.lon); const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(toRadians(position1.lat)) * Math.cos(toRadians(position2.lat)) * Math.sin(dLon / 2) * Math.sin(dLon / 2); const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return radiusOfEarth * c * 1000; }

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