Skip to main content
Glama
ricleedo

Google Services MCP Server

by ricleedo

geocode

Convert addresses to geographic coordinates using Google's geocoding service to enable location-based applications and mapping functionality.

Instructions

Convert an address to coordinates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesThe address to geocode

Implementation Reference

  • The primary handler function for the 'geocode' tool. It uses the Google Maps Geocoding API to convert an address to coordinates and returns formatted markdown output.
    export async function geocode(
      params: z.infer<typeof geocodeSchema>,
      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.geocode({
          params: {
            address: params.address,
            key: apiKey,
          },
        });
    
        const results = response.data.results;
        if (results.length === 0) {
          return {
            content: [
              {
                type: "text" as const,
                text: "No results found for the given address.",
              },
            ],
          };
        }
    
        const location = results[0];
        return {
          content: [
            {
              type: "text" as const,
              text: formatLocationToMarkdown(
                "Geocoded Location", 
                location.formatted_address, 
                location.geometry.location.lat, 
                location.geometry.location.lng,
                location.place_id
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error geocoding address: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
  • Zod schema defining the input parameters for the geocode tool: a single 'address' string field.
    export const geocodeSchema = z.object({
      address: z.string().describe("The address to geocode"),
    });
  • src/index.ts:60-67 (registration)
    MCP server registration of the 'geocode' tool, specifying name, description, input schema, and handler execution.
    server.tool(
      "geocode",
      "Convert an address to coordinates",
      geocodeSchema.shape,
      async (params) => {
        return await geocode(params);
      }
    );
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It states the transformation (address to coordinates) but doesn't mention accuracy, rate limits, error handling, authentication requirements, or what happens with ambiguous addresses. For a tool with zero annotation coverage, this is a significant gap in behavioral 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 with a single, clear sentence that directly states the tool's purpose. There's no wasted verbiage or unnecessary elaboration, making it efficiently front-loaded and easy to parse for an AI agent.

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 the lack of annotations and output schema, the description is incomplete for effective tool use. It doesn't explain the return format (e.g., coordinates structure), error cases, or performance characteristics. While the purpose is clear, the missing behavioral and output details leave significant gaps for an agent relying solely on this description.

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 doesn't add any parameter-specific information beyond what's already in the schema, which has 100% coverage and clearly documents the single 'address' parameter. The baseline score of 3 reflects adequate but minimal value addition, as the schema fully describes the parameter without needing supplemental explanation from 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 with a specific verb ('convert') and resource ('address to coordinates'), making the purpose immediately understandable. However, it doesn't explicitly distinguish this tool from its sibling 'reverse-geocode', which performs the opposite operation, leaving some ambiguity about sibling differentiation.

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 like 'reverse-geocode' (which converts coordinates to addresses) or 'places-search' (which might involve geocoding). There's no mention of prerequisites, limitations, or typical use cases, leaving the agent with insufficient context for optimal 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/ricleedo/Google-Service-MCP'

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