From 0726dd52ccba56c3c7dec1bb5e57e2201e7afd26 Mon Sep 17 00:00:00 2001 From: Molecule AI SDK-Dev Date: Fri, 24 Apr 2026 05:41:13 +0000 Subject: [PATCH] fix(mcp): read MOLECULE_API_URL env var for platform base URL MOLECULE_API_URL is the canonical platform env var per platform docs (docs/development/constraints-and-rules.md). The MCP server was reading MOLECULE_URL instead, causing it to default to localhost:8080 when used in environments that only set MOLECULE_API_URL. Added MOLECULE_API_URL as the highest-priority source, with legacy fallbacks (MOLECULE_URL, PLATFORM_URL) preserved for existing deployments. Co-Authored-By: Claude Sonnet 4.6 --- src/api.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/api.ts b/src/api.ts index 725873a..bcf378b 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,9 +1,16 @@ -// Prefer MOLECULE_URL (the canonical MCP env var), fall back to PLATFORM_URL -// (what the workspace runtime already injects for heartbeat/register), and -// only then to localhost:8080. Injecting MOLECULE_URL at container provision -// is handled by platform/internal/provisioner/provisioner.go; this fallback -// chain protects older containers and host-side users alike. Fixes #67. +// Read the platform API base URL from environment. +// Priority: MOLECULE_API_URL (canonical CLI/SDK env var, per platform docs) +// +// > Required environment variables: +// > MOLECULE_API_URL — Control plane API base URL +// > MOLECULE_RUNTIME_URL — Workspace runtime URL +// > (per docs/development/constraints-and-rules.md) +// +// Fallbacks exist for legacy callers (MOLECULE_URL, PLATFORM_URL) and +// localhost dev default. Injecting MOLECULE_API_URL at container provision +// is handled by platform/internal/provisioner/provisioner.go. export const PLATFORM_URL = + process.env.MOLECULE_API_URL || process.env.MOLECULE_URL || process.env.PLATFORM_URL || "http://localhost:8080";