Use this skill when the user pastes a Motion invite URL (contains /invite/ or /agent/), asks to "edit a Motion document", "connect to Motion", "collaborate o...
---
name: motion-agent
description: >
Use this skill when the user pastes a Motion invite URL (contains /invite/ or /agent/),
asks to "edit a Motion document", "connect to Motion", "collaborate on a document",
"write to Motion", or provides a document_id/agent_token/invite_token for real-time editing.
Also triggers on "Motion MCP", "review suggestions", "leave a comment on the doc",
"export the document", "save a version", "list pages", or "create a page".
---
# Motion Document Agent
You are a real-time collaborative document editor. Your edits appear live in the user's
browser. You appear in the presence bar alongside human collaborators. Other users may be
viewing and editing the same document simultaneously.
By default, your edits are wrapped in **suggestion marks** so humans can review and
accept/reject them before they become permanent. You can also operate in direct mode.
## Authentication
There are two auth methods:
### Agent token (preferred)
Workspace admins generate **agent tokens** from Settings > Agent tokens. Each token grants
full access to all documents in the workspace. The token is a 64-character hex string.
```bash
curl -X POST https://motion-mcp-server.fly.dev/sessions \
-H "Content-Type: application/json" \
-d '{"agent_token": "{TOKEN}", "agent_name": "Claude"}'
```
### Invite token (legacy)
Extract from an invite URL: `https://{APP_HOST}/invite/{INVITE_TOKEN}/{DOCUMENT_ID}`
```bash
curl -X POST https://motion-mcp-server.fly.dev/sessions \
-H "Content-Type: application/json" \
-d '{"invite_token": "{INVITE_TOKEN}", "document_id": "{DOCUMENT_ID}", "agent_name": "Claude"}'
```
## Connection
### Workspace-first flow (recommended with agent tokens)
Create a session without a document — browse, create, then connect:
```bash
# 1. Create workspace-only session
curl -X POST $BASE/sessions \
-H "Content-Type: application/json" \
-d '{"agent_token": "{TOKEN}", "agent_name": "Claude"}'
# 2. List pages, create pages, manage folders — all without a document
# 3. Connect to a document when ready
curl -X POST $BASE/sessions/:id/connect \
-H "Content-Type: application/json" \
-d '{"document_id": "{PAGE_ID}"}'
# 4. Or create a new page and connect in one step
curl -X POST $BASE/sessions/:id/pages \
-H "Content-Type: application/json" \
-d '{"title": "My Doc", "auto_connect": true}'
```
### Direct document session
If you know which document to edit, connect immediately:
```bash
curl -X POST $BASE/sessions \
-H "Content-Type: application/json" \
-d '{"agent_token": "{TOKEN}", "document_id": "{PAGE_ID}", "agent_name": "Claude"}'
```
### Switch documents
Switch to a different document within the same session (workspace boundary enforced):
```bash
curl -X POST $BASE/sessions/:id/connect \
-H "Content-Type: application/json" \
-d '{"document_id": "{ANOTHER_PAGE_ID}"}'
```
### Disconnect when done
```bash
curl -X DELETE $BASE/sessions/:id
```
## Security Model
- **Agent tokens** grant workspace-wide access — all documents, folders, comments, versions
- Agents can only access documents within their authorized workspace
- `switch_document` and `/connect` validate that the target document belongs to the workspace
- All page/folder mutations are workspace-scoped at the database level
- Tokens can be revoked by workspace admins at any time
## Core Editing Workflow
1. **Read first** — call `GET /sessions/:id/document` to get all blocks with stable IDs
2. **Edit by block ID** — always use block IDs (UUIDs), never array indexes. IDs persist across concurrent edits.
3. **Use format_text_by_match** for formatting — specify the text string, not character offsets
4. **Re-read after edits** if you need to continue editing or verify changes
5. **Disconnect** when done
## Suggestion Mode
Agents default to **suggestion mode**: edits appear as green underlines (additions) or
strikethroughs (deletions) that humans can accept or reject.
All edit endpoints (`insert`, `update`, `replace`, `delete`, `find-and-replace`) accept an
optional `"mode"` field:
- `"suggest"` (default) — wraps edits in suggestion marks for human review
- `"direct"` — applies edits immediately without suggestion marks
You can also:
- **List suggestions**: see all pending suggestions in the document
- **Accept/reject**: review another agent's suggestions
- **Bulk operations**: accept-all or reject-all
## Capabilities
### Page & Folder Management (workspace-level — no document connection needed)
List all workspace pages and folders. Create, rename, delete, restore pages. Create,
rename, delete folders. Move pages between folders and positions. These work even
without a document connection.
For endpoint details: read `references/api-reference.md` (Page Management and Folder sections)
### Document Editing (requires document connection)
Read, insert, update, delete, move blocks. Apply formatting (bold, italic, links, etc.).
Find and replace text. Full ProseMirror JSON support for rich content.
For endpoint details: read `references/api-reference.md` (Document Editing section)
For block/mark JSON format: read `references/block-format-reference.md`
### Comments (requires document connection)
Read all comment threads on a page. Create new threads, reply to existing ones,
resolve threads when discussion is complete, reopen resolved threads.
For endpoint details: read `references/api-reference.md` (Comments section)
### Version History (requires document connection)
List saved versions. Save a named version snapshot before making large changes.
Useful for checkpointing your work.
For endpoint details: read `references/api-reference.md` (Versions section)
### Export (requires document connection)
Export the current document as Markdown or HTML. Returns content as text.
For endpoint details: read `references/api-reference.md` (Export section)
### Suggestion Review (requires document connection)
List all pending suggestions. Accept or reject individual suggestions by ID.
Bulk accept-all or reject-all.
For endpoint details: read `references/api-reference.md` (Suggestions section)
## Quick Reference: Key Endpoints
### Workspace-level (no document needed)
| Action | Method | Path |
|--------|--------|------|
| Create session | POST | `/sessions` |
| Connect to document | POST | `/sessions/:id/connect` |
| List pages | GET | `/sessions/:id/pages` |
| Create page | POST | `/sessions/:id/pages` |
| Create page + connect | POST | `/sessions/:id/pages` (with `auto_connect: true`) |
| Rename page | PATCH | `/sessions/:id/pages/:pid` |
| Delete page | DELETE | `/sessions/:id/pages/:pid` |
| Restore page | POST | `/sessions/:id/pages/:pid/restore` |
| Move page | POST | `/sessions/:id/pages/move` |
| List folders | GET | `/sessions/:id/folders` |
| Create folder | POST | `/sessions/:id/folders` |
| Rename folder | PATCH | `/sessions/:id/folders/:fid` |
| Delete folder | DELETE | `/sessions/:id/folders/:fid` |
| Disconnect | DELETE | `/sessions/:id` |
### Document-level (requires document connection)
| Action | Method | Path |
|--------|--------|------|
| Read document | GET | `/sessions/:id/document` |
| Insert block | POST | `/sessions/:id/blocks` |
| Format text | POST | `/sessions/:id/blocks/:bid/format-by-match` |
| Delete block | DELETE | `/sessions/:id/blocks/:bid` |
| List comments | GET | `/sessions/:id/comments` |
| Create comment | POST | `/sessions/:id/comments` |
| Save version | POST | `/sessions/:id/versions` |
| Export | GET | `/sessions/:id/export?format=markdown` |
| List suggestions | GET | `/sessions/:id/suggestions` |
| Accept suggestion | POST | `/sessions/:id/suggestions/:sid/accept` |
For the complete API with request/response schemas: read `references/api-reference.md`
For common editing patterns and examples: read `references/examples.md`
## Tips
- Use an **agent token** for workspace-wide access — no need to deal with invite URLs
- Create a workspace-only session first, list pages, then connect to the one you need
- Use `auto_connect: true` when creating a page to start editing it immediately
- Always call `read_document` first to understand block structure and IDs
- Use `format-by-match` instead of offset-based formatting — it handles nested blocks
- When building a list, send the entire list as one `insert_block` call
- Save a version before making large destructive changes
- The agent identifies as `agent:Claude` in comments and suggestions
- If the same text appears multiple times, use the `occurrence` parameter
- Use `POST /sessions/:id/connect` to switch between documents without creating a new session
- Callout blocks support variants: info, warning, error, success
- Agents can only access documents within their authorized workspace — cross-workspace access is blocked
don't have the plugin yet? install it then click "run inline in claude" again.
restructured into implexa six-component format, extracted auth and runtime inputs, numbered all procedure steps with explicit inputs/outputs, added decision branches for auth method, edit mode, concurrent editing, and error handling, defined output contract with all response formats, and added outcome signal checklist for 11 user-facing confirmations.
use this skill when the user pastes a Motion invite URL (contains /invite/ or /agent/), asks to edit a Motion document, connect to Motion, collaborate on a document, write to Motion, or provides a document_id/agent_token/invite_token. also triggers on "Motion MCP", "review suggestions", "leave a comment on the doc", "export the document", "save a version", "list pages", or "create a page". this skill connects to Motion's real-time collaborative editor, where your edits appear live in the user's browser and show up in the presence bar alongside human collaborators. by default edits are wrapped in suggestion marks for human review, but you can operate in direct mode if authorized.
authentication (choose one):
agent_token: 64-character hex string. workspace admins generate this from Settings > Agent tokens. grants full workspace access. preferred method.invite_token + document_id: extract from invite URL pattern https://{APP_HOST}/invite/{INVITE_TOKEN}/{DOCUMENT_ID}. legacy method, document-scoped.session context:
agent_name: your identifier in the Motion workspace (e.g., "Claude"). appears in presence bar and comments.base_url: Motion MCP server endpoint (default: https://motion-mcp-server.fly.dev).external connection:
motion-mcp-server.fly.dev or your custom Motion deployment.optional runtime context:
document_id or page_id: target document UUID. if not provided, you create a workspace-only session first.mode: "suggest" (default, wraps edits in review marks) or "direct" (applies edits immediately).determine auth method. check if user provided agent_token or (invite_token + document_id).
create session. POST to /sessions with agent_token or invite_token.
{"agent_token": "{TOKEN}", "agent_name": "Claude"} or {"invite_token": "{TOKEN}", "document_id": "{DOC_ID}", "agent_name": "Claude"}.session_id (UUID), workspace_id, active connection status.session_id for all subsequent calls in this conversation.optional: browse workspace without document. if using agent_token and no specific document yet:
session_id.connect to document (if not already connected during session creation).
session_id, document_id./sessions/{session_id}/connect with {"document_id": "{PAGE_ID}"}.read document structure. GET /sessions/{session_id}/document.
session_id.choose edit operation based on user intent (insert, update, delete, format, find-and-replace, comment, version, export).
insert block (if adding content).
session_id, block type (paragraph, heading, list, callout, etc.), content, position (after_id or at_index)./sessions/{session_id}/blocks with block JSON.format text (if changing style, bold, italic, links, etc.).
session_id, block_id, text string to match, format marks (bold, italic, link, code, etc.)./sessions/{session_id}/blocks/{block_id}/format-by-match with {"match": "{TEXT}", "marks": [...], "mode": "suggest"}.delete block (if removing content).
session_id, block_id./sessions/{session_id}/blocks/{block_id}.find and replace (if making bulk text changes).
session_id, find string, replace string, optional occurrence number.re-read document after edits if you need to continue editing or verify changes took effect.
session_id./sessions/{session_id}/document.list comments (if reviewing discussion).
session_id./sessions/{session_id}/comments.create or reply to comment (if adding feedback).
session_id, optional block_id, comment text./sessions/{session_id}/comments with thread payload.list suggestions (if reviewing pending edits from other agents or humans).
session_id./sessions/{session_id}/suggestions.accept or reject suggestion (if reviewing).
session_id, suggestion_id, action (accept or reject)./sessions/{session_id}/suggestions/{suggestion_id}/accept or /reject.bulk suggestion operations (if clearing all pending).
session_id, bulk action (accept-all or reject-all).create new page (if user asks to create a document).
session_id, title, optional folder_id, optional auto_connect: true./sessions/{session_id}/pages with {"title": "...", "auto_connect": true}.rename page (if user asks to rename).
session_id, page_id, new title./sessions/{session_id}/pages/{page_id} with {"title": "..."}.list pages (if user asks to see all pages).
session_id./sessions/{session_id}/pages.move page (if user asks to reorganize).
session_id, page_id, new folder_id, new position./sessions/{session_id}/pages/move with move payload.delete page (if user asks to remove).
session_id, page_id./sessions/{session_id}/pages/{page_id}.restore page (if user asks to recover a deleted page).
session_id, page_id./sessions/{session_id}/pages/{page_id}/restore.save version (before making large changes).
session_id, optional version name./sessions/{session_id}/versions with {"name": "..."}.export document (if user asks to download or view as markdown/html).
session_id, format (markdown or html)./sessions/{session_id}/export?format=markdown.session_id./sessions/{session_id}.auth method branch:
document scope branch:
/sessions/{session_id}/connect (step 4) rather than creating a new session.edit mode branch:
"mode": "suggest" in all edit endpoints. edits appear as green underlines (additions) or strikethroughs (deletions)."mode": "direct". edits apply without suggestion marks.concurrent editing branch:
empty or error branch:
network/rate limit branch:
successful session creation:
successful document read:
successful edit operation:
successful comment operation:
successful page/folder operation:
successful version save:
successful export:
all responses:
the user knows the skill worked when:
session creation: you report back with a session_id and confirm "connected to Motion workspace {workspace_id}".
document read: you display the document structure in a readable format (outline of headings, blocks, etc.) and confirm "loaded X blocks from document {document_id}".
edits applied: you confirm "inserted {count} blocks", "formatted text in block {block_id}", or "deleted block {block_id}". if in suggest mode, you report "sent for review" and provide suggestion_id. if in direct mode, you say "applied immediately".
comments added: you confirm "comment posted as agent:Claude" and show the comment thread_id.
suggestions reviewed: you confirm "accepted {count} suggestions" or "rejected {count} suggestions" and show which blocks changed.
pages created or renamed: you confirm "created new page '{title}' with id {page_id}" or "renamed to '{new_title}'".
version saved: you confirm "saved version '{version_name}' at {timestamp}".
export complete: you return the markdown or html content and confirm "exported {character_count} characters".
document switch: you confirm "switched to document {new_document_id}" without creating a new session.
session ended: you confirm "disconnected from Motion. presence removed." when task is done.
visual confirmation in user's browser: user sees your agent name in the presence bar, sees suggestion marks appear (if suggest mode) or text updated live (if direct mode), and sees your comments or reactions in the discussion threads.