Skip to main content
Glama

Superprecio MCP Server

by bunkerapps
findNearbySupermarkets.tsβ€’3.93 kB
/** * MCP Tool: Find Nearby Supermarkets * Find supermarkets near a given location using GPS coordinates */ import type { SuperPrecioApiClient } from '../client/superPrecioApi.js'; export const findNearbySupermarketsTool = { name: 'find_nearby_supermarkets', description: `Find supermarkets near your current location using GPS coordinates. Discover which supermarkets are closest to you! Features: - Search by latitude and longitude - Customizable search radius (default: 5km) - Get distance in km and meters - See full addresses and contact info - Opening hours when available Perfect for: - Finding nearby stores after optimizing your shopping list - Planning your shopping route - Discovering new supermarkets in your area - Getting directions to the best-priced store Example coordinates for Buenos Aires city center: - Latitude: -34.6037 - Longitude: -58.3816 The tool uses the Haversine formula to calculate accurate distances.`, inputSchema: { type: 'object', properties: { latitude: { type: 'number', description: 'Latitude coordinate (-90 to 90)', minimum: -90, maximum: 90, }, longitude: { type: 'number', description: 'Longitude coordinate (-180 to 180)', minimum: -180, maximum: 180, }, radiusKm: { type: 'number', description: 'Search radius in kilometers (default: 5km)', minimum: 0.1, maximum: 50, default: 5, }, }, required: ['latitude', 'longitude'], }, }; export async function executeFindNearbySupermarkets( client: SuperPrecioApiClient, args: { latitude: number; longitude: number; radiusKm?: number } ) { const response = await client.findNearbySupermarkets({ lat: args.latitude, lng: args.longitude, radius: args.radiusKm || 5, }); if (!response.success) { return { content: [ { type: 'text', text: `Failed to find nearby supermarkets: ${response.message || 'Unknown error'}`, }, ], isError: true, }; } const locations = response.locations || []; const count = response.found || 0; if (count === 0) { return { content: [ { type: 'text', text: ` πŸ“ No supermarkets found within ${response.radiusKm}km of your location. Search location: Latitude: ${response.searchLocation.latitude} Longitude: ${response.searchLocation.longitude} Try: - Increasing the search radius - Checking if your coordinates are correct - Moving to a different location `, }, ], }; } const summary = ` πŸ“ Nearby Supermarkets (${count} found) Search radius: ${response.radiusKm}km Location: ${response.searchLocation.latitude.toFixed(4)}, ${response.searchLocation.longitude.toFixed(4)} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ${locations .map((loc: any, i: number) => { return ` ${i + 1}. ${loc.supermarketName} - ${loc.branchName} πŸ“ Distance: ${loc.distance}km (${loc.distanceMeters}m) πŸ“ Address: ${loc.address}, ${loc.city} ${loc.phone ? `πŸ“ž Phone: ${loc.phone}` : ''} ${loc.openingHours ? `πŸ•’ Hours: ${loc.openingHours}` : ''} πŸ—ΊοΈ Coordinates: ${loc.coordinates.latitude}, ${loc.coordinates.longitude} `; }) .join('\n')} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ πŸš— Closest supermarket: ${locations[0].supermarketName} (${locations[0].distance}km away) πŸ’‘ Tip: After optimizing your shopping list, use this to find the nearest location of the best-priced supermarket! `; return { content: [ { type: 'text', text: summary, }, { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; }

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/bunkerapps/superprecio_mcp'

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