matrix

Pack: openrouteservice · Endpoint: https://gateway.pipeworx.io/openrouteservice/mcp

“Distance matrix between locations” / “all-to-all travel times” / “N×M routing grid” / “drive / walk / bike times between [list]” — N×M distance and duration matrix between many points via OpenStreetMap routing. Use for traveling-salesman setup, multi-stop optimization, nearest-warehouse, fleet dispatch. Profile-aware (car / truck / bike / foot / wheelchair).

Parameters

NameTypeRequiredDescription
locationsarrayyes
itemsarrayno
itemsnumberno
profilestringno
itemsnumberno
sourcesarraynoWhich locations to route FROM, as 0-based indices into that array — e.g. [0] means the first location. NOT coordinates. Omit to use every location.
itemsnumberno
destinationsarraynoWhich locations to route TO, as 0-based indices into that array — e.g. [1,2]. NOT coordinates. Omit to use every location.
itemsnumberno
metricsarrayno[“duration”,“distance”]
itemsstringno

Example call

Arguments

{
  "locations": [
    [
      8.681495,
      49.41461
    ],
    [
      8.687872,
      49.420318
    ],
    [
      8.675444,
      49.418892
    ]
  ],
  "profile": "driving-car",
  "metrics": [
    "duration",
    "distance"
  ]
}

curl

curl -X POST https://gateway.pipeworx.io/openrouteservice/mcp \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"matrix","arguments":{"locations":[[8.681495,49.41461],[8.687872,49.420318],[8.675444,49.418892]],"profile":"driving-car","metrics":["duration","distance"]}}}'

TypeScript (@pipeworx/sdk)

import { Pipeworx } from '@pipeworx/sdk';
const pipeworx = new Pipeworx();

const result = await pipeworx.call('matrix', {
  "locations": [
    [
      8.681495,
      49.41461
    ],
    [
      8.687872,
      49.420318
    ],
    [
      8.675444,
      49.418892
    ]
  ],
  "profile": "driving-car",
  "metrics": [
    "duration",
    "distance"
  ]
});

More examples

{
  "locations": [
    [
      8.681495,
      49.41461
    ],
    [
      8.686507,
      49.41943
    ],
    [
      8.687872,
      49.420318
    ]
  ],
  "profile": "driving-car",
  "sources": [
    0
  ],
  "destinations": [
    1,
    2
  ]
}

Response shape

Always returns: sources, destinations, metadata

FieldTypeDescription
durationsarraySeconds, sources × destinations
distancesarrayMeters; only when metrics includes “distance”
sourcesarray
destinationsarray
metadataobject
Full JSON Schema
{
  "type": "object",
  "description": "Travel-time / distance matrix. `durations` and `distances` each appear only when the corresponding entry is in `metrics` (durations is the default), so neither is guaranteed.",
  "properties": {
    "durations": {
      "type": "array",
      "items": {
        "type": "array",
        "items": {
          "type": [
            "number",
            "null"
          ]
        }
      },
      "description": "Seconds, sources × destinations"
    },
    "distances": {
      "type": "array",
      "items": {
        "type": "array",
        "items": {
          "type": [
            "number",
            "null"
          ]
        }
      },
      "description": "Meters; only when metrics includes \"distance\""
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "location": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "[lon, lat] snapped to the road network"
          },
          "snapped_distance": {
            "type": [
              "number",
              "null"
            ]
          }
        }
      }
    },
    "destinations": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "location": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "[lon, lat] snapped to the road network"
          },
          "snapped_distance": {
            "type": [
              "number",
              "null"
            ]
          }
        }
      }
    },
    "metadata": {
      "type": "object",
      "properties": {
        "attribution": {
          "type": "string"
        },
        "service": {
          "type": "string"
        },
        "timestamp": {
          "type": [
            "number",
            "null"
          ]
        },
        "query": {
          "type": "object",
          "description": "Echo of the request"
        },
        "engine": {
          "type": "object",
          "properties": {
            "version": {
              "type": "string"
            },
            "build_date": {
              "type": "string"
            },
            "graph_date": {
              "type": "string"
            },
            "osm_date": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "required": [
    "sources",
    "destinations",
    "metadata"
  ]
}

Connect

Add this to your MCP client config, or use one-click install buttons:

{
  "mcpServers": {
    "openrouteservice": {
      "url": "https://gateway.pipeworx.io/openrouteservice/mcp"
    }
  }
}

See Getting Started for client-specific install steps.

Regenerated from source · build August 21, 2026