Principle:8beeeaaat Touchdesigner mcp Schema Driven Request Routing
| Knowledge Sources | |
|---|---|
| Domains | Request_Routing, OpenAPI |
| Last Updated | 2026-10-28 00:00 GMT |
Overview
A routing strategy where the set of valid HTTP routes, their path patterns, and their handler bindings are derived from an OpenAPI schema's `operationId` rather than hand-coded route tables.
Description
In a schema-driven router, the OpenAPI specification is the single source of truth for the route table. At initialization, the router extracts RouteDefinition objects (method, path pattern, operationId, parameters) from the schema's `paths` section. Handlers are registered against `operationId` strings — not raw paths — so the binding is decoupled from the URL shape. Incoming requests are matched in two passes: first an exact string match on (method, path), then a parameterized pattern match that splits on `/` and captures `{param}` segments. A greedy last-segment rule lets trailing slashes in path parameters (common for TouchDesigner node paths like `/project1/geo1/circle1`) be captured intact. This approach eliminates route-table drift: changing the OpenAPI spec and regenerating automatically updates both the routes and the handler stubs.
Usage
Use this principle when a Python web framework runs inside a constrained runtime (like a TouchDesigner WebServer DAT) and the API surface is already defined in OpenAPI, so the router and handlers stay in sync with zero hand-written routing code.
Theoretical Basis
# Abstract algorithm (NOT real implementation)
routes = [Route(method, path, operationId) for path, ops in schema["paths"] for method, ops in ops]
def route_request(method, path, query, body):
match = match_route(method, path, routes) # exact, then parametric
if not match:
return error(NOT_FOUND)
handler = handlers[match.route.operationId]
params = {**match.path_params, **query}
if method in (POST, PUT, PATCH) and body:
params["body"] = body
return handler(**params)
Key properties:
- operationId as dispatch key: handler registration is path-agnostic.
- Two-pass matching: exact match first (fast path), then parameterized (slow path).
- Greedy last segment: `{nodePath}` captures `/`-delimited trailing segments.