{
  "openapi": "3.1.1",
  "info": {
    "title": "Material Transport Scheduler API",
    "version": "1.0.0",
    "summary": "Schedule shared vehicles and inspect travel and waiting times.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://twinworkstransportscheduler.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Schedule shared vehicles and inspect travel and waiting times.",
        "description": "Plan material moves on a shared fleet using fixed travel times or a network of shared route segments.\n\nMethodology:\n- Sort requests by time and use listed order for ties.\n- Fixed-time mode assigns each request to the vehicle available earliest and includes empty return.\n- Network mode assigns the first idle vehicle, computes shortest travel-time paths to pickup and destination, and queues vehicles FIFO at capacity-limited two-way segments. Vehicles stay at their last delivery location.\n\nStandalone fleet estimate, separate from the Twinworks production model. Network paths minimize uncongested travel time and do not reroute dynamically; intersections, loading, charging and breakdowns are not modeled.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "twinworks_transport_scheduler",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TwinworksTransportSchedulerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Three requests and one cart",
                  "value": {
                    "trips": "Move A,0,60,30\nMove B,10,60,30\nMove C,20,45,20",
                    "vehicles": 1
                  }
                },
                "example2": {
                  "summary": "Two vehicles share a narrow aisle",
                  "value": {
                    "trips": "Move A,0,Depot,End\nMove B,0,Depot,End",
                    "vehicles": 2,
                    "network": "Depot,End,10,1",
                    "depot": "Depot"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TwinworksTransportSchedulerResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "TwinworksTransportSchedulerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "trips": {
            "title": "Trips: name, request time, loaded travel, empty return (seconds)",
            "description": "Without a network, use name, request, loaded time, empty return. With a network, use name, request, pickup location, destination. Times are seconds.",
            "type": "string",
            "maxLength": 60000,
            "default": "Move A,0,60,30\nMove B,10,60,30\nMove C,20,45,20"
          },
          "network": {
            "title": "Optional route network: location A, location B, travel seconds, capacity",
            "description": "One two-way shared segment per row. When supplied, requests use pickup and destination names and vehicles start at the depot.",
            "type": "string",
            "maxLength": 20000,
            "default": ""
          },
          "depot": {
            "title": "Initial depot location for network mode",
            "description": "All vehicles start here; after a delivery each stays at its destination.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "vehicles": {
            "title": "Number of identical vehicles",
            "type": "number",
            "minimum": 1,
            "maximum": 100,
            "default": 1
          }
        },
        "required": []
      },
      "TwinworksTransportSchedulerResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "schedule",
              "meanWait",
              "maxWait",
              "end",
              "utilization"
            ],
            "properties": {
              "schedule": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "name",
                    "request",
                    "vehicle",
                    "start",
                    "wait",
                    "delivered",
                    "free"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "request": {
                      "type": "number"
                    },
                    "vehicle": {
                      "type": "integer"
                    },
                    "start": {
                      "type": "number"
                    },
                    "wait": {
                      "type": "number"
                    },
                    "delivered": {
                      "type": "number"
                    },
                    "free": {
                      "type": "number"
                    },
                    "pickup": {
                      "type": "number"
                    },
                    "emptyPath": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "loadedPath": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "trafficWait": {
                      "type": "number"
                    }
                  }
                }
              },
              "meanWait": {
                "type": "number"
              },
              "maxWait": {
                "type": "number"
              },
              "end": {
                "type": "number"
              },
              "utilization": {
                "type": "number"
              },
              "network": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "segments",
                  "totalTrafficWait"
                ],
                "properties": {
                  "totalTrafficWait": {
                    "type": "number"
                  },
                  "segments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "a",
                        "b",
                        "seconds",
                        "capacity",
                        "maxBusy",
                        "traversals"
                      ],
                      "properties": {
                        "a": {
                          "type": "string"
                        },
                        "b": {
                          "type": "string"
                        },
                        "seconds": {
                          "type": "number"
                        },
                        "capacity": {
                          "type": "integer"
                        },
                        "maxBusy": {
                          "type": "integer"
                        },
                        "traversals": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}