{
  "openapi": "3.1.0",
  "info": {
    "title": "Geoapify MCP Calculate Route Matrix Tool",
    "version": "0.1.0",
    "description": "OpenAPI specification for calling the Geoapify MCP calculate_route_matrix tool through the JSON-RPC endpoint."
  },
  "servers": [
    {
      "url": "https://api.geoapify.com/v1"
    }
  ],
  "tags": [
    {
      "name": "MCP Calculate Route Matrix",
      "description": "Call the Geoapify MCP calculate_route_matrix tool through the JSON-RPC endpoint."
    }
  ],
  "paths": {
    "/mcp": {
      "post": {
        "tags": [
          "MCP Calculate Route Matrix"
        ],
        "operationId": "callMcpCalculateRouteMatrix",
        "summary": "Call the calculate_route_matrix MCP tool",
        "description": "Call the calculate_route_matrix MCP tool with a JSON-RPC tools/call request.",
        "parameters": [
          {
            "name": "apiKey",
            "in": "query",
            "required": true,
            "description": "Geoapify API key.",
            "schema": {
              "type": "string"
            },
            "example": "YOUR_API_KEY"
          }
        ],
        "requestBody": {
          "description": "JSON-RPC request body for the calculate_route_matrix MCP tool.",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CalculateRouteMatrixToolCallRequest"
              },
              "example": {
                "jsonrpc": "2.0",
                "id": 1,
                "method": "tools/call",
                "params": {
                  "name": "calculate_route_matrix",
                  "arguments": {
                    "sources": [
                      {
                        "lat": 52.52,
                        "lon": 13.405
                      },
                      {
                        "lat": 52.51,
                        "lon": 13.39
                      }
                    ],
                    "mode": "drive"
                  }
                }
              },
              "examples": {
                "calculateRouteMatrix": {
                  "summary": "Calculate route matrix",
                  "description": "Calculate travel times and distances between source and target locations.",
                  "value": {
                    "jsonrpc": "2.0",
                    "id": 1,
                    "method": "tools/call",
                    "params": {
                      "name": "calculate_route_matrix",
                      "arguments": {
                        "sources": [
                          {
                            "lat": 52.52,
                            "lon": 13.405
                          },
                          {
                            "lat": 52.51,
                            "lon": 13.39
                          }
                        ],
                        "mode": "drive"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC response for the MCP tool call.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ToolCallResponse"
                    },
                    {
                      "$ref": "#/components/schemas/JsonRpcErrorResponse"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request payload or tool arguments."
          },
          "401": {
            "description": "Missing or invalid Geoapify API key."
          },
          "429": {
            "description": "Rate limit or quota exceeded."
          },
          "500": {
            "description": "Internal gateway error."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CalculateRouteMatrixToolCallRequest": {
        "type": "object",
        "description": "JSON-RPC tools/call request for the calculate_route_matrix MCP tool.",
        "additionalProperties": false,
        "required": [
          "jsonrpc",
          "id",
          "method",
          "params"
        ],
        "properties": {
          "jsonrpc": {
            "description": "JSON-RPC protocol version.",
            "const": "2.0"
          },
          "id": {
            "description": "Client-supplied JSON-RPC request id echoed in the response.",
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "method": {
            "description": "MCP method used to call a tool.",
            "const": "tools/call"
          },
          "params": {
            "description": "Tool call parameters for calculate_route_matrix.",
            "$ref": "#/components/schemas/CalculateRouteMatrixToolCallParams"
          }
        },
        "examples": [
          {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "calculate_route_matrix",
              "arguments": {
                "sources": [
                  {
                    "lat": 52.52,
                    "lon": 13.405
                  }
                ]
              }
            }
          }
        ],
        "x-geoapify-mcp-tool": "calculate_route_matrix",
        "x-geoapify-mcp-category": "Routing",
        "x-geoapify-mcp-input-schema": "#/components/schemas/CalculateRouteMatrixInput",
        "x-geoapify-mcp-output-schema": "#/components/schemas/CalculateRouteMatrixOutput"
      },
      "JsonRpcId": {
        "description": "JSON-RPC request identifier. The server echoes this value in the response.",
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "integer"
          },
          {
            "type": "null"
          }
        ]
      },
      "CalculateRouteMatrixToolCallParams": {
        "type": "object",
        "description": "MCP tools/call params for calculate_route_matrix.",
        "additionalProperties": false,
        "required": [
          "name",
          "arguments"
        ],
        "properties": {
          "name": {
            "description": "Registered MCP tool name.",
            "const": "calculate_route_matrix"
          },
          "arguments": {
            "description": "Arguments validated by the calculate_route_matrix input schema.",
            "$ref": "#/components/schemas/CalculateRouteMatrixInput"
          }
        }
      },
      "CalculateRouteMatrixInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "sources"
        ],
        "properties": {
          "sources": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "lat",
                "lon"
              ],
              "properties": {
                "lat": {
                  "type": "number",
                  "minimum": -90,
                  "maximum": 90,
                  "description": "Location latitude."
                },
                "lon": {
                  "type": "number",
                  "minimum": -180,
                  "maximum": 180,
                  "description": "Location longitude."
                }
              }
            },
            "description": "Matrix source locations. sources.length multiplied by targets.length must not exceed 1000."
          },
          "targets": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "lat",
                "lon"
              ],
              "properties": {
                "lat": {
                  "type": "number",
                  "minimum": -90,
                  "maximum": 90,
                  "description": "Location latitude."
                },
                "lon": {
                  "type": "number",
                  "minimum": -180,
                  "maximum": 180,
                  "description": "Location longitude."
                }
              }
            },
            "description": "Matrix target locations. Defaults to the source locations when omitted. sources.length multiplied by targets.length must not exceed 1000."
          },
          "mode": {
            "type": "string",
            "enum": [
              "drive",
              "truck",
              "light_truck",
              "medium_truck",
              "bus",
              "motorcycle",
              "scooter",
              "bicycle",
              "walk",
              "hike"
            ],
            "default": "drive",
            "description": "Travel or vehicle mode used to calculate the matrix."
          },
          "type": {
            "type": "string",
            "enum": [
              "balanced",
              "short",
              "less_maneuvers"
            ],
            "default": "balanced",
            "description": "Route optimization preference."
          },
          "traffic": {
            "type": "string",
            "enum": [
              "free_flow",
              "approximated"
            ],
            "default": "free_flow",
            "description": "Traffic model used for motorized routing."
          },
          "avoid": {
            "type": "array",
            "maxItems": 3,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "tolls",
                "highways",
                "ferries"
              ]
            },
            "description": "Route features to avoid. Supported values are \"tolls\", \"highways\", and \"ferries\"."
          },
          "units": {
            "type": "string",
            "enum": [
              "metric",
              "imperial"
            ],
            "default": "metric",
            "description": "Distance and speed units."
          }
        }
      },
      "CalculateRouteMatrixOutput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "sources",
          "targets",
          "sources_to_targets",
          "units",
          "distance_units",
          "time_units"
        ],
        "properties": {
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "lat",
                "lon"
              ],
              "properties": {
                "lat": {
                  "type": "number"
                },
                "lon": {
                  "type": "number"
                }
              }
            }
          },
          "targets": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "lat",
                "lon"
              ],
              "properties": {
                "lat": {
                  "type": "number"
                },
                "lon": {
                  "type": "number"
                }
              }
            }
          },
          "sources_to_targets": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": true,
                "properties": {
                  "distance": {
                    "type": "number"
                  },
                  "time": {
                    "type": "number"
                  }
                }
              }
            }
          },
          "units": {
            "type": "string",
            "enum": [
              "metric",
              "imperial"
            ]
          },
          "distance_units": {
            "type": "string",
            "enum": [
              "meters",
              "miles"
            ]
          },
          "time_units": {
            "type": "string",
            "enum": [
              "seconds"
            ]
          }
        }
      },
      "ToolCallResponse": {
        "type": "object",
        "description": "Successful JSON-RPC response for tools/call. Tool failures are returned with isError set to true.",
        "additionalProperties": false,
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "properties": {
          "jsonrpc": {
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "content",
              "isError"
            ],
            "properties": {
              "content": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "type",
                    "text"
                  ],
                  "properties": {
                    "type": {
                      "const": "text"
                    },
                    "text": {
                      "type": "string"
                    }
                  }
                }
              },
              "structuredContent": {
                "description": "Structured output returned by the calculate_route_matrix tool.",
                "$ref": "#/components/schemas/CalculateRouteMatrixOutput"
              },
              "isError": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "JsonRpcErrorResponse": {
        "type": "object",
        "description": "JSON-RPC error response returned for invalid requests or unknown methods.",
        "additionalProperties": false,
        "required": [
          "jsonrpc",
          "id",
          "error"
        ],
        "properties": {
          "jsonrpc": {
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "error": {
            "$ref": "#/components/schemas/JsonRpcError"
          }
        }
      },
      "JsonRpcError": {
        "type": "object",
        "description": "JSON-RPC error object.",
        "additionalProperties": false,
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          },
          "data": true
        }
      }
    }
  }
}
