Skip to main content
Glama
stadiamaps

Stadia Maps Location API MCP Server

isochrone

Calculate travel-time or distance-based reachable areas from a location using specified transportation modes, returning GeoJSON polygons for visualization and analysis.

Instructions

Generate isochrone contours showing areas reachable within specified time or distance constraints from a single location. Returns GeoJSON polygons representing the reachable areas.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYesA geographic coordinate pair.
costingYesThe method of travel to use for isochrone calculation (auto = automobile).
contoursYesArray of 1-4 contours. All contours must be of the same type (all time or all distance).

Implementation Reference

  • Main handler function that constructs an IsochroneRequest, calls the Stadia Maps API, processes the response using a helper, or handles errors.
    export async function isochrone({ location, costing, contours, }: IsochroneParams): Promise<CallToolResult> { return handleToolError( async () => { const request: IsochroneRequest = { locations: [location], costing, contours, }; const response = await routeApi.isochrone({ isochroneRequest: request }); if (instanceOfIsochroneResponse(response)) { return isochroneToolResult(response); } else { return { content: [ { type: "text", text: "Unexpected response format from isochrone API.", }, ], }; } }, { contextMessage: "Isochrone calculation failed", enableLogging: true, }, ); }
  • src/index.ts:91-100 (registration)
    Registers the 'isochrone' MCP tool with name, description, input schema (using imported zod schemas), and the handler function.
    server.tool( "isochrone", "Generate isochrone contours showing areas reachable within specified time or distance constraints from a single location. Returns GeoJSON polygons representing the reachable areas.", { location: coordinatesSchema, costing: isochroneCostingSchema, contours: contoursSchema, }, isochrone, );
  • Zod schema for the costing model parameter used in the isochrone tool.
    export const isochroneCostingSchema = z .nativeEnum(IsochroneCostingModel) .describe( "The method of travel to use for isochrone calculation (auto = automobile).", );
  • Zod schema for the contours array parameter, including validation for consistency in time/distance types.
    export const contoursSchema = z .array(contourSchema) .min(1) .max(4) .describe( "Array of 1-4 contours. All contours must be of the same type (all time or all distance).", ) .refine( (contours) => { const hasTime = contours.some((c) => c.time !== undefined); const hasDistance = contours.some((c) => c.distance !== undefined); return !(hasTime && hasDistance); }, { message: "All contours must be of the same type (either all time-based or all distance-based).", }, );
  • Helper function to format the IsochroneResponse into a CallToolResult text summary, extracting contour info and GeoJSON geometries.
    function isochroneToolResult(response: IsochroneResponse): CallToolResult { if (!response.features || !response.features.length) { return { content: [ { type: "text", text: "No isochrone results found.", }, ], }; } const results = response.features .map((feature, index) => { const properties = feature.properties; if (!properties) return `Invalid result (no properties): ${index}`; const contourInfo = `Contour ${properties.contour}`; let metricInfo = ""; if (properties?.metric === "time") { metricInfo = `Time: ${properties.contour} minutes`; } else if (properties?.metric === "distance") { metricInfo = `Distance: ${properties.contour} km`; } return [ `${contourInfo}`, metricInfo ? `${metricInfo}` : "", `GeoJSON Geometry: ${JSON.stringify(feature.geometry)}`, ] .filter(Boolean) .join("\n"); }) .join("\n---\n"); return { content: [ { type: "text", text: `Isochrone Results:\n---\n${results}`, }, ], }; }

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/stadiamaps/stadiamaps-mcp-server-ts'

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