get_location
Retrieve your current geographic location using IP geolocation or system settings to provide accurate positioning data.
Instructions
Get your current location based on IP geolocation or system settings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.js:183-197 (handler)Handler function for the 'get_location' tool that returns the current location information by calling detectLocation if not already loaded.case 'get_location': { // Wait for location if not yet loaded if (!LOCATION) { LOCATION = await detectLocation(); } return { content: [ { type: 'text', text: JSON.stringify(LOCATION, null, 2), }, ], }; }
- server.js:129-132 (schema)Input schema definition for the 'get_location' tool, which takes no parameters.inputSchema: { type: 'object', properties: {}, },
- server.js:126-133 (registration)Registration of the 'get_location' tool in the list of available tools.{ name: 'get_location', description: 'Get your current location based on IP geolocation or system settings', inputSchema: { type: 'object', properties: {}, }, },
- server.js:37-85 (helper)Helper function that fetches the user's location via IP geolocation API or falls back to environment variables.async function detectLocation() { return new Promise((resolve) => { https.get('https://ipapi.co/json/', (res) => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => { try { const locationData = JSON.parse(data); resolve({ city: locationData.city || 'Unknown', province: locationData.region || 'Unknown', country: locationData.country_name || 'Unknown', country_code: locationData.country || 'Unknown', coordinates: { latitude: locationData.latitude || 0, longitude: locationData.longitude || 0 }, timezone: locationData.timezone || detectTimezone(), ip: locationData.ip || 'Unknown' }); } catch (e) { // Fallback to environment variables or defaults resolve({ city: process.env.CITY || 'Unknown', province: process.env.PROVINCE || 'Unknown', country: process.env.COUNTRY || 'Unknown', coordinates: { latitude: parseFloat(process.env.LATITUDE) || 0, longitude: parseFloat(process.env.LONGITUDE) || 0 }, timezone: detectTimezone() }); } }); }).on('error', () => { // Fallback to environment variables or defaults resolve({ city: process.env.CITY || 'Unknown', province: process.env.PROVINCE || 'Unknown', country: process.env.COUNTRY || 'Unknown', coordinates: { latitude: parseFloat(process.env.LATITUDE) || 0, longitude: parseFloat(process.env.LONGITUDE) || 0 }, timezone: detectTimezone() }); }); }); }