Skip to main content
Glama
vlad-ds

Street View MCP

by vlad-ds

get_metadata

Fetch Street View panorama metadata by location, coordinates, or panorama ID to obtain copyright, date, and geographic information for 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

TableJSON Schema
NameRequiredDescriptionDefault
locationNo
lat_lngNo
pano_idNo
radiusNo
sourceNodefault

Implementation Reference

  • Handler function for 'get_metadata' tool. Includes @mcp.tool() decorator for registration and input parsing. Delegates core logic to get_panorama_metadata helper.
    @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 implementation of get_metadata logic. Makes HTTP request to Google Street View Metadata API and returns 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}")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vlad-ds/street-view-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server