Repository navigation
Expand file tree
/
Copy pathtest_client.py
More file actions
49 lines (42 loc) · 1.72 KB
/
Copy pathtest_client.py
File metadata and controls
49 lines (42 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import asyncio
from fastmcp import Client
from src.googlemaps_mcp_server.main import mcp
async def main():
async with Client(mcp) as client:
# Geocode an address
print("Geocoding 'University of Passau, Germany'...")
geocode_result = await client.call_tool("geocode", {"address": "University of Passau, Germany"})
geocode_text = geocode_result[0].text
print(f"Geocode Result: {geocode_text}")
# Parse the result to get lat/lon
import json
data = json.loads(geocode_text)
lat = data["latitude"]
lon = data["longitude"]
# Get a map for the coordinates at different zoom levels
zoom_levels = [8, 12,18, 20]
for zoom in zoom_levels:
print(f"Getting map for lat={lat}, lon={lon} at zoom={zoom}...")
map_result = await client.call_tool(
"get_map",
{
"lat": lat,
"lon": lon,
"maptype": "hybrid",
"zoom": zoom,
"width": 1024,
"height": 1024,
"scale": 2,
},
)
print(f"Map Result (zoom={zoom}): {map_result[0].text}")
# --- Test Resources and Prompts ---
print("\n--- Testing Prompts ---")
# List and get a prompt
prompts = await client.list_prompts()
print(f"Available Prompts: {[p.name for p in prompts]}")
map_prompt = await client.get_prompt("get_map_for_address", {"address": "University of Passau, Germany"})
print(f"Generated Prompt: {map_prompt}")
print("--- Prompt Test Complete ---")
if __name__ == "__main__":
asyncio.run(main())