From 94cb683e2667a249d8574aa2c62395562806c3c6 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 19 Aug 2026 12:58:03 +0000 Subject: [PATCH] :bug: Do not register developer tools in multi-user MCP mode Prevent developer tools from being exposed when the MCP server runs in multi-user mode. Keep them available for local devenv usage and document the mode restriction. Add regression coverage for the registration policy. Closes #11291 AI-assisted-by: gpt-5.6-luna --- mcp/README.md | 2 +- mcp/packages/server/src/PenpotMcpServer.test.ts | 15 +++++++++++++++ mcp/packages/server/src/PenpotMcpServer.ts | 9 ++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 mcp/packages/server/src/PenpotMcpServer.test.ts diff --git a/mcp/README.md b/mcp/README.md index 9b4ac77038..ac9fa86425 100644 --- a/mcp/README.md +++ b/mcp/README.md @@ -266,7 +266,7 @@ The Penpot MCP server can be configured using environment variables. | `PENPOT_MCP_WEBSOCKET_PORT` | Port for the WebSocket server (plugin connection) | `4402` | | `PENPOT_MCP_REPL_PORT` | Port for the REPL server (development/debugging) | `4403` | | `PENPOT_MCP_REMOTE_MODE` | Enable remote mode (disables file system access). Set to `true` to enable. | `false` | -| `PENPOT_MCP_DEVENV` | Enable Penpot development environment tools. Set to `true` to enable. | `false` | +| `PENPOT_MCP_DEVENV` | Enable Penpot development environment tools in local single-user mode. Set to `true` to enable. | `false` | | `PENPOT_MCP_TOOL_TIMEOUT_S` | Timeout, in seconds, for tool calls dispatched to the Penpot plugin | `120` | | `PENPOT_MCP_EXPORT_SHAPE_MAX_PARALLEL_REQUESTS` | Maximum number of parallel export shape requests (multi-user mode only). | `0` (no limit) | | `PENPOT_MCP_REDIS_URI` | Redis connection URI (e.g. `redis://host:6379`) enabling multi-instance horizontal scaling via Redis pub/sub task routing (multi-user mode only). When unset, the server runs in single-instance mode, requiring the plugin and MCP client to connect to the same instance. | (unset) | diff --git a/mcp/packages/server/src/PenpotMcpServer.test.ts b/mcp/packages/server/src/PenpotMcpServer.test.ts new file mode 100644 index 0000000000..060b00648a --- /dev/null +++ b/mcp/packages/server/src/PenpotMcpServer.test.ts @@ -0,0 +1,15 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import { shouldRegisterDeveloperTools } from "./PenpotMcpServer"; + +test("registers developer tools in local devenv mode", () => { + assert.equal(shouldRegisterDeveloperTools(true, false), true); +}); + +test("does not register developer tools in multi-user devenv mode", () => { + assert.equal(shouldRegisterDeveloperTools(true, true), false); +}); + +test("does not register developer tools when devenv mode is disabled", () => { + assert.equal(shouldRegisterDeveloperTools(false, false), false); +}); diff --git a/mcp/packages/server/src/PenpotMcpServer.ts b/mcp/packages/server/src/PenpotMcpServer.ts index bd992ec108..7344075172 100644 --- a/mcp/packages/server/src/PenpotMcpServer.ts +++ b/mcp/packages/server/src/PenpotMcpServer.ts @@ -50,6 +50,13 @@ class ToolInfo { ) {} } +/** + * Indicates whether developer tools may be registered for the current server mode. + */ +export function shouldRegisterDeveloperTools(isDevEnv: boolean, isMultiUserMode: boolean): boolean { + return isDevEnv && !isMultiUserMode; +} + export class PenpotMcpServer { /** * Timeout, in minutes, for idle sessions (Streamable HTTP and SSE) before they are automatically closed and removed. @@ -219,7 +226,7 @@ export class PenpotMcpServer { if (this.isFileSystemAccessEnabled()) { toolInstances.push(new ImportImageTool(this)); } - if (this.isDevEnv()) { + if (shouldRegisterDeveloperTools(this.isDevEnv(), this.isMultiUserMode())) { const nreplClient = new NreplClient(); toolInstances.push(new CljsReplTool(this, nreplClient)); toolInstances.push(new ImportPenpotFileTool(this, nreplClient));