From 0150cd0f7266a5db8fa85fecee9dac1e4e1a22d6 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 17 Aug 2026 12:12:56 -0400 Subject: [PATCH] fix: Reject personalOwnerId without publish in the MCP update tool Matches the REST validation instead of silently dropping the parameter. Co-Authored-By: Claude Fable 5 --- server/tools/documents.test.ts | 19 +++++++++++++++++++ server/tools/documents.ts | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/server/tools/documents.test.ts b/server/tools/documents.test.ts index d93c10db8f..f12dfbb07f 100644 --- a/server/tools/documents.test.ts +++ b/server/tools/documents.test.ts @@ -1047,6 +1047,25 @@ describe("update_document - personal", () => { expect(membership).not.toBeNull(); }); + it("rejects personalOwnerId without publish", async () => { + const { user, accessToken } = await buildOAuthUser(); + const document = await buildDraftDocument({ + teamId: user.teamId, + userId: user.id, + }); + + const res = await callMcpTool(server, accessToken, "update_document", { + id: document.id, + title: "Updated", + personalOwnerId: "me", + }); + expect(res?.result?.isError).toBe(true); + + const reloaded = await Document.unscoped().findByPk(document.id); + expect(reloaded!.personalOwnerId).toBeNull(); + expect(reloaded!.publishedAt).toBeNull(); + }); + it("rejects personalOwnerId on an already published document", async () => { const { user, accessToken } = await buildOAuthUser(); const collection = await buildCollection({ diff --git a/server/tools/documents.ts b/server/tools/documents.ts index 68b88ee0c7..cbf1efa428 100644 --- a/server/tools/documents.ts +++ b/server/tools/documents.ts @@ -713,6 +713,11 @@ export function documentTools(server: McpServer, scopes: string[]) { ); assertDocumentLocation({ ...input, personalOwnerId }); + if (personalOwnerId && !input.publish) { + throw ValidationError( + "publish is required when personalOwnerId is set" + ); + } let destination;