Skip to main content
Glama
ricleedo

Google Services MCP Server

by ricleedo

reverse-geocode

Convert geographic coordinates to human-readable addresses using Google Maps data. Input latitude and longitude to retrieve location information.

Instructions

Convert coordinates to an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYesThe latitude
longitudeYesThe longitude

Implementation Reference

  • The main handler function for the reverse-geocode tool. It uses Google Maps reverse geocoding API to convert latitude and longitude to an address, formats the result using formatLocationToMarkdown, and returns it as markdown text.
    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 the input parameters for the reverse-geocode tool: latitude and longitude as numbers.
    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, linking the name, description, schema, and handler function.
    server.tool(
      "reverse-geocode",
      "Convert coordinates to an address",
      reverseGeocodeSchema.shape,
      async (params) => {
        return await reverseGeocode(params);
      }
    );
  • Helper function to format the geocoded location data into markdown, used by the reverseGeocode handler.
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'convert' implies a read-only transformation, the description doesn't address important behavioral aspects like rate limits, accuracy expectations, data sources, error conditions, or what format the address will be returned in. It provides only the basic functional intent without operational context.

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 - a single sentence that directly states the tool's purpose with zero wasted words. It's perfectly front-loaded with the core functionality, making it immediately understandable without any unnecessary elaboration.

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?

Given no annotations and no output schema, the description is incomplete for a geocoding tool. It doesn't explain what kind of address format to expect, whether multiple results might be returned, accuracy considerations, or any error handling. For a coordinate-to-address conversion service, users need more context about the output and operational characteristics.

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 input schema has 100% description coverage with clear parameter documentation, so the baseline is 3. The description doesn't add any parameter-specific information beyond what's already in the schema (latitude and longitude as coordinates to convert). No additional syntax, format requirements, or constraints are provided in the description.

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 function as converting coordinates to an address, using specific verbs ('convert') and resources ('coordinates', 'address'). It distinguishes from the sibling 'geocode' tool which presumably does the opposite (address to coordinates), though this distinction isn't explicitly stated in the description itself.

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. While the sibling list includes 'geocode' (likely the inverse operation), the description doesn't mention this relationship or provide any context about appropriate use cases, prerequisites, or exclusions.

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/ricleedo/Google-Service-MCP'

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