Labsco
aatakansalar logo

Valhalla MCP Server

โ˜… 4

from aatakansalar

A server for the Valhalla routing engine, offering routing, isochrone, health, and tile services.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

Valhalla MCP Server

A Model Context Protocol (MCP) server that provides seamless integration between Claude Desktop and the Valhalla Open-Street-Map routing engine. Access professional routing and isochrone capabilities directly from your AI conversations without complex APIs.

Features

Currently Supported Valhalla Services

MCP Tool/ResourceValhalla ServiceDescription
route tool/routeSingle origin โ†’ destination routing with alternatives
isochrone tool/isochroneTravel time polygons showing reachable areas
health resource/statusServer status and version information
tile resource/tile/{z}/{x}/{y}Vector tiles for client-side rendering

Valhalla Services - Coming Soon

ServiceDescriptionUse Cases
MatrixDistance/time matrices for multiple origins/destinationsDelivery optimization, logistics planning
Map-matchingMatch GPS coordinates to road networkGPS trace cleaning, route correction
ElevationElevation profiles along routes or at pointsHiking routes, difficulty analysis
ExpansionGraph traversal visualizationNetwork analysis, reachability studies
LocateDetailed metadata about nodes and edgesAddress geocoding, road attributes
CentroidOptimal convergence point from multiple locationsMeeting point optimization
Optimized RouteMulti-stop delivery routing with constraintsLogistics, delivery services

Transportation Modes

  • auto - Car routing
  • bicycle - Bicycle routing
  • pedestrian - Walking routes
  • taxi - Taxi routing
  • bus - Public transit routing

Integration with MCP Clients

Claude Desktop

Add to your Claude Desktop configuration:

{
  "mcpServers": {
    "valhalla": {
      "command": "node",
      "args": ["/path/to/valhalla-mcp/dist/index.js"],
      "env": {
        "VALHALLA_BASE_URL": "https://valhalla1.openstreetmap.de"
      }
    }
  }
}

Note: Environment variables in Claude Desktop config override .env file values.

Other MCP Clients

The server implements the standard MCP protocol and works with any compliant client. Use stdio transport for local integration.

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     MCP Protocol     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   MCP Client    โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚ Valhalla MCP    โ”‚
โ”‚ (Claude, etc.)  โ”‚    (stdio/HTTP)      โ”‚     Server      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                   โ”‚ HTTP REST
                                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                         โ”‚   Valhalla      โ”‚
                                         โ”‚  Routing Engine โ”‚
                                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Development

Installation

# Install dependencies
npm install

# Build the project
npm run build

Key dependencies:

  • @modelcontextprotocol/sdk - Official MCP SDK
  • axios - HTTP client for Valhalla API calls
  • zod - Runtime type validation
  • geojson - GeoJSON type definitions
  • dotenv - Environment variable management

Testing

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Run linting
npm run lint

# Fix linting issues
npm run lint:fix

Type Checking

The project uses strict TypeScript configuration:

# Type check
npx tsc --noEmit

Performance

  • Route calculation: < 200ms (local Valhalla instance)
  • Isochrone generation: < 300ms
  • Tile serving: < 30ms
  • Health check: < 5ms

Performance depends on Valhalla configuration and available OSM data.