Alonso Torres 3bd549a146
🐛 Stop MCP plugin tasks from throwing after the plugin closes (#13224)
Closing a plugin removes its globals (console, penpot, ...) while a task
of the MCP plugin may still be running. Under SES a removed global reads
as undefined, so the task failed at its next use of console or penpot,
and the catch handlers failed again on console.error. The rejection
reached the workspace as "Cannot read properties of undefined (reading
'error')", for tasks that succeeded as well as for failed ones.

A task that ends after the plugin closed now returns quietly. It cannot
answer: the UI iframe and its WebSocket are gone, and the MCP server
already fails the task when the plugin connection closes. The outer
catch logs through the console reference taken at load, so it cannot
throw.

Tests: PluginTaskRequest.test.ts runs TaskHandler.ts and plugin.ts in
one sandbox, removes the globals while a task waits, and checks that no
rejection escapes and no error is logged when the task ends in success or
failure. A task that fails while the plugin is open still sends its error
response.

Closes #12503

AI-assisted-by: claude-opus-5-5
2026-11-23 17:39:03 +01:00
..
2026-02-04 12:22:36 +01:00
2026-11-20 09:53:37 +01:00
2026-02-04 12:22:36 +01:00

Penpot MCP Plugin

This project contains a Penpot plugin that accompanies the Penpot MCP server. It connects to the MCP server via WebSocket, subsequently allowing the MCP server to execute tasks in Penpot using the Plugin API.

Setup

  1. Install Dependencies

     pnpm install
    
  2. Build the Project

     pnpm run build
    
  3. Start a Local Development Server

     pnpm run start
    

    This will start a local development server at http://localhost:4400.