Skip to main content
Glama

reverse_geocode

Transforms latitude and longitude into a detailed address and location description, providing building, street, city, administrative boundaries, and OSM metadata, ideal for converting GPS coordinates to human-readable places.

Instructions

Convert geographic coordinates to a detailed address and location description.

This tool takes a specific point on Earth (latitude and longitude) and returns comprehensive information about that location, including its address, nearby landmarks, administrative boundaries, and other contextual information. Useful for translating GPS coordinates into human-readable locations.

Args: latitude: The latitude coordinate (decimal degrees, WGS84) longitude: The longitude coordinate (decimal degrees, WGS84)

Returns: Detailed address and location information including: - Formatted address - Building, street, city, state, country - Administrative hierarchy - OSM metadata - Postal code and other relevant identifiers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes
longitudeYes

Implementation Reference

  • The MCP tool handler for 'reverse_geocode'. Retrieves OSM client from context and calls its reverse_geocode method to convert lat/lon to address using Nominatim.
    @mcp.tool() async def reverse_geocode(latitude: float, longitude: float, ctx: Context) -> Dict: """ Convert geographic coordinates to a detailed address and location description. This tool takes a specific point on Earth (latitude and longitude) and returns comprehensive information about that location, including its address, nearby landmarks, administrative boundaries, and other contextual information. Useful for translating GPS coordinates into human-readable locations. Args: latitude: The latitude coordinate (decimal degrees, WGS84) longitude: The longitude coordinate (decimal degrees, WGS84) Returns: Detailed address and location information including: - Formatted address - Building, street, city, state, country - Administrative hierarchy - OSM metadata - Postal code and other relevant identifiers """ osm_client = ctx.request_context.lifespan_context.osm_client return await osm_client.reverse_geocode(latitude, longitude)
  • Supporting method in OSMClient class that implements the reverse geocoding logic by querying the Nominatim reverse API.
    async def reverse_geocode(self, lat: float, lon: float) -> Dict: """Reverse geocode coordinates to address""" if not self.session: raise RuntimeError("OSM client not connected") nominatim_url = "https://nominatim.openstreetmap.org/reverse" async with self.session.get( nominatim_url, params={ "lat": lat, "lon": lon, "format": "json" }, headers={"User-Agent": "OSM-MCP-Server/1.0"} ) as response: if response.status == 200: return await response.json() else: raise Exception(f"Failed to reverse geocode ({lat}, {lon}): {response.status}")
  • The @mcp.tool() decorator registers the reverse_geocode function as an MCP tool.
    @mcp.tool()

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/jagan-shanmugam/open-streetmap-mcp'

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