mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 14:00:37 +00:00
A browser freezes background tabs, and a frozen Penpot tab cannot run the MCP plugin. A browser extension can wake such a tab, so let it connect to the MCP server as a wake agent. Define the messages the extension exchanges with the Penpot page and with the server: the page's session announcement, and the agent's initialization, session list, heartbeat and wake result, and the server's wake request. The server checks the agent messages with zod schemas. The plugin WebSocket endpoint accepts agents: a socket whose first message is initialize-wake-agent goes to a wake agent registry, which then handles its messages, keep-alive pings and close. It never becomes a plugin connection, so it is not listed as a Penpot session and does not displace the plugin connection of the same session. Agents go through the same user token checks as plugins. The registry keeps the sessions each agent can wake, sends wake requests and matches their results by request ID. A request fails when no agent holds the session, the agent disconnects or it does not answer in time. An agent may only wake sessions it registered under the same token, and a reconnecting agent replaces its previous connection.