Skip to main content
Glama

reverse-geocode

Convert geographic coordinates to human-readable addresses by providing latitude and longitude values. This tool enables location identification from GPS data.

Instructions

Convert coordinates to an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYesThe latitude
longitudeYesThe longitude

Implementation Reference

  • Implementation of the reverseGeocode tool handler using Google Maps API to convert coordinates to address.
    export async function reverseGeocode(
      params: z.infer<typeof reverseGeocodeSchema>,
      extra?: any
    ) {
      const apiKey = process.env.GOOGLE_MAPS_API_KEY;
      if (!apiKey) {
        throw new Error("GOOGLE_MAPS_API_KEY is required");
      }
    
      try {
        const response = await googleMapsClient.reverseGeocode({
          params: {
            latlng: [params.latitude, params.longitude],
            key: apiKey,
          },
        });
    
        const results = response.data.results;
        if (results.length === 0) {
          return {
            content: [
              {
                type: "text" as const,
                text: "No results found for the given coordinates.",
              },
            ],
          };
        }
    
        const location = results[0];
        return {
          content: [
            {
              type: "text" as const,
              text: formatLocationToMarkdown(
                "Reverse Geocoded Location",
                location.formatted_address,
                params.latitude,
                params.longitude,
                location.place_id
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error reverse geocoding coordinates: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    }
  • Zod schema defining input parameters for reverse-geocode tool: latitude and longitude.
    export const reverseGeocodeSchema = z.object({
      latitude: z.number().describe("The latitude"),
      longitude: z.number().describe("The longitude"),
    });
  • src/index.ts:70-77 (registration)
    Registration of the reverse-geocode tool in the MCP server using the handler and schema from maps.ts.
    server.tool(
      "reverse-geocode",
      "Convert coordinates to an address",
      reverseGeocodeSchema.shape,
      async (params) => {
        return await reverseGeocode(params);
      }
    );
  • Helper function to format geocoding results into Markdown, used by reverseGeocode.
    function formatLocationToMarkdown(title: string, address: string, lat: number, lng: number, placeId?: string): string {
      let markdown = `# ${title}\n\n`;
      markdown += `Address: ${address}  \n`;
      markdown += `Coordinates: ${lat}, ${lng}  \n`;
      if (placeId) markdown += `Place ID: \`${placeId}\`  \n`;
      markdown += `Google Maps: [View on Maps](https://maps.google.com/?q=${lat},${lng})`;
      return markdown;
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but only states the basic function. It doesn't cover important aspects like rate limits, accuracy, data sources, error handling, or output format (e.g., address structure, precision), which are critical for a geocoding service.

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 extremely concise with a single, clear sentence that directly states the tool's purpose without any wasted words. It's perfectly front-loaded and efficiently communicates the core functionality.

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

Completeness2/5

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

For a tool with no annotations, no output schema, and moderate complexity (coordinate conversion), the description is insufficient. It lacks details on behavioral traits, output expectations, and usage context relative to siblings, leaving significant gaps for an AI agent to operate effectively.

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?

The description adds no parameter semantics beyond what the schema already provides (100% coverage with clear descriptions for latitude and longitude). It doesn't explain coordinate formats (e.g., decimal degrees), ranges, or special cases, so it meets the baseline but adds no extra value.

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 the sibling 'geocode' tool, which appears to perform the opposite operation (address to coordinates), so it misses full sibling distinction.

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. It doesn't mention the sibling 'geocode' tool for reverse operations or other location-related tools like 'places-search' or 'place-details', leaving the agent without context for tool selection.

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/CaptainCrouton89/maps-mcp'

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