#!/usr/bin/env node
/**
* Example usage script for MCP Open Meteo Server
* This demonstrates how to test the tools manually
*/
import { getCurrentWeather } from './tools/current-weather.js';
import { getWeatherForecast } from './tools/weather-forecast.js';
import { searchLocations } from './tools/geocoding.js';
import { getAirQuality } from './tools/air-quality.js';
async function runExamples() {
console.log('🌤️ MCP Open Meteo Server - Example Usage\n');
try {
// Example 1: Search for a location
console.log('1. Searching for locations...');
const locations = await searchLocations({ name: 'New York', count: 3 });
console.log('Found locations:', locations.content[0].text.substring(0, 200) + '...\n');
// Example 2: Get current weather for New York
console.log('2. Getting current weather for New York...');
const currentWeather = await getCurrentWeather({
latitude: 40.7128,
longitude: -74.0060,
units: 'celsius'
});
console.log('Current weather:', currentWeather.content[0].text.substring(0, 300) + '...\n');
// Example 3: Get weather forecast
console.log('3. Getting weather forecast...');
const forecast = await getWeatherForecast({
latitude: 40.7128,
longitude: -74.0060,
days: 3,
hourly: false,
daily: true,
units: 'celsius'
});
console.log('Weather forecast:', forecast.content[0].text.substring(0, 300) + '...\n');
// Example 4: Get air quality
console.log('4. Getting air quality data...');
const airQuality = await getAirQuality({
latitude: 40.7128,
longitude: -74.0060,
days: 2,
current: true
});
console.log('Air quality:', airQuality.content[0].text.substring(0, 300) + '...\n');
console.log('✅ All examples completed successfully!');
console.log('\nTo use this MCP server:');
console.log('1. Build the project: npm run build');
console.log('2. Start the server: npm start');
console.log('3. Configure your MCP client to use this server');
} catch (error) {
console.error('❌ Error running examples:', error);
}
}
// Only run if this file is executed directly
if (import.meta.url === `file://${process.argv[1]}`) {
runExamples();
}