@se-studio/contentful-cms 1.0.81 → 1.0.83

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.
Files changed (146) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/HOSTED.md +121 -0
  3. package/INSTALL.md +22 -5
  4. package/README.md +2 -0
  5. package/dist/bin/cms-edit.js +8 -143
  6. package/dist/bin/cms-edit.js.map +1 -1
  7. package/dist/cli/program.d.ts +9 -0
  8. package/dist/cli/program.d.ts.map +1 -0
  9. package/dist/cli/program.js +163 -0
  10. package/dist/cli/program.js.map +1 -0
  11. package/dist/cli/runner.d.ts +15 -0
  12. package/dist/cli/runner.d.ts.map +1 -0
  13. package/dist/cli/runner.js +94 -0
  14. package/dist/cli/runner.js.map +1 -0
  15. package/dist/commands/add.js +2 -2
  16. package/dist/commands/add.js.map +1 -1
  17. package/dist/commands/asset.js +5 -5
  18. package/dist/commands/asset.js.map +1 -1
  19. package/dist/commands/backup.js +1 -1
  20. package/dist/commands/backup.js.map +1 -1
  21. package/dist/commands/create-from-json.js +1 -1
  22. package/dist/commands/create-from-json.js.map +1 -1
  23. package/dist/commands/create.js +4 -4
  24. package/dist/commands/create.js.map +1 -1
  25. package/dist/commands/diff.js +2 -2
  26. package/dist/commands/diff.js.map +1 -1
  27. package/dist/commands/discard.js +4 -4
  28. package/dist/commands/discard.js.map +1 -1
  29. package/dist/commands/guide.d.ts +4 -0
  30. package/dist/commands/guide.d.ts.map +1 -0
  31. package/dist/commands/guide.js +18 -0
  32. package/dist/commands/guide.js.map +1 -0
  33. package/dist/commands/links.js +10 -10
  34. package/dist/commands/links.js.map +1 -1
  35. package/dist/commands/move.js +3 -3
  36. package/dist/commands/move.js.map +1 -1
  37. package/dist/commands/nav.js +3 -3
  38. package/dist/commands/nav.js.map +1 -1
  39. package/dist/commands/open.js +1 -1
  40. package/dist/commands/open.js.map +1 -1
  41. package/dist/commands/peek.d.ts.map +1 -1
  42. package/dist/commands/peek.js +8 -2
  43. package/dist/commands/peek.js.map +1 -1
  44. package/dist/commands/preview.js +1 -1
  45. package/dist/commands/preview.js.map +1 -1
  46. package/dist/commands/read.d.ts.map +1 -1
  47. package/dist/commands/read.js +97 -68
  48. package/dist/commands/read.js.map +1 -1
  49. package/dist/commands/remove.js +2 -2
  50. package/dist/commands/remove.js.map +1 -1
  51. package/dist/commands/revert.js +5 -5
  52. package/dist/commands/revert.js.map +1 -1
  53. package/dist/commands/rtf.js +11 -11
  54. package/dist/commands/rtf.js.map +1 -1
  55. package/dist/commands/run.js +8 -8
  56. package/dist/commands/run.js.map +1 -1
  57. package/dist/commands/save.js +3 -3
  58. package/dist/commands/save.js.map +1 -1
  59. package/dist/commands/screenshot.js +2 -2
  60. package/dist/commands/screenshot.js.map +1 -1
  61. package/dist/commands/set.js +7 -7
  62. package/dist/commands/set.js.map +1 -1
  63. package/dist/commands/snapshot.js +1 -1
  64. package/dist/commands/snapshot.js.map +1 -1
  65. package/dist/commands/version.d.ts +4 -0
  66. package/dist/commands/version.d.ts.map +1 -0
  67. package/dist/commands/version.js +17 -0
  68. package/dist/commands/version.js.map +1 -0
  69. package/dist/config/hosted.d.ts +28 -0
  70. package/dist/config/hosted.d.ts.map +1 -0
  71. package/dist/config/hosted.js +94 -0
  72. package/dist/config/hosted.js.map +1 -0
  73. package/dist/config/load.d.ts.map +1 -1
  74. package/dist/config/load.js +5 -0
  75. package/dist/config/load.js.map +1 -1
  76. package/dist/hosted/index.d.ts +13 -0
  77. package/dist/hosted/index.d.ts.map +1 -0
  78. package/dist/hosted/index.js +12 -0
  79. package/dist/hosted/index.js.map +1 -0
  80. package/dist/mcp/guide.d.ts +20 -0
  81. package/dist/mcp/guide.d.ts.map +1 -0
  82. package/dist/mcp/guide.js +91 -0
  83. package/dist/mcp/guide.js.map +1 -0
  84. package/dist/mcp/http-handler.d.ts +13 -0
  85. package/dist/mcp/http-handler.d.ts.map +1 -0
  86. package/dist/mcp/http-handler.js +28 -0
  87. package/dist/mcp/http-handler.js.map +1 -0
  88. package/dist/mcp/prompts/onboarding.d.ts +4 -0
  89. package/dist/mcp/prompts/onboarding.d.ts.map +1 -0
  90. package/dist/mcp/prompts/onboarding.js +77 -0
  91. package/dist/mcp/prompts/onboarding.js.map +1 -0
  92. package/dist/mcp/resources/guide.d.ts +4 -0
  93. package/dist/mcp/resources/guide.d.ts.map +1 -0
  94. package/dist/mcp/resources/guide.js +16 -0
  95. package/dist/mcp/resources/guide.js.map +1 -0
  96. package/dist/mcp/server.d.ts +13 -1
  97. package/dist/mcp/server.d.ts.map +1 -1
  98. package/dist/mcp/server.js +20 -92
  99. package/dist/mcp/server.js.map +1 -1
  100. package/dist/mcp/session-args.d.ts +5 -0
  101. package/dist/mcp/session-args.d.ts.map +1 -0
  102. package/dist/mcp/session-args.js +10 -0
  103. package/dist/mcp/session-args.js.map +1 -0
  104. package/dist/mcp/tools/cms-edit.d.ts +9 -0
  105. package/dist/mcp/tools/cms-edit.d.ts.map +1 -0
  106. package/dist/mcp/tools/cms-edit.js +62 -0
  107. package/dist/mcp/tools/cms-edit.js.map +1 -0
  108. package/dist/mcp/tools/help.d.ts +4 -0
  109. package/dist/mcp/tools/help.d.ts.map +1 -0
  110. package/dist/mcp/tools/help.js +22 -0
  111. package/dist/mcp/tools/help.js.map +1 -0
  112. package/dist/mcp/types.d.ts +2 -0
  113. package/dist/mcp/types.d.ts.map +1 -0
  114. package/dist/mcp/types.js +2 -0
  115. package/dist/mcp/types.js.map +1 -0
  116. package/dist/runtime/context.d.ts +19 -0
  117. package/dist/runtime/context.d.ts.map +1 -0
  118. package/dist/runtime/context.js +9 -0
  119. package/dist/runtime/context.js.map +1 -0
  120. package/dist/session/file-session-store.d.ts +10 -0
  121. package/dist/session/file-session-store.d.ts.map +1 -0
  122. package/dist/session/file-session-store.js +149 -0
  123. package/dist/session/file-session-store.js.map +1 -0
  124. package/dist/session/redis-session-store.d.ts +23 -0
  125. package/dist/session/redis-session-store.d.ts.map +1 -0
  126. package/dist/session/redis-session-store.js +133 -0
  127. package/dist/session/redis-session-store.js.map +1 -0
  128. package/dist/session/session-store.d.ts +19 -0
  129. package/dist/session/session-store.d.ts.map +1 -0
  130. package/dist/session/session-store.js +9 -0
  131. package/dist/session/session-store.js.map +1 -0
  132. package/dist/session/store.d.ts +5 -5
  133. package/dist/session/store.d.ts.map +1 -1
  134. package/dist/session/store.js +23 -75
  135. package/dist/session/store.js.map +1 -1
  136. package/dist/snapshot/render.d.ts.map +1 -1
  137. package/dist/snapshot/render.js +7 -0
  138. package/dist/snapshot/render.js.map +1 -1
  139. package/dist/version.d.ts +9 -0
  140. package/dist/version.d.ts.map +1 -0
  141. package/dist/version.js +19 -0
  142. package/dist/version.js.map +1 -0
  143. package/docs/FEATURE_REQUESTS_ARCHIVE.md +141 -0
  144. package/docs/FUNCTIONAL_SPEC.md +271 -0
  145. package/docs/mcp/hosted-guide.md +151 -0
  146. package/package.json +14 -6
