Repository navigation
Done
Labels
Milestone
Description
Summary
MCP create_document unconditionally creates a public, world-editable document (isPrivate: false). Users asking Claude or ChatGPT to draft private notes cannot keep them Invite only without manually opening docs.plus and flipping access afterwards — and forcing public creation also widens indirect prompt-injection exfiltration risk.
Parent: #230. Related: #396 (Private chat mirror). Execution type: AFK.
Where
apps/hocuspocus.server/src/modules/document-content/infra/contentStore.ts(createDocumentWithContent)apps/hocuspocus.server/src/modules/mcp/infra/documentStore.ts(createOwnedDocument)apps/hocuspocus.server/src/modules/mcp/tools/documentTools.ts(create_document)apps/hocuspocus.server/src/lib/documentAccessMirror.ts(writeDocumentAccessMirror)apps/webapp/src/pages/oauth/consent.tsx:311docs/mcp/reference.mdandapps/hocuspocus.server/API.md
What to build
- Fail-closed Private mirror in
createDocumentWithContent(contentStore.ts):- Add
isPrivate?: boolean(defaultfalse) and an optional injectablewriteAccessMirror = writeDocumentAccessMirrortoCreateWithContentParams. - Refuse
params.isPrivate && !params.ownerId(an ownerless Private document locks everyone out, including its creator). - Mandatory fail-closed order (
#396,apps/hocuspocus.server/CLAUDE.md:189):- Mint
documentId. - Run
encodeContent(...)first so invalid Markdown writes zero rows anywhere. - When
params.isPrivate === true,await writeAccessMirror({ documentId, isPrivate: true, ownerId: params.ownerId })beforeprisma.$transaction. (public.document_accessdefaults to public when absent, so failing closed guarantees a Private document's chat is never publicly readable.) If the mirror fails (AppError(503)), abort and write zero Prisma rows. WhenisPrivateisfalse, do not call the mirror. - Pass
isPrivate: Boolean(params.isPrivate)intotx.documentMetadata.create.
- Mint
- Add
- Expose
privateoption increate_document(documentTools.ts):- Add
private: z.boolean().default(false)to the tool'sinputSchema. - On mirror
503, return a clear retryable refusal — never fall back to creating a public document. - Include
private: isPrivateinstructuredContentand state clearly in the reply text whether the document is public or Invite only. - Keep
openWorldHint: true(the default remains public).
- Add
- Update consent copy and docs:
- Update
apps/webapp/src/pages/oauth/consent.tsx:311(currently says "A new document is public, like any docs.plus document") using the domain glossary term Invite only in UI text (CONTEXT.md). - Document the
privateparameter increate_document's tool description,docs/mcp/reference.md, andapps/hocuspocus.server/API.md.
- Update
Out of scope
- Any MCP tool that changes an existing Private document to Public (explicitly rejected to prevent prompt-injection exfiltration).
- Adding people to Invite only access lists (Invite links and grants for Invite only documents (backend) #616).
Acceptance criteria
-
create_documentaccepts optionalprivate: boolean(defaultfalse) and returnsprivateinstructuredContent. - When
private: true,writeDocumentAccessMirrorruns and succeeds beforeprisma.$transactionwritesDocumentMetadatawithisPrivate: true. - If
writeDocumentAccessMirrorthrows503, no Prisma rows are created andcreate_documentreturns a clear refusal (never falls back to public). -
createDocumentWithContentrefusesisPrivate: truewhenownerIdis null. -
consent.tsx:311uses Invite only wording, anddocs/mcp/reference.md+API.mddocument theprivateparameter. - Tests pin the fail-closed mirror ordering (
private: truemirror failure leaves zero Prisma rows;private: falsedoes not call the mirror).
Verify
cd apps/hocuspocus.server && bun run typecheck && bun testcd apps/webapp && bun run typecheck
Blocked by
None — can start immediately.
Activity
HMarzban commentedon Nov 24, 2026
Implemented and verified on
main(b4ca4c9e3,2a82a9b9f):isPrivateaccess mirror write before$transactionincontentStore.ts, addedprivateparameter tocreate_document(matchinginputSchema/outputSchema/structuredContent), updated/oauth/consentscope copy to referenceInvite only, and syncedAPI.mdanddocs/mcp/reference.md.1,400pass) and webapp (655pass) test suites,typecheck, eslint, andcheck:agent-docs.