Add route declarations and automatic port allocation to MCP agent
Service definitions can now declare routes per component instead of manual port mappings: [[components.routes]] name = "rest" port = 8443 mode = "l4" The agent allocates free host ports at deploy time and injects $PORT/$PORT_<NAME> env vars into containers. Backward compatible: components with old-style ports= work unchanged. Changes: - Proto: RouteSpec message, routes + env fields on ComponentSpec - Servicedef: RouteDef parsing and validation from TOML - Registry: component_routes table with host_port tracking - Runtime: Env field on ContainerSpec, -e flag in BuildRunArgs - Agent: PortAllocator (random 10000-60000, availability check), deploy wiring for route→port mapping and env injection Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -127,4 +127,19 @@ var migrations = []string{
|
||||
CREATE INDEX IF NOT EXISTS idx_events_component_time
|
||||
ON events(service, component, timestamp);
|
||||
`,
|
||||
|
||||
// Migration 2: component routes
|
||||
`
|
||||
CREATE TABLE IF NOT EXISTS component_routes (
|
||||
service TEXT NOT NULL,
|
||||
component TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
port INTEGER NOT NULL,
|
||||
mode TEXT NOT NULL DEFAULT 'l4',
|
||||
hostname TEXT NOT NULL DEFAULT '',
|
||||
host_port INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (service, component, name),
|
||||
FOREIGN KEY (service, component) REFERENCES components(service, name) ON DELETE CASCADE
|
||||
);
|
||||
`,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user