import { readFileSync } from 'node:fs'; const env = process.env; if (!/^[a-z0-9][a-z0-9-]{1,48}$/.test(env.MCP_OWNER ?? '')) throw new Error('MCP_OWNER must be an isolated product/project slug'); if (!/^[a-f0-9]{40}$/.test(env.SOURCE_REVISION ?? '')) throw new Error('Exact SOURCE_REVISION required'); if (!/^[a-z0-9.-]+\.[a-z]{2,}$/.test(env.MCP_HOST ?? '')) throw new Error('Product-owned MCP_HOST required'); if (!/^\S+@sha256:[a-f0-9]{64}$/.test(env.MCP_IMAGE ?? '')) throw new Error('MCP_IMAGE must be an immutable registry digest'); if ( !/^[a-zA-Z0-9][a-zA-Z0-9_.-]{1,100}$/.test(env.MCP_PRIVATE_NETWORK ?? '') || ['dokploy-network', 'host', 'bridge'].includes(env.MCP_PRIVATE_NETWORK) ) throw new Error('Existing product-private network required'); for (const name of ['MCP_DATABASE_SECRET_FILE', 'MCP_INTROSPECTION_SECRET_FILE']) if (!env[name]?.startsWith('/')) throw new Error(`Protected absolute ${name} reference required`); const source = readFileSync(new URL('./compose.yaml', import.meta.url), 'utf8'); if (/^\s*(?:privileged|network_mode|ports):|docker\.sock/m.test(source)) throw new Error('Unexpected broad exposure'); console.log( 'MCP deployment identity, immutable revision and product boundary validated; provider placement and access require live readback.', );