@se-studio/contentful-cms 1.0.81 → 1.0.82
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/CHANGELOG.md +6 -0
- package/HOSTED.md +121 -0
- package/INSTALL.md +22 -5
- package/README.md +2 -0
- package/dist/bin/cms-edit.js +8 -143
- package/dist/bin/cms-edit.js.map +1 -1
- package/dist/cli/program.d.ts +9 -0
- package/dist/cli/program.d.ts.map +1 -0
- package/dist/cli/program.js +159 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/runner.d.ts +15 -0
- package/dist/cli/runner.d.ts.map +1 -0
- package/dist/cli/runner.js +93 -0
- package/dist/cli/runner.js.map +1 -0
- package/dist/commands/add.js +2 -2
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/asset.js +5 -5
- package/dist/commands/asset.js.map +1 -1
- package/dist/commands/backup.js +1 -1
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/create-from-json.js +1 -1
- package/dist/commands/create-from-json.js.map +1 -1
- package/dist/commands/create.js +4 -4
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/diff.js +2 -2
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/discard.js +4 -4
- package/dist/commands/discard.js.map +1 -1
- package/dist/commands/guide.d.ts +4 -0
- package/dist/commands/guide.d.ts.map +1 -0
- package/dist/commands/guide.js +18 -0
- package/dist/commands/guide.js.map +1 -0
- package/dist/commands/links.js +10 -10
- package/dist/commands/links.js.map +1 -1
- package/dist/commands/move.js +3 -3
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/nav.js +3 -3
- package/dist/commands/nav.js.map +1 -1
- package/dist/commands/open.js +1 -1
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/peek.d.ts.map +1 -1
- package/dist/commands/peek.js +8 -2
- package/dist/commands/peek.js.map +1 -1
- package/dist/commands/preview.js +1 -1
- package/dist/commands/preview.js.map +1 -1
- package/dist/commands/read.js +2 -2
- package/dist/commands/read.js.map +1 -1
- package/dist/commands/remove.js +2 -2
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/revert.js +5 -5
- package/dist/commands/revert.js.map +1 -1
- package/dist/commands/rtf.js +11 -11
- package/dist/commands/rtf.js.map +1 -1
- package/dist/commands/run.js +8 -8
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/save.js +3 -3
- package/dist/commands/save.js.map +1 -1
- package/dist/commands/screenshot.js +2 -2
- package/dist/commands/screenshot.js.map +1 -1
- package/dist/commands/set.js +7 -7
- package/dist/commands/set.js.map +1 -1
- package/dist/commands/snapshot.js +1 -1
- package/dist/commands/snapshot.js.map +1 -1
- package/dist/commands/version.d.ts +4 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +17 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/config/hosted.d.ts +28 -0
- package/dist/config/hosted.d.ts.map +1 -0
- package/dist/config/hosted.js +94 -0
- package/dist/config/hosted.js.map +1 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +5 -0
- package/dist/config/load.js.map +1 -1
- package/dist/hosted/index.d.ts +13 -0
- package/dist/hosted/index.d.ts.map +1 -0
- package/dist/hosted/index.js +12 -0
- package/dist/hosted/index.js.map +1 -0
- package/dist/mcp/guide.d.ts +20 -0
- package/dist/mcp/guide.d.ts.map +1 -0
- package/dist/mcp/guide.js +91 -0
- package/dist/mcp/guide.js.map +1 -0
- package/dist/mcp/http-handler.d.ts +13 -0
- package/dist/mcp/http-handler.d.ts.map +1 -0
- package/dist/mcp/http-handler.js +28 -0
- package/dist/mcp/http-handler.js.map +1 -0
- package/dist/mcp/prompts/onboarding.d.ts +4 -0
- package/dist/mcp/prompts/onboarding.d.ts.map +1 -0
- package/dist/mcp/prompts/onboarding.js +77 -0
- package/dist/mcp/prompts/onboarding.js.map +1 -0
- package/dist/mcp/resources/guide.d.ts +4 -0
- package/dist/mcp/resources/guide.d.ts.map +1 -0
- package/dist/mcp/resources/guide.js +16 -0
- package/dist/mcp/resources/guide.js.map +1 -0
- package/dist/mcp/server.d.ts +13 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +20 -92
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/cms-edit.d.ts +9 -0
- package/dist/mcp/tools/cms-edit.d.ts.map +1 -0
- package/dist/mcp/tools/cms-edit.js +57 -0
- package/dist/mcp/tools/cms-edit.js.map +1 -0
- package/dist/mcp/tools/help.d.ts +4 -0
- package/dist/mcp/tools/help.d.ts.map +1 -0
- package/dist/mcp/tools/help.js +22 -0
- package/dist/mcp/tools/help.js.map +1 -0
- package/dist/mcp/types.d.ts +2 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +2 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/runtime/context.d.ts +19 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +9 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/session/file-session-store.d.ts +10 -0
- package/dist/session/file-session-store.d.ts.map +1 -0
- package/dist/session/file-session-store.js +92 -0
- package/dist/session/file-session-store.js.map +1 -0
- package/dist/session/redis-session-store.d.ts +21 -0
- package/dist/session/redis-session-store.d.ts.map +1 -0
- package/dist/session/redis-session-store.js +121 -0
- package/dist/session/redis-session-store.js.map +1 -0
- package/dist/session/session-store.d.ts +19 -0
- package/dist/session/session-store.d.ts.map +1 -0
- package/dist/session/session-store.js +9 -0
- package/dist/session/session-store.js.map +1 -0
- package/dist/session/store.d.ts +5 -5
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js +16 -74
- package/dist/session/store.js.map +1 -1
- package/dist/version.d.ts +9 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +19 -0
- package/dist/version.js.map +1 -0
- package/docs/FEATURE_REQUESTS_ARCHIVE.md +141 -0
- package/docs/FUNCTIONAL_SPEC.md +271 -0
- package/docs/mcp/hosted-guide.md +149 -0
- 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,149 @@
|
|
|
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. The session persists automatically between calls.
|
|
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 commands use the same session automatically.
|
|
126
|
+
- Use `--session <name>` only when juggling multiple pages at once — pass the **same name on every command** in that workflow.
|
|
127
|
+
- If you see "No active session", run `open` again, then continue with `snapshot` or `read`.
|
|
128
|
+
|
|
129
|
+
## Troubleshooting
|
|
130
|
+
|
|
131
|
+
| Problem | What to do |
|
|
132
|
+
|---------|------------|
|
|
133
|
+
| **401 / invalid token** | Regenerate CMA token in Contentful; update token in Claude Desktop → Settings → Extensions |
|
|
134
|
+
| **No cms_edit tool** | Quit Claude fully and reopen; confirm extension is enabled |
|
|
135
|
+
| **No active session** | Do not pass `--space` on hosted. Run `open` again, then `snapshot` |
|
|
136
|
+
| **Wrong space** | Token must belong to this deployment's Contentful space |
|
|
137
|
+
| **Check version** | Call `cms_edit_version` or `curl /api/health` and read `cmsEdit` |
|
|
138
|
+
|
|
139
|
+
## Command reference (cms_edit args)
|
|
140
|
+
|
|
141
|
+
**Discovery:** `sitemap`, `list --type <type>`, `search <query>`, `schema <contentType>`
|
|
142
|
+
|
|
143
|
+
**Reading:** `open <slug>`, `open <id> --id`, `snapshot`, `read <ref>`, `peek <slug>`
|
|
144
|
+
|
|
145
|
+
**Editing:** `set <ref> <field> <value>`, `rtf <ref> <field> --content "<md>"`, `diff`, `save`, `discard`
|
|
146
|
+
|
|
147
|
+
**Creating:** `create page --slug … --title …`, `add <type> --content-type … --parent @c0 --target content`
|
|
148
|
+
|
|
149
|
+
**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.
|
|
3
|
+
"version": "1.0.82",
|
|
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.
|
|
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.
|
|
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": "^
|
|
50
|
+
"@types/node": "^24.12.4",
|
|
51
|
+
"esbuild": "^0.25.0",
|
|
45
52
|
"typescript": "^6.0.3",
|
|
46
|
-
"vitest": "^4.1.
|
|
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
|
}
|