@@ -0,0 +1,271 @@
1
+ # Functional Specification: cms-edit
2
+
3
+ ## 1. Purpose
4
+
5
+ `cms-edit` is a CLI tool and MCP server for reading and writing draft content in a Contentful CMS space. It is designed to be operated by an AI agent or a human via the command line. All write operations produce Contentful drafts; no publish, unpublish, archive, or delete operation is exposed.
6
+
7
+ ---
8
+
9
+ ## 2. Interfaces
10
+
11
+ **CLI binary (`cms-edit`)** — invoked with subcommands and arguments from a terminal or shell script.
12
+
13
+ **MCP server (`cms-edit-mcp`)** — exposes a single MCP tool `cms_edit` that accepts an array of CLI arguments and returns JSON output. Used by Claude (Desktop/Code) to call the tool as a native action.
14
+
15
+ ---
16
+
17
+ ## 3. Configuration
18
+
19
+ A project-level `.contentful-cms.json` file defines one or more Contentful spaces. Each space entry holds:
20
+
21
+ - `spaceId` — Contentful space identifier
22
+ - `environment` — Contentful environment name (e.g., `master`)
23
+ - `managementToken` — Contentful Management API token, expressed as an env var reference (e.g., `${CMS_EDIT_TOKEN_OM1}`)
24
+ - `defaultLocale` — locale string (e.g., `en-US`)
25
+ - `devBaseUrl` — local app URL used for screenshot capture
26
+
27
+ A `defaultSpace` key selects the active space when none is specified. The `--space` flag overrides per invocation.
28
+
29
+ **Environment variables:**
30
+
31
+ | Variable | Purpose |
32
+ |---|---|
33
+ | `CMS_EDIT_TOKEN_<SPACE>` | Management token per space |
34
+ | `CMS_EDIT_JSON=1` | Force JSON output mode globally |
35
+ | `CONTENTFUL_CMS_SESSION=<name>` | Select a named session for concurrent workflows |
36
+
37
+ ---
38
+
39
+ ## 4. Session Model
40
+
41
+ A session is the unit of work. It is created when content is opened and persists on the local filesystem until saved or discarded. Multiple named sessions can be active concurrently.
42
+
43
+ Each session holds:
44
+ - The loaded entry tree with assigned `@ref` labels (`@c0`, `@c1`, …)
45
+ - A change log (set of modified fields per entry)
46
+ - Entries queued for deletion (drafts unlinked during the session)
47
+
48
+ Commands within a session reference entries by their `@ref` label. The session is explicitly ended by `save` or `discard`.
49
+
50
+ ---
51
+
52
+ ## 5. Supported Contentful Entity Types
53
+
54
+ The tool operates on the following Contentful content types:
55
+
56
+ | Type | Discriminator field | Notes |
57
+ |---|---|---|
58
+ | Page | — | Top-level container; identified by `slug` |
59
+ | Article | — | Blog/editorial entry; identified by `slug` |
60
+ | Component | `componentType` | Inline content block (Hero, RichText, CTA, Card, …) |
61
+ | Collection | `collectionType` | Container with a `contents` array of child entries |
62
+ | ExternalComponent | `externalComponentType` | Embeds (data viz, research charts) |
63
+ | Template | — | Layout with `preContent`/`postContent` arrays |
64
+ | Navigation | — | Menu tree with nested `items`/`navigationItems` |
65
+ | Person | — | Author/team member |
66
+ | ArticleType | — | Article taxonomy tag |
67
+ | Tag | — | General taxonomy |
68
+ | Media | — | Wrapper entry around an asset |
69
+ | Asset | — | Image, PDF, or file (read-only; no upload capability) |
70
+
71
+ ---
72
+
73
+ ## 6. Entry Tree Resolution
74
+
75
+ When content is opened, the tool recursively fetches linked entries to build a tree:
76
+
77
+ - Content arrays: `topContent`, `content`, `bottomContent` (on pages/articles/templates), `contents` (on collections)
78
+ - Single-link fields: `template`, `articleType`, `author`, `menu`, `footer`
79
+ - Navigation trees: `items`, `navigationItems`
80
+ - Template layout: `preContent`, `postContent`
81
+
82
+ Each resolved entry is assigned a stable `@ref` label (`@c0` = the root, `@c1`, `@c2`, … for children in tree order). The tree is rebuilt on each `snapshot` call.
83
+
84
+ ---
85
+
86
+ ## 7. Command Reference
87
+
88
+ ### 7.1 Discovery and Navigation
89
+
90
+ | Command | Function |
91
+ |---|---|
92
+ | `open <slug>` | Load page/article/tag by slug into a session. Resolution order: page → article → articleType → tag. |
93
+ | `open <id> --id` | Load by Contentful entry ID |
94
+ | `peek <slug>` | Fetch and display content tree without creating a session |
95
+ | `snapshot` | Print the current session's entry tree with @refs, entry types, field labels, and publish status |
96
+ | `read <ref>` | Print all fields of an entry |
97
+ | `read <ref> <field>` | Print a specific field (rich text rendered as Markdown) |
98
+ | `search <query>` | Full-text search across entries; returns matching entries |
99
+ | `list --type <type>` | List all entries of a given content type |
100
+ | `sitemap` | List all pages with their slugs and publish status |
101
+ | `resolve <id>` | Resolve an entry or asset ID to its details |
102
+
103
+ ### 7.2 Session Management
104
+
105
+ | Command | Function |
106
+ |---|---|
107
+ | `diff` | Show all unsaved field changes across all modified entries in the session |
108
+ | `save` | Write all queued changes to Contentful as drafts; delete queued draft-only entries |
109
+ | `discard` | Clear all unsaved changes; end the session |
110
+ | `discard --all` | Clear all active sessions |
111
+
112
+ ### 7.3 Field Mutations
113
+
114
+ | Command | Function |
115
+ |---|---|
116
+ | `set <ref> <field> <value>` | Set a scalar field (string, boolean, number, date) |
117
+ | `set <ref> <field> <id> --link` | Set a single entry-link field |
118
+ | `set <ref> <field> @c1,@c2 --links` | Replace a content-array field with the given refs |
119
+ | `set <ref> <field> @c1,@c2 --links --append` | Append refs to an existing content array |
120
+ | `set <ref> <field> --file <path>` | Set a JSON/Object field from a local file |
121
+ | `set <ref> <field> --json '<json>'` | Set a JSON/Object field from an inline string |
122
+ | `set @c1:field="val" @c2:field="val" …` | Bulk set scalar fields across multiple entries in one command |
123
+ | `rtf <ref> <field> "<markdown>"` | Set a rich text field from Markdown |
124
+ | `rtf <ref> <field> --file <path>` | Set a rich text field from a Markdown file |
125
+ | `rtf <ref> <field> -` | Set a rich text field from stdin |
126
+ | `rtf replace <ref> <field> --find "X" --replace-plain "Y"` | Surgical per-text-node replacement within existing rich text (does not rewrite the entire field) |
127
+ | `rtf embed <ref> <field> <entry-id>` | Embed an entry block into an existing rich text field |
128
+ | `rtf embed <ref> <field> <asset-id> --asset` | Embed an asset block into an existing rich text field |
129
+ | `asset set <ref> <field> <asset-id>` | Set a visual/asset link field |
130
+
131
+ ### 7.4 Entry Creation
132
+
133
+ | Command | Function |
134
+ |---|---|
135
+ | `create page --slug /x --title "X"` | Create a new page entry and open it in a session |
136
+ | `create article --slug /x --title "X" --article-type-id <id>` | Create a new article entry and open it in a session |
137
+ | `create template --label "X"` | Create a new template entry |
138
+ | `create media --asset-id <id> --name "X"` | Create a Media wrapper entry around an existing asset |
139
+ | `create from-json --file <path>` | Bulk-create a page or article with all its components from a declarative JSON file |
140
+ | `add <entry-type> --content-type <ct>` | Create a new child entry of a given content type, link it into the current open entry's content array, and assign it a @ref |
141
+
142
+ ### 7.5 Entry Removal and Reordering
143
+
144
+ | Command | Function |
145
+ |---|---|
146
+ | `remove <ref>` | Unlink an entry from its parent. If the entry is a draft that has never been published, it is queued for deletion on `save`. Published entries are only unlinked. |
147
+ | `move <ref> --after <ref2>` | Move an entry to a new position within its parent content array |
148
+
149
+ ### 7.6 CTA Links
150
+
151
+ CTA link lists are nested within component entries.
152
+
153
+ | Command | Function |
154
+ |---|---|
155
+ | `links list <ref>` | List all CTA links on an entry |
156
+ | `links add <ref> --type external --label "X" --href <url>` | Add an external URL link |
157
+ | `links add <ref> --type internal --label "X" --slug /page` | Add an internal link by page slug |
158
+ | `links add <ref> --type internal --label "X" --id <id>` | Add an internal link by entry ID |
159
+ | `links add <ref> --type download --label "X" --asset-id <id>` | Add a download link to an asset |
160
+ | `links move <ref> <from-index> <to-index>` | Reorder links by index |
161
+ | `links remove <ref> <index>` | Remove a link by index |
162
+
163
+ ### 7.7 Navigation
164
+
165
+ | Command | Function |
166
+ |---|---|
167
+ | `nav open <slug-or-id>` | Open a navigation entry in a session |
168
+ | `nav add --label "X" --slug /page` | Add a navigation item |
169
+
170
+ ---
171
+
172
+ ## 8. Rich Text Conversion
173
+
174
+ The `rtf` command sets Rich Text fields from one of four input modes (exactly one flag; **`--markdown` is the default** when omitted):
175
+
176
+ | Mode | Flag | Behaviour |
177
+ |---|---|---|
178
+ | Plain text | `--text` | Paragraphs from `\n\n` or `\n`; inline markers (`**bold**`, links, …) use the same inline rules as Markdown. |
179
+ | Markdown | `--markdown` | Full document Markdown (see table below). |
180
+ | HTML | `--html` | Subset of HTML (`h1`–`h6`, `p`, lists, `blockquote`, `table`, inline tags). |
181
+ | Rich Text JSON | `--json` | Full Contentful Rich Text document JSON (`nodeType: document`). |
182
+
183
+ Input may be passed as positional argument, `--content`, `--base64`, `--file`, or stdin (`-`). The same modes apply to `cms-edit set` on Rich Text fields via `--rtf-text`, `--rtf-markdown`, `--rtf-html`, `--rtf-json`; `create from-json` auto-detects Markdown / HTML / JSON document strings or accepts `{ "value", "format" }`; `rtf patch` ops support `replaceIsMarkdown`, `replaceIsHtml`, `replaceIsJson`, or `replaceFormat`.
184
+
185
+ Markdown syntax (when using `--markdown`):
186
+
187
+ | Markdown | Rich text output |
188
+ |---|---|
189
+ | `#` through `######` | heading-1 through heading-6 |
190
+ | `**text**` | bold |
191
+ | `_text_` | italic |
192
+ | `***text***` | bold-italic |
193
+ | `` `code` `` | inline code |
194
+ | `[text](url)` | hyperlink |
195
+ | `- item` | unordered list item |
196
+ | `1. item` | ordered list item |
197
+ | Indented list items | nested lists |
198
+ | `> text` | blockquote |
199
+ | `---` | horizontal rule |
200
+ | `\| col \| col \|` (GFM) | table |
201
+
202
+ The `rtf replace` command performs surgical replacement at the text-node level. Replacements may be supplied as plain text, inline Markdown, inline HTML, or a JSON array of inline nodes (`--replace-plain`, `--replace`, `--replace-html`, `--replace-json`).
203
+
204
+ ---
205
+
206
+ ## 9. Write Behaviour and Optimistic Locking
207
+
208
+ On `save`:
209
+
210
+ 1. For each modified entry, the tool fetches the current live version from Contentful.
211
+ 2. Local changes are merged on top of the fetched version (handles concurrent edits from other sources).
212
+ 3. The merged entry is written using the Contentful Management API `update` method (not `publish`).
213
+ 4. Draft-only entries queued for deletion are deleted.
214
+ 5. Success and failure counts are reported.
215
+
216
+ If a version conflict cannot be resolved cleanly, an error is returned and the entry is not written.
217
+
218
+ ---
219
+
220
+ ## 10. Permission Constraints
221
+
222
+ The tool enforces a hard boundary between editing and publishing:
223
+
224
+ **Permitted:**
225
+ - Read entries and assets
226
+ - Create draft entries
227
+ - Update draft and published entries (saving as new draft versions)
228
+ - Delete draft-only entries (never-published)
229
+
230
+ **Not permitted (not exposed by the tool):**
231
+ - Publish entries
232
+ - Unpublish entries
233
+ - Archive entries
234
+ - Delete published entries
235
+
236
+ This boundary is enforced at two levels: the tool exposes no publish/unpublish/archive/delete commands, and the expected Contentful management token role should not have those permissions either.
237
+
238
+ ---
239
+
240
+ ## 11. Output Modes
241
+
242
+ **Human-readable mode (default):** Coloured console output with info, success, warning, and error messages.
243
+
244
+ **JSON mode** (`--json` flag or `CMS_EDIT_JSON=1`): Structured JSON on stdout. Schema varies by command:
245
+
246
+ | Command | JSON output |
247
+ |---|---|
248
+ | `snapshot` | Entry tree with refs, types, labels, publish status |
249
+ | `read` | Entry object with all fields, or single field value |
250
+ | `diff` | Array of changed entries, each with before/after field values |
251
+ | `search` / `list` | Array of matching entry objects |
252
+ | `save` | Success/failure counts and per-entry messages |
253
+ | `resolve` | Asset or entry metadata |
254
+
255
+ ---
256
+
257
+ ## 12. Screenshot Capture
258
+
259
+ When `devBaseUrl` is configured, the tool can capture screenshots of components or pages by driving a headless browser against the local development server. Screenshots are written as PNG files to the local filesystem. This requires the app to be running at the configured URL.
260
+
261
+ ---
262
+
263
+ ## 13. Telemetry
264
+
265
+ The tool emits telemetry events recording the command name, outcome (success/error), and duration. No field values, entry IDs, or other content is included.
266
+
267
+ ---
268
+
269
+ ## 14. Concurrency
270
+
271
+ Multiple sessions can be active simultaneously using the `--session <name>` flag or `CONTENTFUL_CMS_SESSION` env var. Sessions are isolated; changes in one session do not affect another. The optimistic locking on `save` handles the case where two sessions modify the same entry.
@@ -0,0 +1,151 @@
1
+ # cms-edit MCP guide
2
+
3
+ Use this guide when editing Contentful draft content through Claude Desktop (hosted `.mcpb` extension) or local stdio MCP.
4
+
5
+ {{SITE_INTRO}}
6
+
7
+ ## Safety rules
8
+
9
+ cms-edit **cannot and will not**:
10
+
11
+ - Publish or unpublish entries
12
+ - Archive or delete published entries
13
+ - Upload new assets (use Contentful UI for assets)
14
+
15
+ All `save` operations create **drafts only**. A human must review and publish in Contentful.
16
+
17
+ ## MCP tools
18
+
19
+ | Tool | Purpose |
20
+ |------|---------|
21
+ | `cms_edit` | Run any cms-edit command via an `args` array |
22
+ | `cms_edit_version` | Check the installed cms-edit version (no session required) |
23
+ | `cms_edit_help` | Read this guide by topic (`overview`, `workflow`, `commands`, `troubleshooting`, `hosted`) |
24
+
25
+ ## MCP prompts
26
+
27
+ | Prompt | Purpose |
28
+ |--------|---------|
29
+ | `cms_edit_verify` | Check version and connectivity |
30
+ | `cms_edit_explore` | List site content and open a page |
31
+ | `cms_edit_edit_page` | Edit a page through diff → save |
32
+
33
+ Read the full guide anytime via the `cms-edit://guide` resource or `cms_edit_help`.
34
+
35
+ ## Core workflow
36
+
37
+ Standard editing flow: **open → snapshot → read → set/rtf → diff → save**
38
+
39
+ Each step is a separate `cms_edit` call. Sessions persist in Redis between calls (hosted) or on disk (local). MCP auto-uses session `_mcp`.
40
+
41
+ ### 1. Open a page
42
+
43
+ ```
44
+ ["open", "/"]
45
+ ["open", "/pricing"]
46
+ ["open", "<entry-id>", "--id"]
47
+ ```
48
+
49
+ Homepage slug is `/` (or `index` depending on the site).
50
+
51
+ ### 2. Snapshot — see the content tree
52
+
53
+ ```
54
+ ["snapshot"]
55
+ ```
56
+
57
+ Output shows `@c0`, `@c1`, … refs for each component. Use these refs in `read`, `set`, and `rtf`.
58
+
59
+ ### 3. Read fields
60
+
61
+ ```
62
+ ["read", "@c1"]
63
+ ["read", "@c1", "heading"]
64
+ ```
65
+
66
+ ### 4. Edit fields
67
+
68
+ ```
69
+ ["set", "@c1", "heading", "New heading text"]
70
+ ["rtf", "@c1", "body", "--content", "# Title\n\nParagraph text."]
71
+ ```
72
+
73
+ For rich text, prefer `--content` with inline markdown. Use `--base64` when special characters cause issues.
74
+
75
+ ### 5. Review and save
76
+
77
+ ```
78
+ ["diff"]
79
+ ["save"]
80
+ ```
81
+
82
+ Always run `diff` before `save`. To abandon changes: `["discard"]`.
83
+
84
+ ## Common sequences
85
+
86
+ ### List all pages
87
+
88
+ ```
89
+ ["sitemap"]
90
+ ```
91
+
92
+ ### Explore the homepage
93
+
94
+ ```
95
+ ["open", "/"]
96
+ ["snapshot"]
97
+ ["read", "@c1"]
98
+ ```
99
+
100
+ ### Edit copy on a page
101
+
102
+ ```
103
+ ["open", "{{EXAMPLE_SLUG}}"]
104
+ ["snapshot"]
105
+ ["read", "@c1", "heading"]
106
+ ["set", "@c1", "heading", "Updated heading"]
107
+ ["diff"]
108
+ ["save"]
109
+ ```
110
+
111
+ ## Field discovery
112
+
113
+ ```
114
+ ["schema", "component"]
115
+ ["list", "--type", "page"]
116
+ ["search", "pricing"]
117
+ ```
118
+
119
+ ## Hosted extension rules
120
+
121
+ {{HOSTED_RULES}}
122
+
123
+ ## Session tips
124
+
125
+ - After `open`, subsequent MCP commands share session `_mcp` automatically (stored in Redis on hosted).
126
+ - Use `--session <name>` only when juggling multiple pages — pass it **before** the subcommand on every call: `["--session", "my-work", "open", "/"]`.
127
+ - Snapshot JSON includes `sessionName` and `sessionKey` for debugging.
128
+ - Stateless read (no session): `["read", "<entry-id>", "--id"]` — use `entryId` from snapshot JSON.
129
+ - If you see "No active session", check `/api/health` (Redis must be ok), then run `open` again.
130
+
131
+ ## Troubleshooting
132
+
133
+ | Problem | What to do |
134
+ |---------|------------|
135
+ | **401 / invalid token** | Regenerate CMA token in Contentful; update token in Claude Desktop → Settings → Extensions |
136
+ | **No cms_edit tool** | Quit Claude fully and reopen; confirm extension is enabled |
137
+ | **No active session** | Do not pass `--space` on hosted. Check `/api/health` — `redis` must be ok. MCP uses `_mcp` session automatically. Manual session: `["--session", "name", "open", "/"]`. Fallback: `["read", "<entry-id>", "--id"]` |
138
+ | **Wrong space** | Token must belong to this deployment's Contentful space |
139
+ | **Check version** | Call `cms_edit_version` or `curl /api/health` and read `cmsEdit` |
140
+
141
+ ## Command reference (cms_edit args)
142
+
143
+ **Discovery:** `sitemap`, `list --type <type>`, `search <query>`, `schema <contentType>`
144
+
145
+ **Reading:** `open <slug>`, `open <id> --id`, `snapshot`, `read <ref>`, `read <id> --id`, `peek <slug>`
146
+
147
+ **Editing:** `set <ref> <field> <value>`, `rtf <ref> <field> --content "<md>"`, `diff`, `save`, `discard`
148
+
149
+ **Creating:** `create page --slug … --title …`, `add <type> --content-type … --parent @c0 --target content`
150
+
151
+ **Other:** `health`, `version`, `guide [topic]`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/contentful-cms",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
4
4
  "description": "CLI tool for AI agents to read and edit Contentful draft content without publish permissions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,6 +15,10 @@
