Skip to main content
Glama
cablate

MCP Google Map Server

maps_geocode

Convert addresses or landmark names into precise geographic coordinates using the MCP Google Map Server, enabling accurate location-based applications and services.

Instructions

將地址轉換為座標

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes要轉換的地址或地標名稱

Implementation Reference

  • Main handler function (ACTION) for the maps_geocode tool. It creates a PlacesSearcher instance, calls geocode on the provided address, and returns the result as MCP content or error.
    async function ACTION(params: any): Promise<{ content: any[]; isError?: boolean }> {
      try {
        // Create a new PlacesSearcher instance with the current request's API key
        const apiKey = getCurrentApiKey();
        const placesSearcher = new PlacesSearcher(apiKey);
        const result = await placesSearcher.geocode(params.address);
    
        if (!result.success) {
          return {
            content: [{ type: "text", text: result.error || "Failed to geocode address" }],
            isError: true,
          };
        }
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result.data, null, 2),
            },
          ],
          isError: false,
        };
      } catch (error: any) {
        const errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
        return {
          isError: true,
          content: [{ type: "text", text: `Error geocoding address: ${errorMessage}` }],
        };
      }
    }
  • Zod schema definition for input parameters (address) and TypeScript type inference for GeocodeParams.
    const SCHEMA = {
      address: z.string().describe("Address or place name to convert to coordinates"),
    };
    
    export type GeocodeParams = z.infer<z.ZodObject<typeof SCHEMA>>;
  • src/config.ts:35-40 (registration)
    Tool registration in server configuration, referencing the Geocode module's NAME, DESCRIPTION, SCHEMA, and ACTION.
    {
      name: Geocode.NAME,
      description: Geocode.DESCRIPTION,
      schema: Geocode.SCHEMA,
      action: (params: GeocodeParams) => Geocode.ACTION(params),
    },
  • src/config.ts:6-6 (registration)
    Import of the Geocode tool module and its params type.
    import { Geocode, GeocodeParams } from "./tools/maps/geocode.js";
Install Server

Other Tools

Related 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/cablate/mcp-google-map'

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