Skip to main content
Glama

Reverse Geocode

get_reverse_geocode

Convert geographic coordinates into a human-readable address using Google Maps data. Input latitude and longitude values to retrieve location information.

Instructions

Convert coordinates to an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYesLatitude coordinate
longitudeYesLongitude coordinate

Implementation Reference

  • Core implementation of reverse geocoding logic using Google Maps Places API client. Validates coordinates, calls reverseGeocode API, processes the first result, and handles errors.
    async reverseGeocode(
        latitude: number,
        longitude: number
    ): Promise<ServiceResponse<Location>> {
        try {
            validateCoordinates(latitude, longitude);
    
            const response = await this.client.reverseGeocode({
                params: {
                    key: config.googleMapsApiKey,
                    latlng: { lat: latitude, lng: longitude },
                    language: config.defaultLanguage as Language,
                },
            });
    
            if (response.data.results.length === 0) {
                throw new Error("No results found for the given coordinates");
            }
    
            const result = response.data.results[0];
            return {
                success: true,
                data: {
                    lat: latitude,
                    lng: longitude,
                    address: result.formatted_address,
                    placeId: result.place_id,
                },
            };
        } catch (error) {
            return handleError(error);
        }
    }
  • Registers the 'get_reverse_geocode' tool with MCP server, including schema reference and a thin async handler that delegates to PlacesSearcher.reverseGeocode and formats the response.
    server.registerTool(
        "get_reverse_geocode",
        {
            title: "Reverse Geocode",
            description: "Convert coordinates to an address",
            inputSchema: ReverseGeocodeSchema,
        },
        async (args) => {
            try {
                const result = await placesSearcher.reverseGeocode(
                    args.latitude,
                    args.longitude
                );
                return {
                    content: [
                        { type: "text", text: JSON.stringify(result, null, 2) },
                    ],
                    isError: !result.success,
                };
            } catch (error) {
                const errorResponse = handleError(error);
                return {
                    content: [
                        {
                            type: "text",
                            text:
                                errorResponse.error ||
                                "An unknown error occurred",
                        },
                    ],
                    isError: true,
                };
            }
        }
    );
  • Zod schema defining the input parameters for the get_reverse_geocode tool: latitude and longitude numbers.
    export const ReverseGeocodeSchema = {
      latitude: z.number().describe("Latitude coordinate"),
      longitude: z.number().describe("Longitude coordinate")
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'convert' implies a read-only transformation, the description doesn't mention any behavioral traits like rate limits, accuracy considerations, data source, error handling, or what happens with invalid coordinates. For a tool with no annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise - a single sentence that directly states the tool's purpose with zero wasted words. It's front-loaded with the core functionality and doesn't include any unnecessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple coordinate-to-address conversion tool with 2 parameters and 100% schema coverage, the description is minimally adequate. However, with no annotations and no output schema, it should ideally provide more context about what kind of address format is returned, accuracy considerations, or limitations. The description meets basic requirements but could be more complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description adds no additional parameter semantics beyond what's in the schema (latitude and longitude as coordinates). The baseline score of 3 is appropriate when the schema does all the parameter documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('convert') and resource ('coordinates to an address'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_geocode' (which likely converts addresses to coordinates), leaving some ambiguity about when to use each.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'get_geocode' (likely the inverse operation) and 'search_nearby' (which might also use coordinates), there's no indication of when this specific reverse geocoding tool is preferred over other coordinate-based tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/BACH-AI-Tools/MCP-Google-Maps'

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