Skip to main content
Glama

Geocode Address

get_geocode

Convert addresses or place names into geographic coordinates for mapping and location-based applications.

Instructions

Convert an address to coordinates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesAddress or place name to convert

Implementation Reference

  • Registers the 'get_geocode' tool with the MCP server, including title, description, input schema, and a handler function that calls placesSearcher.geocode and formats the response.
    server.registerTool(
        "get_geocode",
        {
            title: "Geocode Address",
            description: "Convert an address to coordinates",
            inputSchema: GeocodeSchema,
        },
        async (args) => {
            try {
                const result = await placesSearcher.geocode(args.address);
                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,
                };
            }
        }
    );
  • Defines the input schema for the 'get_geocode' tool using Zod, requiring an 'address' string.
    export const GeocodeSchema = {
      address: z.string().describe("Address or place name to convert")
    };
  • Implements the core geocoding logic in the PlacesSearcher class by calling the Google Maps Geocoding API, extracting the first result's location data, and returning it in the ServiceResponse format.
    async geocode(address: string): Promise<ServiceResponse<Location>> {
        try {
            validateRequiredString(address, "Address");
    
            const response = await this.client.geocode({
                params: {
                    key: config.googleMapsApiKey,
                    address: address,
                    language: config.defaultLanguage as Language,
                    region: config.defaultRegion,
                },
            });
    
            if (response.data.results.length === 0) {
                throw new Error("No results found for the given address");
            }
    
            const location = response.data.results[0].geometry.location;
            return {
                success: true,
                data: {
                    lat: location.lat,
                    lng: location.lng,
                    address: response.data.results[0].formatted_address,
                    placeId: response.data.results[0].place_id,
                },
            };
        } catch (error) {
            return handleError(error);
        }
    }
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. While 'Convert' implies a read-only operation, it doesn't address rate limits, accuracy expectations, error handling, or what format the coordinates will be returned in. This leaves significant gaps for an AI agent to understand the tool's behavior.

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 at just four words, front-loading the core functionality without any wasted language. Every word earns its place in communicating the essential purpose.

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 geocoding tool with no annotations and no output schema, the description is insufficient. It doesn't explain what coordinate system is used, whether it returns latitude/longitude pairs, accuracy metrics, or how to interpret results. The agent would need to guess about the tool's output format and behavior.

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 schema has 100% description coverage, with the single parameter 'address' clearly documented. The description doesn't add any meaningful semantic context beyond what the schema already provides, such as examples of valid address formats or handling of ambiguous inputs.

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 ('address to coordinates'), making it immediately understandable. However, it doesn't explicitly distinguish this tool from its sibling 'get_reverse_geocode', which presumably does the opposite conversion.

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_place_details' and 'search_nearby' available, there's no indication of when address-to-coordinate conversion is preferred over other geospatial operations.

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