4 Commits

Author SHA1 Message Date
d3c174d9b0 Support $PORT env var for MCP agent port allocation
MCP agent sets $PORT for containers with route declarations.
$PORT takes precedence over HTTP_PORT from config, matching the mcdsl
convention used by all other platform services.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 18:07:49 -07:00
0ecea29413 remove $PORT, use config for listen port
MCP's pasta port mapping maps host:randomport to container:routeport.
The app must listen on the route's port (443) inside the container,
configured via HTTP_PORT in kls.conf.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 17:07:26 -07:00
06d469abaf restore $PORT support, remove explicit ports mapping
The MCP agent assigns its own host port and sets $PORT. The app must
listen on $PORT for mc-proxy to reach it. Explicit Podman port mappings
in the service definition are ignored by the agent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 17:01:29 -07:00
a94b92f7fd fix deployment: use config port, not $PORT
The MCP agent sets $PORT from the route, but the Podman port mapping
expects the container to listen on the config-defined port (3030).
Remove $PORT override to avoid the mismatch. Also restore ports,
network, and user fields in the service definition.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 16:57:33 -07:00
2 changed files with 6 additions and 12 deletions

View File

@@ -9,10 +9,6 @@ kls = "Dockerfile"
[[components]] [[components]]
name = "kls" name = "kls"
image = "mcr.svc.mcp.metacircular.net:8443/kls:v0.1.0" image = "mcr.svc.mcp.metacircular.net:8443/kls:v0.1.0"
network = "mcpnet"
user = "0:0"
restart = "unless-stopped"
ports = ["127.0.0.1:48000:8000"]
volumes = ["/srv/kls:/srv/kls"] volumes = ["/srv/kls:/srv/kls"]
cmd = ["-f", "/srv/kls/kls.conf"] cmd = ["-f", "/srv/kls/kls.conf"]

14
main.go
View File

@@ -30,15 +30,13 @@ func main() {
srv := &server{db: db} srv := &server{db: db}
http.Handle("/", srv) http.Handle("/", srv)
var addr string // $PORT is set by the MCP agent for containers with route declarations.
if port := os.Getenv("PORT"); port != "" { // It takes precedence over config, matching the mcdsl convention.
addr = ":" + port port := os.Getenv("PORT")
} else { if port == "" {
addr = net.JoinHostPort( port = config.GetDefault("HTTP_PORT", "8000")
config.Get("HTTP_ADDR"),
config.GetDefault("HTTP_PORT", "8000"),
)
} }
addr := net.JoinHostPort(config.Get("HTTP_ADDR"), port)
log.Print("listening on ", addr) log.Print("listening on ", addr)
log.Fatal(http.ListenAndServe(addr, nil)) log.Fatal(http.ListenAndServe(addr, nil))
} }