get_metadata
Fetch metadata for Street View panoramas using location, coordinates, or panorama ID. Retrieve details like status, copyright, date, and geographic position for creating virtual tours.
Instructions
Fetch metadata about a Street View panorama.
Args: location: The address to check for Street View imagery lat_lng: Comma-separated latitude and longitude (e.g., "40.748817,-73.985428") pano_id: Specific panorama ID to fetch metadata for radius: Search radius in meters when using location or coordinates source: Limit Street View searches to selected sources ("default" or "outdoor")
Returns: Dict: Panorama metadata including status, copyright, date, pano_id, lat, lng
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat_lng | No | ||
| location | No | ||
| pano_id | No | ||
| radius | No | ||
| source | No | default |
Implementation Reference
- src/street_view_mcp/server.py:88-125 (handler)Handler function for the 'get_metadata' tool. Decorated with @mcp.tool() for registration. Parses lat_lng parameter and calls the core helper function.@mcp.tool() def get_metadata( location: Optional[str] = None, lat_lng: Optional[str] = None, pano_id: Optional[str] = None, radius: int = 50, source: str = "default", ) -> Dict[str, Any]: """ Fetch metadata about a Street View panorama. Args: location: The address to check for Street View imagery lat_lng: Comma-separated latitude and longitude (e.g., "40.748817,-73.985428") pano_id: Specific panorama ID to fetch metadata for radius: Search radius in meters when using location or coordinates source: Limit Street View searches to selected sources ("default" or "outdoor") Returns: Dict: Panorama metadata including status, copyright, date, pano_id, lat, lng """ # Parse lat_lng string to tuple if provided lat_lng_tuple = None if lat_lng: try: lat, lng = map(float, lat_lng.split(',')) lat_lng_tuple = (lat, lng) except (ValueError, TypeError): raise ValueError("Invalid lat_lng format. Use format: '40.714728,-73.998672'") # Fetch metadata return get_panorama_metadata( location=location, lat_lng=lat_lng_tuple, pano_id=pano_id, radius=radius, source=source, )
- Core helper function implementing the API call to Google Street View metadata endpoint, handling parameters and returning JSON response.def get_panorama_metadata( location: Optional[str] = None, lat_lng: Optional[Tuple[float, float]] = None, pano_id: Optional[str] = None, radius: int = 50, source: str = "default", ): """ Fetch metadata about a Street View panorama to check availability. Args: location (str, optional): The address to check for Street View imagery lat_lng (tuple, optional): Latitude and longitude coordinates as (lat, lng) pano_id (str, optional): Specific panorama ID to fetch metadata for radius (int): Search radius in meters (when using location or lat_lng) source (str): Limits Street View searches to selected sources (default, outdoor) Returns: dict: Panorama metadata including status, copyright, date, pano_id, lat, lng Raises: ValueError: If no location method is provided or multiple are provided Exception: If the API request fails """ # Validate input: exactly one location method must be provided location_methods = sum(1 for m in [location, lat_lng, pano_id] if m is not None) if location_methods == 0: raise ValueError("Must provide one of: location, lat_lng, or pano_id") if location_methods > 1: raise ValueError("Provide only one of: location, lat_lng, or pano_id") base_url = "https://maps.googleapis.com/maps/api/streetview/metadata" params = { "radius": radius, "source": source, "key": API_KEY, } # Set the location parameter based on what was provided if location: params["location"] = location elif lat_lng: params["location"] = f"{lat_lng[0]},{lat_lng[1]}" elif pano_id: params["pano"] = pano_id # Remove radius when using pano_id as it's not applicable if "radius" in params: del params["radius"] response = requests.get(base_url, params=params) if response.status_code == 200: return response.json() else: raise Exception(f"Error fetching Street View metadata: {response.status_code}")