From dc3c407ac5fc898198de0abd3aba312af30b09d8 Mon Sep 17 00:00:00 2001 From: Fernando Basello Date: Sat, 10 Jan 2026 20:41:16 -0300 Subject: [PATCH] feat(plugin): support running the MCP server on a remote host (not just localhost) --- penpot-plugin/src/main.ts | 4 +++- penpot-plugin/vite.config.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/penpot-plugin/src/main.ts b/penpot-plugin/src/main.ts index ce01d0a..fe28cd1 100644 --- a/penpot-plugin/src/main.ts +++ b/penpot-plugin/src/main.ts @@ -42,7 +42,9 @@ function connectToMcpServer(): void { } try { - ws = new WebSocket("ws://localhost:4402"); + // Use environment variable for MCP WebSocket URL, fallback to localhost for local development + const mcpWsUrl = import.meta.env.VITE_MCP_WS_URL || "ws://localhost:4402"; + ws = new WebSocket(mcpWsUrl); updateConnectionStatus("Connecting...", false); ws.onopen = () => { diff --git a/penpot-plugin/vite.config.ts b/penpot-plugin/vite.config.ts index adfe58b..3607bf2 100644 --- a/penpot-plugin/vite.config.ts +++ b/penpot-plugin/vite.config.ts @@ -26,5 +26,8 @@ export default defineConfig({ preview: { port: 4400, cors: true, + allowedHosts: process.env.VITE_ALLOWED_HOSTS + ? process.env.VITE_ALLOWED_HOSTS.split(",").map((h) => h.trim()) + : ["localhost", "0.0.0.0"], }, });