Skip to main content
Glama
masx200

AMap Maps MCP Server

by masx200

maps_direction_driving

Plan driving routes between origin and destination coordinates for car commutes. Get detailed navigation data including travel paths and directions for efficient journey planning.

Instructions

驾车路径规划 API 可以根据用户起终点经纬度坐标规划以小客车、轿车通勤出行的方案,并且返回通勤方案的数据。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
originYes出发点经度,纬度,坐标格式为:经度,纬度
destinationYes目的地经度,纬度,坐标格式为:经度,纬度

Implementation Reference

  • Handler function that implements the maps_direction_driving tool by calling the AMap driving directions API, processing the response, and returning formatted JSON or error.
    async function handleDriving(origin, destination) { const url = new URL("https://restapi.amap.com/v3/direction/driving"); url.searchParams.append("key", AMAP_MAPS_API_KEY); url.searchParams.append("origin", origin); url.searchParams.append("destination", destination); url.searchParams.append("source", "ts_mcp"); const response = await fetch(url.toString()); const data = await response.json(); if (data.status !== "1") { return { content: [{ type: "text", text: `Direction Driving failed: ${data.info || data.infocode}`, }], isError: true, }; } return { content: [{ type: "text", text: JSON.stringify( { route: { origin: data.route.origin, destination: data.route.destination, paths: data.route.paths.map((path) => { return { path: path.path, distance: path.distance, duration: path.duration, steps: path.steps.map((step) => { return { instruction: step.instruction, road: step.road, distance: step.distance, orientation: step.orientation, duration: step.duration, }; }), }; }), }, }, null, 2, ), }], isError: false, };
  • Schema definition for the maps_direction_driving tool, including name, description, and input schema requiring origin and destination coordinates.
    const DRIVING_TOOl = { name: "maps_direction_driving", description: "驾车路径规划 API 可以根据用户起终点经纬度坐标规划以小客车、轿车通勤出行的方案,并且返回通勤方案的数据。", inputSchema: { type: "object", properties: { origin: { type: "string", description: "出发点经度,纬度,坐标格式为:经度,纬度", }, destination: { type: "string", description: "目的地经度,纬度,坐标格式为:经度,纬度", }, }, required: ["origin", "destination"], }, };
  • build/index.js:247-260 (registration)
    Registration of the maps_direction_driving tool (as DRIVING_TOOl) in the MAPS_TOOLS array used for listing tools.
    const MAPS_TOOLS = [ REGEOCODE_TOOL, GEO_TOOL, IP_LOCATION_TOOL, WEATHER_TOOL, SEARCH_DETAIL_TOOL, BICYCLING_TOOL, WALKING_TOOL, DRIVING_TOOl, TRANSIT_INTEGRATED_TOOL, DISTANCE_TOOL, TEXT_SEARCH_TOOL, AROUND_SEARCH_TOOL, ];
  • build/index.js:882-885 (registration)
    Registration/dispatch case in the CallToolRequestSchema handler that routes calls to maps_direction_driving to the handleDriving function.
    case "maps_direction_driving": { const { origin, destination } = request.params.arguments; return await handleDriving(origin, destination); }
  • Duplicate handler function for maps_direction_driving in the HTTP version of the server.
    async function handleDriving(origin, destination) { const AMAP_MAPS_API_KEY = getApiKey(); const url = new URL("https://restapi.amap.com/v3/direction/driving"); url.searchParams.append("key", AMAP_MAPS_API_KEY); url.searchParams.append("origin", origin); url.searchParams.append("destination", destination); url.searchParams.append("source", "ts_mcp"); const response = await fetch(url.toString()); const data = await response.json(); if (data.status !== "1") { return { content: [ { type: "text", text: `Direction Driving failed: ${data.info || data.infocode}`, }, ], isError: true, }; } return { content: [ { type: "text", text: JSON.stringify( { route: { origin: data.route.origin, destination: data.route.destination, paths: data.route.paths.map((path) => { return { path: path.path, distance: path.distance, duration: path.duration, steps: path.steps.map((step) => { return { instruction: step.instruction, road: step.road, distance: step.distance, orientation: step.orientation, duration: step.duration, }; }), }; }), }, }, null, 2, ), }, ], isError: false, };

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/masx200/amap-maps-mcp-server'

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