#!/usr/bin/env python3
"""Simple test script for the Geolocation MCP server."""
import asyncio
import os
import sys
from src.mcp_server_geolocation.server import WalkScoreClient
async def test_walkscore_api():
"""Test the WalkScore API client directly."""
api_key = "b901157a817d3058367b22fdabcc6596"
client = WalkScoreClient(api_key)
# Test coordinates from the provided URL
lat = 40.7136183
lon = -73.9909309
print(f"Testing WalkScore API with coordinates: {lat}, {lon}")
print("=" * 50)
try:
# Test transit stops
print("Fetching transit stops...")
stops = await client.get_transit_stops(lat, lon)
print(f"Found {len(stops)} transit stops")
if stops:
print("\nFirst 3 stops:")
for i, stop in enumerate(stops[:3], 1):
print(f"{i}. {stop.name}")
print(f" Distance: {stop.distance:.3f} miles")
print(f" Routes: {stop.summary_text}")
print()
# Test WalkScore
print("Fetching WalkScore...")
walkscore_data = await client.get_walkscore(lat=lat, lon=lon)
print(f"WalkScore API Response: {walkscore_data}")
except Exception as e:
print(f"Error: {e}")
return False
return True
if __name__ == "__main__":
success = asyncio.run(test_walkscore_api())
sys.exit(0 if success else 1)