@radaros/transport package provides createAgentRouter() to generate a fully-featured Express router with endpoints for all your agents, teams, and workflows.
Installation
- npm
- pnpm
- yarn
Quick Start
Explicit wiring
Pass agents, teams, and workflows by name:Auto-discovery (zero-wiring)
Agents, teams, and workflows auto-register into a globalregistry when instantiated. The transport layer reads from this registry dynamically — entities created after the server starts are immediately available.
serve:
| Method | Path | Description |
|---|---|---|
| POST | /api/agents/:name/run | Run agent, return JSON response |
| POST | /api/agents/:name/stream | Stream response via Server-Sent Events |
| POST | /api/teams/:name/run | Run team |
| POST | /api/teams/:name/stream | Stream team via SSE |
| POST | /api/workflows/:name/run | Run workflow |
| GET | /api/agents | List registered agents with metadata |
| GET | /api/teams | List registered teams |
| GET | /api/workflows | List registered workflows |
| GET | /api/registry | List all registered names |
| GET | /api/tools | List available tools (when toolkits/toolLibrary configured) |
| GET | /api/tools/:name | Get single tool detail |
| GET | /api/admin/mcp | List MCP servers (when admin enabled) |
| POST | /api/admin/mcp | Add + connect an MCP server |
| GET | /api/admin/toolkits | List toolkit catalog |
RouterOptions
Map of named agents to expose. Each agent gets
/agents/:name/run and /agents/:name/stream endpoints.Map of named teams. Each gets
/teams/:name/run and /teams/:name/stream endpoints.Map of named workflows. Each gets
/workflows/:name/run endpoint.Mixed array of Agent, Team, and Workflow instances. Automatically classified and registered. An alternative to passing
agents, teams, and workflows separately.Controls live auto-discovery. Defaults to the global
registry (all auto-registered entities are available). Pass a custom Registry instance, or false to disable auto-discovery and only serve explicitly passed entities.Express middleware applied to all routes (e.g., auth, rate limiting).
Enable Swagger UI. See Swagger docs.
Enable multipart file upload for multi-modal input. See File Upload docs.
Toolkit instances whose tools are exposed via
GET /tools. Useful for UI tool discovery.Named tools exposed via
GET /tools. Merged with toolkit tools (explicit entries take precedence).Enable admin routes under
/admin for managing MCP servers and the toolkit catalog at runtime.
Pass true to use defaults, or provide a shared MCPManager instance and authentication middleware. See MCP Admin.In production, admin routes require authentication middleware — the server will throw an error at startup if none is provided.Request Format
JSON Request
With Session
With API Key
Response Format
Run Response
Structured Output Response
When an agent hasstructuredOutput configured, the structured field contains the parsed and validated JSON object:
Stream Response (SSE)
List Endpoints
When auto-discovery is enabled (default), the router exposes list endpoints with rich metadata:Full Example with Multiple Agents
Adding Custom Middleware
Error Handling
errorHandler middleware catches errors and returns structured JSON responses:
In production (
NODE_ENV=production), 5xx errors return a generic "Internal server error" message. Stack traces and internal details are never exposed to clients.Security
RadarOS includes several built-in security measures for the Express transport layer:Rate Limiting
createAgentRouter() includes a built-in IP-based rate limiter. The rate limiter’s internal state is periodically cleaned (every 60 seconds) to prevent unbounded memory growth from large numbers of unique IPs.
Admin Route Authentication
In production (NODE_ENV=production), mounting admin routes without authentication middleware will throw an error at startup — not just a warning. Always pass auth middleware when enabling admin routes:
Request Logging
TherequestLogger middleware sanitizes URL paths to prevent log injection. Control characters and newlines are stripped before logging.