Skip to main content
Glama
stadiamaps

Stadia Maps Location API MCP Server

isochrone

Create isochrone contours to visualize areas accessible within a set time or distance from a specific location. Supports multiple travel methods and returns GeoJSON polygons for 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
contoursYesArray of 1-4 contours. All contours must be of the same type (all time or all distance).
costingYesThe method of travel to use for isochrone calculation (auto = automobile).
locationYesA geographic coordinate pair.

Implementation Reference

  • Main handler function for the 'isochrone' tool. Constructs the API request using provided parameters, calls the Stadia Maps Routing API, processes the response using isochroneToolResult 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, }, ); }
  • Helper function to format the IsochroneResponse from the API into a structured CallToolResult with text description of contours 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}`, }, ], }; }
  • src/index.ts:91-100 (registration)
    Registers the 'isochrone' tool with the MCP server, specifying name, description, input schema, 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 (travel mode) used in the isochrone tool input.
    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 in the isochrone tool input, validating 1-4 contours all of same type (time or distance).
    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).", }, );

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

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