Skip to main content
Glama

zaragoza-bizi-stations

Find nearby Bizi bicycle rental stations in Zaragoza using latitude and longitude coordinates. Access real-time station details for convenient cycling options.

Instructions

Get all Bizi stations in Zaragoza, the bicycle rental public service

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes
longitudeYes

Implementation Reference

  • Handler function that fetches Bizi stations from the external API, computes the top nearest stations based on provided latitude and longitude using helper functions, and returns the data as a text content block.
    async ({ latitude, longitude }) => { const response = await fetch("https://dndzgz.herokuapp.com/services/bizi"); 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 Bizi stations", }, ], }; } }
  • Zod schema defining the input parameters: latitude and longitude as numbers.
    { latitude: z.number(), longitude: z.number(), },
  • index.js:128-158 (registration)
    Registration of the tool using McpServer.tool() method, specifying name, description, input schema, and inline handler function.
    server.tool( "zaragoza-bizi-stations", "Get all Bizi stations in Zaragoza, the bicycle rental public service", { latitude: z.number(), longitude: z.number(), }, async ({ latitude, longitude }) => { const response = await fetch("https://dndzgz.herokuapp.com/services/bizi"); 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 Bizi stations", }, ], }; } } );
  • Helper function to get the top N nearest positions (default 10), used by the handler to filter stations by proximity.
    function getTopNearestPositions(positions, latitude, longitude, size = 10) { return getOrderedPositionsByDistance(positions, latitude, longitude).slice( 0, size ); }
  • Helper functions for ordering positions by distance using Haversine formula and computing distance in meters, supporting the nearest stations calculation.
    function getOrderedPositionsByDistance(positions, latitude, longitude) { return positions .map((position) => { const distanceInMeters = haversineDistanceInMeters( { lat: latitude, lon: longitude }, position ); return { ...position, distanceInMeters, }; }) .sort((a, b) => a.distanceInMeters - b.distanceInMeters); } 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