From d3c174d9b09f3c27dc9fcc38ea029a3a8b2d8352 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Sat, 28 Mar 2026 18:07:49 -0700 Subject: [PATCH] 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) --- main.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 2b99b4e..6fb4918 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "log" "net" "net/http" + "os" "git.wntrmute.dev/kyle/goutils/config" "git.wntrmute.dev/kyle/goutils/die" @@ -29,10 +30,13 @@ func main() { srv := &server{db: db} http.Handle("/", srv) - addr := net.JoinHostPort( - config.Get("HTTP_ADDR"), - config.GetDefault("HTTP_PORT", "8000"), - ) + // $PORT is set by the MCP agent for containers with route declarations. + // It takes precedence over config, matching the mcdsl convention. + port := os.Getenv("PORT") + if port == "" { + port = config.GetDefault("HTTP_PORT", "8000") + } + addr := net.JoinHostPort(config.Get("HTTP_ADDR"), port) log.Print("listening on ", addr) log.Fatal(http.ListenAndServe(addr, nil)) }