diff --git a/mcp/README.md b/mcp/README.md index eaf8b22081..539266ee15 100644 --- a/mcp/README.md +++ b/mcp/README.md @@ -258,7 +258,7 @@ The Penpot MCP server can be configured using environment variables. | Environment Variable | Description | Default | |------------------------------------|----------------------------------------------------------------------------|--------------| -| `PENPOT_MCP_SERVER_LISTEN_ADDRESS` | Address on which the MCP server listens (binds to) | `localhost` | +| `PENPOT_MCP_SERVER_HOST` | Address on which the MCP server listens (binds to) | `localhost` | | `PENPOT_MCP_SERVER_PORT` | Port for the HTTP/SSE server | `4401` | | `PENPOT_MCP_WEBSOCKET_PORT` | Port for the WebSocket server (plugin connection) | `4402` | | `PENPOT_MCP_REPL_PORT` | Port for the REPL server (development/debugging) | `4403` | @@ -276,7 +276,7 @@ The Penpot MCP server can be configured using environment variables. | Environment Variable | Description | Default | |-------------------------------------------|-----------------------------------------------------------------------------------------|--------------| -| `PENPOT_MCP_PLUGIN_SERVER_LISTEN_ADDRESS` | Address on which the plugin web server listens (single address or comma-separated list) | (local only) | +| `PENPOT_MCP_PLUGIN_SERVER_HOST` | Address on which the plugin web server listens (single address or comma-separated list) | (local only) | ## Beyond Local Execution @@ -303,4 +303,4 @@ you may set the following environment variables to configure the two servers * Auto-formatting: Use `pnpm run fmt` * Generating API type data: See [types-generator/README.md](types-generator/README.md) * Packaging and publishing: - - Create npm package: `bash scripts/pack` (sets version and then calls `npm pack`) \ No newline at end of file + - Create npm package: `bash scripts/pack` (sets version and then calls `npm pack`) diff --git a/mcp/packages/plugin/package.json b/mcp/packages/plugin/package.json index 0ccf276181..2aad3625f1 100644 --- a/mcp/packages/plugin/package.json +++ b/mcp/packages/plugin/package.json @@ -4,7 +4,7 @@ "version": "1.0.0", "type": "module", "scripts": { - "start": "vite build --watch --config vite.config.ts", + "start": "cross-env PENPOT_MCP_PLUGIN_SERVER_HOST=0.0.0.0 vite build --watch --config vite.config.ts", "start:multi-user": "pnpm run start", "build": "tsc && vite build --config vite.release.config.ts", "types:check": "tsc --noEmit", diff --git a/mcp/packages/plugin/vite.config.ts b/mcp/packages/plugin/vite.config.ts index 128a0f554f..fcc8e7e299 100644 --- a/mcp/packages/plugin/vite.config.ts +++ b/mcp/packages/plugin/vite.config.ts @@ -2,13 +2,14 @@ import { defineConfig } from "vite"; import livePreview from "vite-live-preview"; let WS_URI = process.env.WS_URI || "http://localhost:4402"; +let SERVER_HOST = process.env.PENPOT_MCP_PLUGIN_SERVER_HOST ?? "localhost"; console.log("Will define PENPOT_MCP_WEBSOCKET_URL as:", JSON.stringify(WS_URI)); export default defineConfig({ - base: "./", - plugins: [ - livePreview({ + base: "./", + plugins: [ + livePreview({ reload: true, config: { build: { @@ -29,7 +30,7 @@ export default defineConfig({ }, }, preview: { - host: "0.0.0.0", + host: SERVER_HOST, port: 4400, cors: true, allowedHosts: [], diff --git a/mcp/packages/server/src/PenpotMcpServer.ts b/mcp/packages/server/src/PenpotMcpServer.ts index 4cc08e43b3..ae95724a09 100644 --- a/mcp/packages/server/src/PenpotMcpServer.ts +++ b/mcp/packages/server/src/PenpotMcpServer.ts @@ -75,7 +75,7 @@ export class PenpotMcpServer { constructor(private isMultiUser: boolean = false) { // read port configuration from environment variables - this.host = process.env.PENPOT_MCP_SERVER_HOST ?? "0.0.0.0"; + this.host = process.env.PENPOT_MCP_SERVER_HOST ?? "localhost"; this.port = parseInt(process.env.PENPOT_MCP_SERVER_PORT ?? "4401", 10); this.webSocketPort = parseInt(process.env.PENPOT_MCP_WEBSOCKET_PORT ?? "4402", 10); this.replPort = parseInt(process.env.PENPOT_MCP_REPL_PORT ?? "4403", 10);