@superdoc/mcp 0.18.0-next.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # @superdoc/mcp
2
+
3
+ MCP server for SuperDoc. Lets AI agents open, read, edit, and save `.docx` files through the [Model Context Protocol](https://modelcontextprotocol.io).
4
+
5
+ Works with Claude Code, Claude Desktop, Cursor, Windsurf, and any MCP-compatible client.
6
+
7
+ ## Quick start
8
+
9
+ ```bash
10
+ npx @superdoc/mcp
11
+ ```
12
+
13
+ The server runs locally over stdio as a subprocess. You don't run it directly; your MCP client spawns it.
14
+
15
+ ## Setup
16
+
17
+ ### Claude Code
18
+
19
+ ```bash
20
+ claude mcp add superdoc -- npx @superdoc/mcp
21
+ ```
22
+
23
+ ### Claude Desktop
24
+
25
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
26
+
27
+ ```json
28
+ {
29
+ "mcpServers": {
30
+ "superdoc": {
31
+ "command": "npx",
32
+ "args": ["@superdoc/mcp"]
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ### Cursor
39
+
40
+ Add to `~/.cursor/mcp.json`:
41
+
42
+ ```json
43
+ {
44
+ "mcpServers": {
45
+ "superdoc": {
46
+ "command": "npx",
47
+ "args": ["@superdoc/mcp"]
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### Windsurf
54
+
55
+ Add to `~/.codeium/windsurf/mcp_config.json`:
56
+
57
+ ```json
58
+ {
59
+ "mcpServers": {
60
+ "superdoc": {
61
+ "command": "npx",
62
+ "args": ["@superdoc/mcp"]
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ ## Tools
69
+
70
+ Three lifecycle tools are always registered. The editing surface depends on `MCP_PRESET`:
71
+
72
+ | `MCP_PRESET` | Tools |
73
+ | --- | --- |
74
+ | `legacy` (default) | 13: 3 lifecycle + 10 grouped intent tools |
75
+ | `core` | 5: 3 lifecycle + `superdoc_inspect` and `superdoc_perform_action` |
76
+
77
+ All tools except `superdoc_open` take a `session_id` from `superdoc_open`.
78
+
79
+ Pass absolute paths. A relative path resolves against the server process's working directory, which your MCP client chooses. `superdoc_open` also opens a blank document when the path does not exist rather than reporting an error, so a wrong path presents as an empty file instead of a failure.
80
+
81
+ The server reads and writes any path it is given, with no restriction to a particular directory. Run it under a container, a dedicated user account, or an OS sandbox if you need to bound what it can reach.
82
+
83
+ `superdoc_save` has no overwrite guard: it resolves `out` and writes it, replacing any file already there, including the source. Point the agent at copies, and preflight the destination yourself when a workflow cannot tolerate that.
84
+
85
+ ### Lifecycle
86
+
87
+ | Tool | Description |
88
+ | --- | --- |
89
+ | `superdoc_open` | Open a `.docx` file by absolute path and get a `session_id`. A missing path opens a blank document |
90
+ | `superdoc_save` | Save the document to disk (original path or custom `out` path). Overwrites an existing file without warning |
91
+ | `superdoc_close` | Close the session and release memory |
92
+
93
+ ### Intent tools (`legacy` preset)
94
+
95
+ Most intent tools take an `action` argument selecting the operation within the group. `superdoc_search` is the exception: it takes `select`, not `action`.
96
+
97
+ | Tool | Covers |
98
+ | --- | --- |
99
+ | `superdoc_get_content` | Read the document as text, markdown, HTML, blocks, or metadata |
100
+ | `superdoc_search` | Find content and return stable targets. Takes `select`, not `action` |
101
+ | `superdoc_edit` | Insert, replace, and delete text, plus undo and redo |
102
+ | `superdoc_format` | Inline and paragraph formatting, styles, direction, and flow |
103
+ | `superdoc_create` | Create paragraphs, headings, and tables |
104
+ | `superdoc_list` | Create, convert, nest, split, merge, and renumber lists |
105
+ | `superdoc_table` | Table structure, content, and styling |
106
+ | `superdoc_comment` | Create, update, resolve, and read comment threads |
107
+ | `superdoc_track_changes` | List tracked changes and decide on them |
108
+ | `superdoc_mutations` | Preview and apply multi-step edits as one atomic batch |
109
+
110
+ Each tool's exact action list is generated from the Document API contract and changes with it. Read the advertised schema rather than a copy of it. Every tool's JSON Schema is served over MCP, and `getToolCatalog('legacy')` in `@superdoc/sdk` returns the same data.
111
+
112
+ ## Workflow
113
+
114
+ Every interaction follows the same pattern:
115
+
116
+ ```
117
+ open → read/search → edit → save → close
118
+ ```
119
+
120
+ 1. `superdoc_open` loads a document and returns a `session_id`
121
+ 2. `superdoc_get_content` reads the current document and `superdoc_search` finds stable handles or addresses
122
+ 3. Intent tools use `session_id` plus `action` to modify content
123
+ 4. `superdoc_save` writes changes to disk
124
+ 5. `superdoc_close` releases the session
125
+
126
+ Steps 2 and 3 name `legacy` tools. Under `MCP_PRESET=core` the shape is the same, but reads go through `superdoc_inspect` and edits through `superdoc_perform_action`. The lifecycle steps are identical under both presets.
127
+
128
+ ### Tracked changes
129
+
130
+ Actions that support tracked edits use the underlying Document API's `changeMode: "tracked"` option.
131
+
132
+ Reviewing them differs by preset. Under `legacy`, call `superdoc_track_changes`. Under `core` that tool does not exist: use `superdoc_perform_action` with `accept_tracked_changes` or `reject_tracked_changes`.
133
+
134
+ Not every action honors `changeMode`. Some ignore it and edit directly, and `move_range` accepts it and then fails without mutating, so check the action rather than assuming the argument applied.
135
+
136
+ Every session authors its changes as `MCP Server`; there is no way to configure that identity. Two MCP deployments editing the same document produce tracked changes a reviewer cannot tell apart. Use the SDK when attribution matters.
137
+
138
+ ## Development
139
+
140
+ ```bash
141
+ # Run locally
142
+ bun run src/index.ts
143
+
144
+ # Run tests
145
+ bun test
146
+
147
+ # Test with MCP Inspector
148
+ npx @modelcontextprotocol/inspector -- bun run src/index.ts
149
+ ```
150
+
151
+ ## License
152
+
153
+ See the [SuperDoc license](../../LICENSE).
Binary file