15
15
  ".": {
16
16
  "types": "./dist/index.d.ts",
17
17
  "import": "./dist/index.js"
18
+ },
19
+ "./hosted": {
20
+ "types": "./dist/hosted/index.d.ts",
21
+ "import": "./dist/hosted/index.js"
18
22
  }
19
23
  },
20
24
  "bin": {
@@ -26,24 +30,27 @@
26
30
  "files": [
27
31
  "dist",
28
32
  "docs/help",
33
+ "docs/mcp",
29
34
  "skills",
30
35
  "*.md"
31
36
  ],
32
37
  "dependencies": {
33
- "@clack/prompts": "^1.3.0",
38
+ "@clack/prompts": "^1.4.0",
34
39
  "@contentful/rich-text-types": "^17.2.7",
35
40
  "@modelcontextprotocol/sdk": "^1.29.0",
36
41
  "commander": "^14.0.3",
37
- "contentful-management": "^12.3.3",
42
+ "contentful-management": "^12.5.0",
38
43
  "dotenv": "^17.4.2",
39
44
  "picocolors": "^1.1.1",
40
45
  "zod": "^4.4.3"
41
46
  },
42
47
  "devDependencies": {
48
+ "@anthropic-ai/mcpb": "^1.0.0",
43
49
  "@biomejs/biome": "^2.4.15",
44
- "@types/node": "^22.19.18",
50
+ "@types/node": "^24.12.4",
51
+ "esbuild": "^0.25.0",
45
52
  "typescript": "^6.0.3",
46
- "vitest": "^4.1.5"
53
+ "vitest": "^4.1.7"
47
54
  },
48
55
  "keywords": [
49
56
  "contentful",
@@ -59,10 +66,11 @@
59
66
  },
60
67
  "scripts": {
61
68
  "build": "tsc --project tsconfig.build.json",
69
+ "build:mcpb-bridge": "esbuild mcpb/bridge/index.ts --bundle --platform=node --target=node20 --format=esm --packages=bundle --outfile=mcpb/.pack/bridge/index.js",
62
70
  "dev": "tsc --project tsconfig.build.json --watch",
63
71
  "type-check": "tsc --noEmit",
64
72
  "lint": "biome lint .",
65
- "clean": "rm -rf dist .turbo *.tsbuildinfo",
73
+ "clean": "rm -rf dist .turbo *.tsbuildinfo mcpb/.pack mcpb/dist",
66
74
  "test": "vitest run"
67
75
  }
68
76
  }