feat(mcp): add live collaboration demo#3835
Conversation
…cked changes
Add `superdoc_attach` so an MCP client can join a live SuperDoc Yjs
collaboration room over WebSocket (openRoom + WebsocketProvider, awaiting
initial sync) instead of only round-tripping a local .docx. The returned
session_id works with every existing tool. The motivating use case is
agent-assisted review: suggesting tracked redlines into a document a human has
open, attributed to a named reviewer, for accept/reject.
Tracked-change attribution: `superdoc_attach` accepts an optional
user ({ id, name, email }) threaded through openRoom into buildAttachEditor's
headless Editor config. Without a configured user, forceTrackChanges rejects
tracked edits, so suggested edits over an attach could not be attributed. The
file-open path already sets a default user; this brings the attach path to
parity, scoped to a caller-supplied identity.
Collab-aware save export: a joiner editor is built with no docx source, so
converter.convertedXml carried none of the base OOXML parts that
Editor.exportDocx dereferences. The deref threw and (via exportDocx's catch)
surfaced as "not binary (got undefined)". buildAttachEditor now seeds the
blank-docx template via Editor.loadXmlData so export has valid scaffolding;
Yjs still drives the body (the initial ProseMirror doc is seeded from `content`
only when no ydoc is present). save() rejects room saves without an explicit
output path.
Sync-wait robustness: the initial-sync wait delegates to the codebase's
canonical onCollaborationProviderSynced helper instead of a bespoke on('sync')
wait. The helper pre-checks an already-synced provider, listens to both
sync(boolean) and the no-arg synced event, and re-checks after wiring to close
the register-after-sync race. The default WebsocketProvider was already safe
(its sync(true) fires strictly async from websocket.onmessage), but the
createProvider seam admits alternate providers — pooled/already-synced, or
synced-only emitters — that the bespoke wait would hang on until a spurious
timeout. Post-sync editor/adapter construction is now wrapped so a throw there
destroys the provider before rethrowing, rather than leaking a live socket, its
resync timers, and a process exit handler (this applies to the default provider
too). The attach error path also reports non-Error throws as their string form
instead of "undefined".
Tests: protocol.test.ts now covers superdoc_attach in the tool-list,
action-enum, and session_id assertions (like superdoc_open, it creates a
session rather than consuming one). New collab-export.test.ts asserts a binary
PK-zip round-trip (word/document.xml + styles.xml + document.xml.rels) from a
collab-joiner editor, and collab-attach-user.test.ts asserts the tracked-change
user is configured when supplied and left unset otherwise. collab-attach.test.ts
is reshaped to the repo's provider-stub idiom (inert on(), explicit emit,
synced/isSynced fields) and adds already-synced and synced-only sync cases, so
the suite exercises the sync contract rather than a single auto-emitted edge.
Adds yjs, y-websocket, and ws dependencies.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…on-demo # Conflicts: # apps/mcp/package.json # apps/mcp/src/server.ts # apps/mcp/src/tools/index.ts # pnpm-lock.yaml
Code Review by Qodo
1.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d103feac7d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Code Review by Qodo
1.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fcb4dde16e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Code review by qodo was updated up to the latest commit 961697c |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 961697ca31
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
@caio-pizzol FYI https://github.com/qodo-ai/qodo-cover is no longer maintained:
|
What changed
Adds a standalone local demo where Codex or Claude Code can edit a DOCX through MCP and the changes show up live in SuperDoc.
It includes the browser client, Yjs room server, a demo-only HTTP MCP host, and the tests needed to cover the full loop.
Why a new MCP host
We spun up a small, demo-only HTTP host because the PR that adds live updates (#3569) has not merged yet. This lets us exercise the browser-to-MCP flow now while keeping the published stdio server untouched.
This PR currently includes the commits from #3569 because GitHub cannot use that PR's fork branch as the base here. Once #3569 lands, we can rebase this branch onto
mainand the diff will shrink to just the demo and its HTTP transport.This is a localhost-only demo. It does not include an LLM or require a model API key.
Visual changes
output-1440p-30fps-1.2x.mp4
Test
make test