Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(mcp): let the app's answers carry documents above 10 MiB, document checkpoints not crossing over

EtienneLescotbee391d4e7c0
diff --git a/electron/mcp/app-channel.ts b/electron/mcp/app-channel.ts
index 8f612466e..eb166a333 100644
--- a/electron/mcp/app-channel.ts
+++ b/electron/mcp/app-channel.ts
@@ -52,6 +52,7 @@ const CONNECT_TIMEOUT_MS = 3_000;
// Above the editor's own 30 s for a snapshot plus 30 s for an apply.
const CALL_TIMEOUT_MS = 90_000;
const MAX_TOKEN_LINE_BYTES = 256;
+const MAX_ANSWER_BYTES = 256 * 1024 * 1024;
const LOST_MESSAGE =
"OpenScreen stopped answering during this call, so whether it took effect is unknown. Call getCurrentDocument with the same projectId to check before retrying.";
@@ -242,7 +243,9 @@ export async function connectToApp(
CONNECT_TIMEOUT_MS,
);
socket.write(`${found.token}\n`);
- await client.connect(new StdioServerTransport(socket, socket), { timeout: CONNECT_TIMEOUT_MS });
+ // Answers carry whole documents: well above the SDK's 10 MiB default.
+ const transport = new StdioServerTransport(socket, socket, { maxBufferSize: MAX_ANSWER_BYTES });
+ await client.connect(transport, { timeout: CONNECT_TIMEOUT_MS });
const { tools } = await client.listTools(undefined, { timeout: CONNECT_TIMEOUT_MS });
for (const tool of tools) connection.tools.add(tool.name);
return connection;
diff --git a/technical-documentation/architecture/mcp-server.md b/technical-documentation/architecture/mcp-server.md
index 5ff70a4b6..4c7130a2d 100644
--- a/technical-documentation/architecture/mcp-server.md
+++ b/technical-documentation/architecture/mcp-server.md
@@ -129,6 +129,7 @@ The stdio server (`openscreen mcp`, [`stdio-server.ts`](../../electron/mcp/stdio
- **Trust.** Every connection must first send the token from that file, or it is dropped. Node cannot set a named pipe's DACL, and the default one lets any user open it read-only; the token, in a file inside the user's profile, is what limits the channel to the current user. Any process of that user can connect, which grants nothing new: it could run `openscreen mcp` itself. So calls over the channel edit as `openscreen mcp` always did, whatever the in-app server's **MCP server** and **MCP edits** switches say: those guard the HTTP port, a door a web page or another tool could knock on.
- **Fallback.** With no app, or one that does not answer, the calls run in the CLI process on the files, as before. The project a live app's editor holds is then still refused (#1138): the app's `.open-in-editor.json` marker says so, and the refusal asks to retry, close the project, or restart or update OpenScreen.
- **Never twice.** A call the app received but did not answer within 90 s, or whose connection dropped, is not run again locally unless it is a read: the client is told the outcome is unknown and to re-read. The connection is dropped, so a hung app does not hold later calls.
+- **Checkpoints do not cross over.** One made while the app answered lives in the app and is gone once it quits; one made while it did not lives in the CLI process and is unknown to the app. Either way the restore says the checkpoint is unknown, and an edit to a closed project asks for a new one.
## Transport and security