Skip to main content
Glama
cablate

MCP Google Map Server

maps_directions

Generate precise directions between two locations using specified travel modes like driving, walking, bicycling, or transit. Ideal for planning routes with accurate, real-time guidance.

Instructions

獲取兩點之間的路線指引

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
destinationYes終點地址或座標
modeNo交通模式driving
originYes起點地址或座標

Implementation Reference

  • The ACTION function that executes the core logic of the 'maps_directions' tool. It uses PlacesSearcher to fetch directions between origin and destination, handles errors, and returns formatted content.
    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.getDirections(
          params.origin,
          params.destination,
          params.mode,
          params.departure_time,
          params.arrival_time
        );
    
        if (!result.success) {
          return {
            content: [{ type: "text", text: result.error || "Failed to get directions" }],
            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 getting directions: ${errorMessage}` }],
        };
      }
  • Zod schema defining the input parameters for the maps_directions tool.
    const SCHEMA = {
      origin: z.string().describe("Starting point address or coordinates"),
      destination: z.string().describe("Destination address or coordinates"),
      mode: z.enum(["driving", "walking", "bicycling", "transit"]).default("driving").describe("Travel mode for directions"),
      departure_time: z.string().optional().describe("Departure time (ISO string format)"),
      arrival_time: z.string().optional().describe("Arrival time (ISO string format)"),
    };
  • src/config.ts:53-58 (registration)
    Registration of the 'maps_directions' tool in the server configuration array, linking to the Directions module.
    {
      name: Directions.NAME,
      description: Directions.DESCRIPTION,
      schema: Directions.SCHEMA,
      action: (params: DirectionsParams) => Directions.ACTION(params),
    },
  • src/config.ts:9-9 (registration)
    Import statement for the Directions tool module used in registration.
    import { Directions, DirectionsParams } from "./tools/maps/directions.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