@se-studio/contentful-cms 2.7.5 → 2.7.7
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 +12 -0
- package/HOSTED.md +20 -2
- package/dist/generated/hosted-guide.d.ts +1 -1
- package/dist/generated/hosted-guide.d.ts.map +1 -1
- package/dist/generated/hosted-guide.js +1 -1
- package/dist/generated/hosted-guide.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/hosted/oauth/complete.d.ts.map +1 -1
- package/dist/hosted/oauth/complete.js +2 -1
- package/dist/hosted/oauth/complete.js.map +1 -1
- package/dist/hosted/oauth/handlers.d.ts.map +1 -1
- package/dist/hosted/oauth/handlers.js +5 -26
- package/dist/hosted/oauth/handlers.js.map +1 -1
- package/dist/hosted/oauth/redirect-uri.d.ts +10 -0
- package/dist/hosted/oauth/redirect-uri.d.ts.map +1 -0
- package/dist/hosted/oauth/redirect-uri.js +61 -0
- package/dist/hosted/oauth/redirect-uri.js.map +1 -0
- package/docs/mcp/hosted-guide.md +23 -2
- package/package.json +3 -3
- package/skills/manifest.json +1 -1
- package/skills/setup/SKILL.md +39 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @se-studio/contentful-cms Changelog
|
|
2
2
|
|
|
3
|
+
## 2.7.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0ee34af: Fix hosted MCP OAuth for Grok Build: accept loopback redirect_uri aliases (127.0.0.1 ↔ localhost) and auto-redirect authorize to Contentful sign-in.
|
|
8
|
+
|
|
9
|
+
## 2.7.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Bulk version bump: patch for all packages
|
|
14
|
+
|
|
3
15
|
## 2.7.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/HOSTED.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Hosted cms-edit for Claude Desktop
|
|
1
|
+
# Hosted cms-edit for Claude Desktop and Grok Build
|
|
2
2
|
|
|
3
|
-
Use this guide when your team hosts cms-edit on Vercel (one deployment per client). **You do not need Node.js, tokens, or config files** — only Claude Desktop and a Contentful account.
|
|
3
|
+
Use this guide when your team hosts cms-edit on Vercel (one deployment per client). **You do not need Node.js, tokens, or config files** — only an MCP client (Claude Desktop or Grok Build) and a Contentful account.
|
|
4
4
|
|
|
5
5
|
Edits you make appear in Contentful under **your name**, because you sign in with your own Contentful account.
|
|
6
6
|
|
|
@@ -42,6 +42,24 @@ No extension install, no personal access token, no command line.
|
|
|
42
42
|
|
|
43
43
|
---
|
|
44
44
|
|
|
45
|
+
## Grok Build
|
|
46
|
+
|
|
47
|
+
Add the hosted MCP URL to `~/.grok/config.toml` (URL must end with `/api/mcp`):
|
|
48
|
+
|
|
49
|
+
```toml
|
|
50
|
+
[mcp_servers.cms-edit-<projectKey>]
|
|
51
|
+
url = "https://<your-host>/api/mcp"
|
|
52
|
+
enabled = true
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
In Grok: `/mcps` → select the server → press **`i`** to start OAuth → sign in with Contentful.
|
|
56
|
+
|
|
57
|
+
Verify: `grok mcp doctor cms-edit-<projectKey>` or call the `cms_edit_version` tool in a session.
|
|
58
|
+
|
|
59
|
+
See [hosted-guide.md](./docs/mcp/hosted-guide.md) for troubleshooting.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
45
63
|
## Step 3 — Try it
|
|
46
64
|
|
|
47
65
|
**Getting started:** Ask Claude to read the **cms-edit guide** (`cms-edit://guide` resource) or use the **`cms_edit_verify`** prompt to check version and connectivity.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const HOSTED_GUIDE_TEMPLATE = "# cms-edit MCP guide\n\nUse this guide when editing Contentful draft content through Claude Desktop (hosted Integrations + OAuth).\n\n{{SITE_INTRO}}\n\n## Safety rules\n\ncms-edit **cannot and will not**:\n\n- Publish or unpublish entries\n- Archive or delete published entries\n\nAll `save` operations create **drafts only**. A human must review and publish in Contentful.\n\n**Assets:** cms-edit **can upload** draft assets (`asset upload` from file, URL, or base64). Always **search and reuse existing assets first** (`index sync`, then `asset search` or `list --type media`). Use `--if-exists-by-filename` when uploading to avoid duplicates.\n\n## MCP tools\n\n| Tool | Purpose |\n|------|---------|\n| `cms_edit` | Run any cms-edit command via an `args` array |\n| `cms_edit_version` | Check the installed cms-edit version (no session required) |\n| `cms_edit_help` | Read this guide by topic (`overview`, `workflow`, `commands`, `troubleshooting`, `hosted`) |\n\n## Customer editor pack (read first)\n\nWhen a site editor pack is deployed, these MCP resources provide **site-specific** context. Read them before creating or editing content:\n\n| Resource | Purpose |\n|----------|---------|\n| `cms-edit://customer/index` | List of all customer resources |\n| `cms-edit://customer/tasks-index` | Intent \u2192 task playbook map (filtered for this site) |\n| `cms-edit://customer/capabilities` | Machine-readable list of what this site supports |\n| `cms-edit://customer/checklist` | First-session onboarding steps |\n| `cms-edit://customer/overview` | Site name, space, staging URL, handoff rules |\n| `cms-edit://customer/routing` | Article/tag URL rules for this site |\n| `cms-edit://customer/production-site` | Production URL and how to fetch page markdown (do not guess `.md` URLs) |\n| `cms-edit://customer/components-index` | Component types and when to use each |\n| `cms-edit://customer/collections-index` | Collection types |\n| `cms-edit://customer/brand` | Brand voice and terminology (if configured) |\n| `cms-edit://customer/articles` | Article/publication playbook (if configured) |\n| `cms-edit://customer/defaults` | Featured image rules and article types (if configured) |\n| `cms-edit://customer/site-facts` | Optional canonical business facts (if configured) |\n| `cms-edit://customer/task-*` | Capability playbooks (e.g. `task-media-reuse-and-upload`) |\n\n**Workflow:** read `tasks-index` \u2192 `capabilities` \u2192 `checklist` \u2192 `overview` \u2192 `routing` \u2192 `production-site` \u2192 pick a `task-*` playbook for your goal \u2192 `components-index` \u2192 then use `cms_edit` commands.\n\n## MCP prompts\n\n| Prompt | Purpose |\n|--------|---------|\n| `cms_edit_verify` | Check version and connectivity |\n| `cms_edit_explore` | List site content and open a page |\n| `cms_edit_edit_page` | Edit a page through diff \u2192 save |\n| `cms_edit_edit_article` | Edit an article through diff \u2192 save |\n| `cms_edit_index_sync` | Build/refresh local index (assets, media, templates, taxonomy) |\n| `cms_edit_create_page` | Create a page with template selection |\n| `cms_edit_create_article` | Create an article (requires article type; featured image rules) |\n| `cms_edit_create_from_doc` | Create a page from a freeform document (infer \u2192 confirm \u2192 dry-run) |\n| `cms_edit_create_article_from_doc` | Create an article from a freeform document |\n| `cms_edit_taxonomy` | Import taxonomy entries (`create \u2026 --if-not-exists`) |\n| `cms_edit_bulk_seo` | Update SEO meta descriptions (read `task-seo-descriptions`) |\n| `cms_edit_bulk_find_replace` | Bulk find-replace in rich text across entries |\n| `cms_edit_bulk_article_tags` | Update tags on one or more articles |\n| `cms_edit_import_authors` | Create person/author entries from a list or sheet |\n| `cms_edit_media` | Find existing assets or upload new ones (reuse-first) |\n\nRead the full guide anytime via the `cms-edit://guide` resource or `cms_edit_help`.\n\n## End-to-end QA prompt\n\nFor release QA after cms-edit or editor-pack upgrades, use a **copy-paste Claude Desktop test script** (phases: connector \u2192 customer resources \u2192 discovery \u2192 session \u2192 schema \u2192 media \u2192 dry-run writes \u2192 negatives). See [e2e-test-prompt.md](./e2e-test-prompt.md) to author one per customer site. Example: Brightline `docs/cms-edit/MCP-E2E-TEST.md`.\n\n## Core workflow\n\nStandard editing flow: **open \u2192 snapshot \u2192 read \u2192 set/rtf \u2192 diff \u2192 save**\n\nEach step is a separate `cms_edit` call. Sessions persist in Redis between calls (hosted) or on disk (local). MCP auto-uses session `_mcp`.\n\n### 1. Open a page\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"open\", \"--page-slug\", \"/pricing\"]\n[\"open\", \"--id\", \"<entry-id>\"]\n```\n\n**Homepage (all SE Studio sites):** Contentful stores the marketing homepage slug as `index`. The live site URL is `/`. In cms-edit, `--page-slug /` and `--page-slug /index` are equivalent (both resolve to `index`). Read `cms-edit://customer/routing` for site-specific exceptions (e.g. Pedestal uses `home`).\n\n### 2. Snapshot \u2014 see the content tree\n\n```\n[\"snapshot\"]\n```\n\nOutput shows `@c0`, `@c1`, \u2026 refs for each component. Use these refs in `read`, `set`, and `rtf`.\n\n### 3. Read fields\n\n```\n[\"read\", \"@c1\"]\n[\"read\", \"@c1\", \"heading\"]\n```\n\n### 4. Edit fields\n\n```\n[\"set\", \"@c1\", \"heading\", \"New heading text\"]\n[\"rtf\", \"@c1\", \"body\", \"--content\", \"# Title\\n\\nParagraph text.\"]\n```\n\nFor rich text, prefer `--content` with inline markdown. Use `--base64` when special characters cause issues.\n\n### 5. Review and save\n\n```\n[\"diff\"]\n[\"save\"]\n```\n\nAlways run `diff` before `save`. To abandon changes: `[\"discard\"]`.\n\n## When to use Contentful UI\n\n| Task | Where |\n|------|-------|\n| Edit copy, add sections, create pages/articles | **Claude + cms-edit** (drafts) |\n| Publish approved drafts | **Contentful UI** |\n| Upload new images and files | **Contentful UI** asset library |\n| Edit copy directly in Contentful | **Avoid** \u2014 use Claude instead |\n\ncms-edit saves **drafts only**. A colleague must **publish in Contentful** for changes to go live.\n\n## Featured images (articles)\n\nRead `cms-edit://customer/defaults` when present. Otherwise:\n\n1. **Custom** \u2014 set `featuredImage` or `featuredImageAssetFilename` on the article when the editor provides a specific image\n2. **Article type** \u2014 if omitted, cms-edit inherits the linked **articleType** `featuredImage`\n3. **Site default** \u2014 from `editor.defaults` in the site config (also in `defaults.json` in the editor pack)\n\nRun `[\"index\", \"sync\"]` before resolving assets by filename.\n\n## Create content\n\n### Create a page\n\n```\n[\"index\", \"sync\"]\n[\"list\", \"--type\", \"template\"]\n[\"create\", \"page\", \"--slug\", \"/about-us\", \"--title\", \"About Us\", \"--template-id\", \"<id>\"]\n[\"snapshot\"]\n```\n\nOr use `create from-json` with `--dry-run --strict` for multi-section pages.\n\n### Create an article\n\nEvery article requires an **articleType**:\n\n```\n[\"index\", \"sync\"]\n[\"list\", \"--type\", \"articleType\"]\n[\"create\", \"article\", \"--slug\", \"resources/blog/my-post\", \"--title\", \"My Post\", \"--article-type-slug\", \"resources/blog\"]\n```\n\nOr `create from-json` with `\"type\": \"article\"` and `articleTypeSlug` / `articleTypeId`.\n\nUse MCP prompt `cms_edit_create_article` for guided creation.\n\n## Common sequences\n\n### List all pages\n\n```\n[\"list\", \"--type\", \"page\"]\n```\n\n### Refresh local index (assets, media, templates, taxonomy)\n\nRun before asset filename search, media-by-filename list, or fast template/taxonomy lookup:\n\n```\n[\"index\", \"sync\"]\n[\"index\", \"status\"]\n[\"list\", \"--type\", \"template\"]\n```\n\nAsset search and media-by-filename list **require** the index. Template/taxonomy list prefers the index when built.\n\n### Explore the homepage\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"snapshot\"]\n[\"read\", \"@c1\"]\n```\n\n### Edit copy on a page\n\n```\n[\"open\", \"--page-slug\", \"{{EXAMPLE_SLUG}}\"]\n[\"snapshot\"]\n[\"read\", \"@c1\", \"heading\"]\n[\"set\", \"@c1\", \"heading\", \"Updated heading\"]\n[\"diff\"]\n[\"save\"]\n```\n\n## Field discovery\n\n```\n[\"schema\", \"component\"]\n[\"list\", \"--type\", \"page\"]\n[\"search\", \"pricing\"]\n```\n\n## Hosted connector rules\n\n{{HOSTED_RULES}}\n\n## Session tips\n\n- After `open`, subsequent MCP commands share session `_mcp` automatically (stored in Redis on hosted).\n- Use `--session <name>` only when juggling multiple pages \u2014 pass it **before** the subcommand on every call: `[\"--session\", \"my-work\", \"open\", \"--page-slug\", \"/\"]`.\n- Snapshot JSON includes `sessionName` and `sessionKey` for debugging.\n- If you see \"No active session\", check `/api/health` (Redis must be ok), then run `open` again. Set `LOG_CMS_SESSION=1` on Vercel and search runtime logs for `[cms-edit:session]` (`redis save ok` / `redis load hit` / `requireSession miss`).\n\n### peek vs open vs read\n\n| Goal | MCP args |\n|------|----------|\n| Edit workflow (session) | `[\"open\", \"--page-slug\", \"/\"]` then `[\"read\", \"@c0\"]` |\n| Preview tree + fields, no session | `[\"peek\", \"--page-slug\", \"/pricing\"]` or `[\"peek\", \"--id\", \"<entry-id>\"]` (JSON includes `rootFields`) |\n| Read fields by entry ID, no session | `[\"read\", \"<entry-id>\", \"--id\"]` or `[\"read\", \"<entry-id>\", \"--id\", \"heading\"]` |\n| Debug session persistence | `[\"diagnose\"]` \u2014 reports store, userId, active session key |\n\n- **`peek` is one-shot** \u2014 prints tree and **root field values** (`rootFields` in JSON). No session is created; do not chain `read @ref` afterward.\n- **Use flat lookup flags** for `open` and `peek` \u2014 same as CLI (`--page-slug`, `--id`, etc.). See `help lookup`.\n- **`read @root`** only works after `open` (uses the active session). The hint in peek output is for terminal users who already ran `open`.\n- **Do not invent flags** \u2014 there is no `--read`, `--then`, or chained peek+read syntax. One command per `cms_edit` call.\n\n## Troubleshooting\n\n| Problem | What to do |\n|---------|------------|\n| **401 / connection failed** | Claude \u2192 Settings \u2192 Integrations \u2192 Connect again; complete Contentful sign-in. On Vercel, search runtime logs for `[cms-edit:oauth] auth_failure` (always logged). Set `LOG_CMS_OAUTH=1` for connect success traces. |\n| **No cms_edit tool** | Confirm the integration is connected under Settings \u2192 Integrations |\n| **No active session** | Do not pass `--space` on hosted. Check `/api/health` \u2014 `redis` must be ok. MCP uses `_mcp` session automatically. Manual session: `[\"--session\", \"name\", \"open\", \"--page-slug\", \"/\"]`. Fallback: `[\"read\", \"<entry-id>\", \"--id\"]` |\n| **Wrong space** | Your Contentful account must have access to this deployment's space |\n| **Check version** | Call `cms_edit_version` or `curl /api/health` and read `cmsEdit` |\n\n## Articles\n\n**Recent articles** (by publication `date`, not last-updated):\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\", \"-n\", \"10\"]\n```\n\nAlternative: `[\"search\", \"<keyword>\", \"--type\", \"article\"]` (also sorts by date).\n\n**Draft articles** \u2014 `peek` and `open` load drafts via CMA (not published-only). To discover drafts:\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\"]\n[\"search\", \"<title>\", \"--type\", \"article\"]\n[\"list\", \"--type\", \"article\", \"--slug\", \"<slug>\"]\n```\n\nThen open: `[\"peek\", \"--article-slug\", \"<slug>\"]` or `[\"open\", \"--id\", \"<entry-id>\"]`. Use `--article-slug`, not `--page-slug`.\n\n**Published-only** is opt-in: `list --published` and `resolve --published` use the Delivery API index and omit never-published drafts.\n\nAfter upgrading cms-edit, run `[\"index\", \"sync\"]` once so the local index includes article `date` values (schema v4).\n\n**Index freshness on hosted MCP:** The catalog index is shared via Redis (gzipped SQLite blob). `index status` on a cold instance may show **not built** until `list`, `open`, or another index command runs \u2014 that is normal. Committed writes (`save`, `create page`, `asset upload`, \u2026) mark the index dirty; the next discovery command refreshes it. In-session `set` edits do not trigger a sync.\n\n## Command reference (cms_edit args)\n\n**Discovery:** `list --type <type>`, `search <query>`, `schema <contentType>`, `index sync`, `index status`\n\n**Reading:** `open --page-slug <slug>`, `open --id <id>`, `peek --page-slug <slug>`, `peek --id <id>`, `snapshot`, `read <ref>`, `read <ref> <field>`, `read <id> --id [field]`\n\n**Diagnostics:** `diagnose` \u2014 session store, userId, active session (after open/read issues)\n\n**Editing:** `set <ref> <field> <value>`, `rtf <ref> <field> --content \"<md>\"`, `diff`, `save`, `discard`\n\n**Creating:** `create page --slug \u2026 --title \u2026`, `create article --slug \u2026 --title \u2026 --article-type-slug \u2026`, `create from-json --file \u2026`, `add <type> --content-type \u2026 --parent @c0 --target content`\n\n**Other:** `health`, `version`, `guide [topic]`\n";
|
|
1
|
+
export declare const HOSTED_GUIDE_TEMPLATE = "# cms-edit MCP guide\n\nUse this guide when editing Contentful draft content through a hosted MCP connector (Claude Desktop Integrations + OAuth, or Grok Build).\n\n{{SITE_INTRO}}\n\n## Safety rules\n\ncms-edit **cannot and will not**:\n\n- Publish or unpublish entries\n- Archive or delete published entries\n\nAll `save` operations create **drafts only**. A human must review and publish in Contentful.\n\n**Assets:** cms-edit **can upload** draft assets (`asset upload` from file, URL, or base64). Always **search and reuse existing assets first** (`index sync`, then `asset search` or `list --type media`). Use `--if-exists-by-filename` when uploading to avoid duplicates.\n\n## MCP tools\n\n| Tool | Purpose |\n|------|---------|\n| `cms_edit` | Run any cms-edit command via an `args` array |\n| `cms_edit_version` | Check the installed cms-edit version (no session required) |\n| `cms_edit_help` | Read this guide by topic (`overview`, `workflow`, `commands`, `troubleshooting`, `hosted`) |\n\n## Customer editor pack (read first)\n\nWhen a site editor pack is deployed, these MCP resources provide **site-specific** context. Read them before creating or editing content:\n\n| Resource | Purpose |\n|----------|---------|\n| `cms-edit://customer/index` | List of all customer resources |\n| `cms-edit://customer/tasks-index` | Intent \u2192 task playbook map (filtered for this site) |\n| `cms-edit://customer/capabilities` | Machine-readable list of what this site supports |\n| `cms-edit://customer/checklist` | First-session onboarding steps |\n| `cms-edit://customer/overview` | Site name, space, staging URL, handoff rules |\n| `cms-edit://customer/routing` | Article/tag URL rules for this site |\n| `cms-edit://customer/production-site` | Production URL and how to fetch page markdown (do not guess `.md` URLs) |\n| `cms-edit://customer/components-index` | Component types and when to use each |\n| `cms-edit://customer/collections-index` | Collection types |\n| `cms-edit://customer/brand` | Brand voice and terminology (if configured) |\n| `cms-edit://customer/articles` | Article/publication playbook (if configured) |\n| `cms-edit://customer/defaults` | Featured image rules and article types (if configured) |\n| `cms-edit://customer/site-facts` | Optional canonical business facts (if configured) |\n| `cms-edit://customer/task-*` | Capability playbooks (e.g. `task-media-reuse-and-upload`) |\n\n**Workflow:** read `tasks-index` \u2192 `capabilities` \u2192 `checklist` \u2192 `overview` \u2192 `routing` \u2192 `production-site` \u2192 pick a `task-*` playbook for your goal \u2192 `components-index` \u2192 then use `cms_edit` commands.\n\n## MCP prompts\n\n| Prompt | Purpose |\n|--------|---------|\n| `cms_edit_verify` | Check version and connectivity |\n| `cms_edit_explore` | List site content and open a page |\n| `cms_edit_edit_page` | Edit a page through diff \u2192 save |\n| `cms_edit_edit_article` | Edit an article through diff \u2192 save |\n| `cms_edit_index_sync` | Build/refresh local index (assets, media, templates, taxonomy) |\n| `cms_edit_create_page` | Create a page with template selection |\n| `cms_edit_create_article` | Create an article (requires article type; featured image rules) |\n| `cms_edit_create_from_doc` | Create a page from a freeform document (infer \u2192 confirm \u2192 dry-run) |\n| `cms_edit_create_article_from_doc` | Create an article from a freeform document |\n| `cms_edit_taxonomy` | Import taxonomy entries (`create \u2026 --if-not-exists`) |\n| `cms_edit_bulk_seo` | Update SEO meta descriptions (read `task-seo-descriptions`) |\n| `cms_edit_bulk_find_replace` | Bulk find-replace in rich text across entries |\n| `cms_edit_bulk_article_tags` | Update tags on one or more articles |\n| `cms_edit_import_authors` | Create person/author entries from a list or sheet |\n| `cms_edit_media` | Find existing assets or upload new ones (reuse-first) |\n\nRead the full guide anytime via the `cms-edit://guide` resource or `cms_edit_help`.\n\n## End-to-end QA prompt\n\nFor release QA after cms-edit or editor-pack upgrades, use a **copy-paste Claude Desktop test script** (phases: connector \u2192 customer resources \u2192 discovery \u2192 session \u2192 schema \u2192 media \u2192 dry-run writes \u2192 negatives). See [e2e-test-prompt.md](./e2e-test-prompt.md) to author one per customer site. Example: Brightline `docs/cms-edit/MCP-E2E-TEST.md`.\n\n## Core workflow\n\nStandard editing flow: **open \u2192 snapshot \u2192 read \u2192 set/rtf \u2192 diff \u2192 save**\n\nEach step is a separate `cms_edit` call. Sessions persist in Redis between calls (hosted) or on disk (local). MCP auto-uses session `_mcp`.\n\n### 1. Open a page\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"open\", \"--page-slug\", \"/pricing\"]\n[\"open\", \"--id\", \"<entry-id>\"]\n```\n\n**Homepage (all SE Studio sites):** Contentful stores the marketing homepage slug as `index`. The live site URL is `/`. In cms-edit, `--page-slug /` and `--page-slug /index` are equivalent (both resolve to `index`). Read `cms-edit://customer/routing` for site-specific exceptions (e.g. Pedestal uses `home`).\n\n### 2. Snapshot \u2014 see the content tree\n\n```\n[\"snapshot\"]\n```\n\nOutput shows `@c0`, `@c1`, \u2026 refs for each component. Use these refs in `read`, `set`, and `rtf`.\n\n### 3. Read fields\n\n```\n[\"read\", \"@c1\"]\n[\"read\", \"@c1\", \"heading\"]\n```\n\n### 4. Edit fields\n\n```\n[\"set\", \"@c1\", \"heading\", \"New heading text\"]\n[\"rtf\", \"@c1\", \"body\", \"--content\", \"# Title\\n\\nParagraph text.\"]\n```\n\nFor rich text, prefer `--content` with inline markdown. Use `--base64` when special characters cause issues.\n\n### 5. Review and save\n\n```\n[\"diff\"]\n[\"save\"]\n```\n\nAlways run `diff` before `save`. To abandon changes: `[\"discard\"]`.\n\n## When to use Contentful UI\n\n| Task | Where |\n|------|-------|\n| Edit copy, add sections, create pages/articles | **Claude + cms-edit** (drafts) |\n| Publish approved drafts | **Contentful UI** |\n| Upload new images and files | **Contentful UI** asset library |\n| Edit copy directly in Contentful | **Avoid** \u2014 use Claude instead |\n\ncms-edit saves **drafts only**. A colleague must **publish in Contentful** for changes to go live.\n\n## Featured images (articles)\n\nRead `cms-edit://customer/defaults` when present. Otherwise:\n\n1. **Custom** \u2014 set `featuredImage` or `featuredImageAssetFilename` on the article when the editor provides a specific image\n2. **Article type** \u2014 if omitted, cms-edit inherits the linked **articleType** `featuredImage`\n3. **Site default** \u2014 from `editor.defaults` in the site config (also in `defaults.json` in the editor pack)\n\nRun `[\"index\", \"sync\"]` before resolving assets by filename.\n\n## Create content\n\n### Create a page\n\n```\n[\"index\", \"sync\"]\n[\"list\", \"--type\", \"template\"]\n[\"create\", \"page\", \"--slug\", \"/about-us\", \"--title\", \"About Us\", \"--template-id\", \"<id>\"]\n[\"snapshot\"]\n```\n\nOr use `create from-json` with `--dry-run --strict` for multi-section pages.\n\n### Create an article\n\nEvery article requires an **articleType**:\n\n```\n[\"index\", \"sync\"]\n[\"list\", \"--type\", \"articleType\"]\n[\"create\", \"article\", \"--slug\", \"resources/blog/my-post\", \"--title\", \"My Post\", \"--article-type-slug\", \"resources/blog\"]\n```\n\nOr `create from-json` with `\"type\": \"article\"` and `articleTypeSlug` / `articleTypeId`.\n\nUse MCP prompt `cms_edit_create_article` for guided creation.\n\n## Common sequences\n\n### List all pages\n\n```\n[\"list\", \"--type\", \"page\"]\n```\n\n### Refresh local index (assets, media, templates, taxonomy)\n\nRun before asset filename search, media-by-filename list, or fast template/taxonomy lookup:\n\n```\n[\"index\", \"sync\"]\n[\"index\", \"status\"]\n[\"list\", \"--type\", \"template\"]\n```\n\nAsset search and media-by-filename list **require** the index. Template/taxonomy list prefers the index when built.\n\n### Explore the homepage\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"snapshot\"]\n[\"read\", \"@c1\"]\n```\n\n### Edit copy on a page\n\n```\n[\"open\", \"--page-slug\", \"{{EXAMPLE_SLUG}}\"]\n[\"snapshot\"]\n[\"read\", \"@c1\", \"heading\"]\n[\"set\", \"@c1\", \"heading\", \"Updated heading\"]\n[\"diff\"]\n[\"save\"]\n```\n\n## Field discovery\n\n```\n[\"schema\", \"component\"]\n[\"list\", \"--type\", \"page\"]\n[\"search\", \"pricing\"]\n```\n\n## Grok Build setup\n\nGrok connects to the same hosted MCP URL as Claude. Add to `~/.grok/config.toml`:\n\n```toml\n[mcp_servers.cms-edit-brightline]\nurl = \"https://brightline.content.se.studio/api/mcp\"\nenabled = true\n```\n\nReplace the server name and host with your site's deployment. The URL **must** end with `/api/mcp` (not the site root).\n\n**Connect:**\n\n1. In Grok, run `/mcps` and select your cms-edit server\n2. Press **`i`** to initiate OAuth (not just enable the toggle)\n3. Sign in with Contentful when the browser opens\n4. Verify with `grok mcp doctor <server-name>` or call `cms_edit_version`\n\nOAuth is two steps: Grok obtains an MCP token, then you sign in with Contentful to link your account. If the browser flashes and closes immediately, reconnect after upgrading cms-edit (loopback redirect handling).\n\n## Hosted connector rules\n\n{{HOSTED_RULES}}\n\n## Session tips\n\n- After `open`, subsequent MCP commands share session `_mcp` automatically (stored in Redis on hosted).\n- Use `--session <name>` only when juggling multiple pages \u2014 pass it **before** the subcommand on every call: `[\"--session\", \"my-work\", \"open\", \"--page-slug\", \"/\"]`.\n- Snapshot JSON includes `sessionName` and `sessionKey` for debugging.\n- If you see \"No active session\", check `/api/health` (Redis must be ok), then run `open` again. Set `LOG_CMS_SESSION=1` on Vercel and search runtime logs for `[cms-edit:session]` (`redis save ok` / `redis load hit` / `requireSession miss`).\n\n### peek vs open vs read\n\n| Goal | MCP args |\n|------|----------|\n| Edit workflow (session) | `[\"open\", \"--page-slug\", \"/\"]` then `[\"read\", \"@c0\"]` |\n| Preview tree + fields, no session | `[\"peek\", \"--page-slug\", \"/pricing\"]` or `[\"peek\", \"--id\", \"<entry-id>\"]` (JSON includes `rootFields`) |\n| Read fields by entry ID, no session | `[\"read\", \"<entry-id>\", \"--id\"]` or `[\"read\", \"<entry-id>\", \"--id\", \"heading\"]` |\n| Debug session persistence | `[\"diagnose\"]` \u2014 reports store, userId, active session key |\n\n- **`peek` is one-shot** \u2014 prints tree and **root field values** (`rootFields` in JSON). No session is created; do not chain `read @ref` afterward.\n- **Use flat lookup flags** for `open` and `peek` \u2014 same as CLI (`--page-slug`, `--id`, etc.). See `help lookup`.\n- **`read @root`** only works after `open` (uses the active session). The hint in peek output is for terminal users who already ran `open`.\n- **Do not invent flags** \u2014 there is no `--read`, `--then`, or chained peek+read syntax. One command per `cms_edit` call.\n\n## Troubleshooting\n\n| Problem | What to do |\n|---------|------------|\n| **401 / connection failed** | Reconnect: Claude \u2192 Settings \u2192 Integrations, or Grok `/mcps` \u2192 press `i`. Complete Contentful sign-in. On Vercel, search runtime logs for `[cms-edit:oauth] auth_failure` (always logged). Set `LOG_CMS_OAUTH=1` for connect success traces. |\n| **No cms_edit tool** | Confirm the integration is connected under Settings \u2192 Integrations |\n| **No active session** | Do not pass `--space` on hosted. Check `/api/health` \u2014 `redis` must be ok. MCP uses `_mcp` session automatically. Manual session: `[\"--session\", \"name\", \"open\", \"--page-slug\", \"/\"]`. Fallback: `[\"read\", \"<entry-id>\", \"--id\"]` |\n| **Wrong space** | Your Contentful account must have access to this deployment's space |\n| **Check version** | Call `cms_edit_version` or `curl /api/health` and read `cmsEdit` |\n\n## Articles\n\n**Recent articles** (by publication `date`, not last-updated):\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\", \"-n\", \"10\"]\n```\n\nAlternative: `[\"search\", \"<keyword>\", \"--type\", \"article\"]` (also sorts by date).\n\n**Draft articles** \u2014 `peek` and `open` load drafts via CMA (not published-only). To discover drafts:\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\"]\n[\"search\", \"<title>\", \"--type\", \"article\"]\n[\"list\", \"--type\", \"article\", \"--slug\", \"<slug>\"]\n```\n\nThen open: `[\"peek\", \"--article-slug\", \"<slug>\"]` or `[\"open\", \"--id\", \"<entry-id>\"]`. Use `--article-slug`, not `--page-slug`.\n\n**Published-only** is opt-in: `list --published` and `resolve --published` use the Delivery API index and omit never-published drafts.\n\nAfter upgrading cms-edit, run `[\"index\", \"sync\"]` once so the local index includes article `date` values (schema v4).\n\n**Index freshness on hosted MCP:** The catalog index is shared via Redis (gzipped SQLite blob). `index status` on a cold instance may show **not built** until `list`, `open`, or another index command runs \u2014 that is normal. Committed writes (`save`, `create page`, `asset upload`, \u2026) mark the index dirty; the next discovery command refreshes it. In-session `set` edits do not trigger a sync.\n\n## Command reference (cms_edit args)\n\n**Discovery:** `list --type <type>`, `search <query>`, `schema <contentType>`, `index sync`, `index status`\n\n**Reading:** `open --page-slug <slug>`, `open --id <id>`, `peek --page-slug <slug>`, `peek --id <id>`, `snapshot`, `read <ref>`, `read <ref> <field>`, `read <id> --id [field]`\n\n**Diagnostics:** `diagnose` \u2014 session store, userId, active session (after open/read issues)\n\n**Editing:** `set <ref> <field> <value>`, `rtf <ref> <field> --content \"<md>\"`, `diff`, `save`, `discard`\n\n**Creating:** `create page --slug \u2026 --title \u2026`, `create article --slug \u2026 --title \u2026 --article-type-slug \u2026`, `create from-json --file \u2026`, `add <type> --content-type \u2026 --parent @c0 --target content`\n\n**Other:** `health`, `version`, `guide [topic]`\n";
|
|
2
2
|
//# sourceMappingURL=hosted-guide.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-guide.d.ts","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"hosted-guide.d.ts","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,u4bAA8nb,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Generated by scripts/generate-embedded-assets.mjs — do not edit manually.
|
|
2
|
-
export const HOSTED_GUIDE_TEMPLATE = "# cms-edit MCP guide\n\nUse this guide when editing Contentful draft content through Claude Desktop (hosted Integrations + OAuth).\n\n{{SITE_INTRO}}\n\n## Safety rules\n\ncms-edit **cannot and will not**:\n\n- Publish or unpublish entries\n- Archive or delete published entries\n\nAll `save` operations create **drafts only**. A human must review and publish in Contentful.\n\n**Assets:** cms-edit **can upload** draft assets (`asset upload` from file, URL, or base64). Always **search and reuse existing assets first** (`index sync`, then `asset search` or `list --type media`). Use `--if-exists-by-filename` when uploading to avoid duplicates.\n\n## MCP tools\n\n| Tool | Purpose |\n|------|---------|\n| `cms_edit` | Run any cms-edit command via an `args` array |\n| `cms_edit_version` | Check the installed cms-edit version (no session required) |\n| `cms_edit_help` | Read this guide by topic (`overview`, `workflow`, `commands`, `troubleshooting`, `hosted`) |\n\n## Customer editor pack (read first)\n\nWhen a site editor pack is deployed, these MCP resources provide **site-specific** context. Read them before creating or editing content:\n\n| Resource | Purpose |\n|----------|---------|\n| `cms-edit://customer/index` | List of all customer resources |\n| `cms-edit://customer/tasks-index` | Intent → task playbook map (filtered for this site) |\n| `cms-edit://customer/capabilities` | Machine-readable list of what this site supports |\n| `cms-edit://customer/checklist` | First-session onboarding steps |\n| `cms-edit://customer/overview` | Site name, space, staging URL, handoff rules |\n| `cms-edit://customer/routing` | Article/tag URL rules for this site |\n| `cms-edit://customer/production-site` | Production URL and how to fetch page markdown (do not guess `.md` URLs) |\n| `cms-edit://customer/components-index` | Component types and when to use each |\n| `cms-edit://customer/collections-index` | Collection types |\n| `cms-edit://customer/brand` | Brand voice and terminology (if configured) |\n| `cms-edit://customer/articles` | Article/publication playbook (if configured) |\n| `cms-edit://customer/defaults` | Featured image rules and article types (if configured) |\n| `cms-edit://customer/site-facts` | Optional canonical business facts (if configured) |\n| `cms-edit://customer/task-*` | Capability playbooks (e.g. `task-media-reuse-and-upload`) |\n\n**Workflow:** read `tasks-index` → `capabilities` → `checklist` → `overview` → `routing` → `production-site` → pick a `task-*` playbook for your goal → `components-index` → then use `cms_edit` commands.\n\n## MCP prompts\n\n| Prompt | Purpose |\n|--------|---------|\n| `cms_edit_verify` | Check version and connectivity |\n| `cms_edit_explore` | List site content and open a page |\n| `cms_edit_edit_page` | Edit a page through diff → save |\n| `cms_edit_edit_article` | Edit an article through diff → save |\n| `cms_edit_index_sync` | Build/refresh local index (assets, media, templates, taxonomy) |\n| `cms_edit_create_page` | Create a page with template selection |\n| `cms_edit_create_article` | Create an article (requires article type; featured image rules) |\n| `cms_edit_create_from_doc` | Create a page from a freeform document (infer → confirm → dry-run) |\n| `cms_edit_create_article_from_doc` | Create an article from a freeform document |\n| `cms_edit_taxonomy` | Import taxonomy entries (`create … --if-not-exists`) |\n| `cms_edit_bulk_seo` | Update SEO meta descriptions (read `task-seo-descriptions`) |\n| `cms_edit_bulk_find_replace` | Bulk find-replace in rich text across entries |\n| `cms_edit_bulk_article_tags` | Update tags on one or more articles |\n| `cms_edit_import_authors` | Create person/author entries from a list or sheet |\n| `cms_edit_media` | Find existing assets or upload new ones (reuse-first) |\n\nRead the full guide anytime via the `cms-edit://guide` resource or `cms_edit_help`.\n\n## End-to-end QA prompt\n\nFor release QA after cms-edit or editor-pack upgrades, use a **copy-paste Claude Desktop test script** (phases: connector → customer resources → discovery → session → schema → media → dry-run writes → negatives). See [e2e-test-prompt.md](./e2e-test-prompt.md) to author one per customer site. Example: Brightline `docs/cms-edit/MCP-E2E-TEST.md`.\n\n## Core workflow\n\nStandard editing flow: **open → snapshot → read → set/rtf → diff → save**\n\nEach step is a separate `cms_edit` call. Sessions persist in Redis between calls (hosted) or on disk (local). MCP auto-uses session `_mcp`.\n\n### 1. Open a page\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"open\", \"--page-slug\", \"/pricing\"]\n[\"open\", \"--id\", \"<entry-id>\"]\n```\n\n**Homepage (all SE Studio sites):** Contentful stores the marketing homepage slug as `index`. The live site URL is `/`. In cms-edit, `--page-slug /` and `--page-slug /index` are equivalent (both resolve to `index`). Read `cms-edit://customer/routing` for site-specific exceptions (e.g. Pedestal uses `home`).\n\n### 2. Snapshot — see the content tree\n\n```\n[\"snapshot\"]\n```\n\nOutput shows `@c0`, `@c1`, … refs for each component. Use these refs in `read`, `set`, and `rtf`.\n\n### 3. Read fields\n\n```\n[\"read\", \"@c1\"]\n[\"read\", \"@c1\", \"heading\"]\n```\n\n### 4. Edit fields\n\n```\n[\"set\", \"@c1\", \"heading\", \"New heading text\"]\n[\"rtf\", \"@c1\", \"body\", \"--content\", \"# Title\\n\\nParagraph text.\"]\n```\n\nFor rich text, prefer `--content` with inline markdown. Use `--base64` when special characters cause issues.\n\n### 5. Review and save\n\n```\n[\"diff\"]\n[\"save\"]\n```\n\nAlways run `diff` before `save`. To abandon changes: `[\"discard\"]`.\n\n## When to use Contentful UI\n\n| Task | Where |\n|------|-------|\n| Edit copy, add sections, create pages/articles | **Claude + cms-edit** (drafts) |\n| Publish approved drafts | **Contentful UI** |\n| Upload new images and files | **Contentful UI** asset library |\n| Edit copy directly in Contentful | **Avoid** — use Claude instead |\n\ncms-edit saves **drafts only**. A colleague must **publish in Contentful** for changes to go live.\n\n## Featured images (articles)\n\nRead `cms-edit://customer/defaults` when present. Otherwise:\n\n1. **Custom** — set `featuredImage` or `featuredImageAssetFilename` on the article when the editor provides a specific image\n2. **Article type** — if omitted, cms-edit inherits the linked **articleType** `featuredImage`\n3. **Site default** — from `editor.defaults` in the site config (also in `defaults.json` in the editor pack)\n\nRun `[\"index\", \"sync\"]` before resolving assets by filename.\n\n## Create content\n\n### Create a page\n\n```\n[\"index\", \"sync\"]\n[\"list\", \"--type\", \"template\"]\n[\"create\", \"page\", \"--slug\", \"/about-us\", \"--title\", \"About Us\", \"--template-id\", \"<id>\"]\n[\"snapshot\"]\n```\n\nOr use `create from-json` with `--dry-run --strict` for multi-section pages.\n\n### Create an article\n\nEvery article requires an **articleType**:\n\n```\n[\"index\", \"sync\"]\n[\"list\", \"--type\", \"articleType\"]\n[\"create\", \"article\", \"--slug\", \"resources/blog/my-post\", \"--title\", \"My Post\", \"--article-type-slug\", \"resources/blog\"]\n```\n\nOr `create from-json` with `\"type\": \"article\"` and `articleTypeSlug` / `articleTypeId`.\n\nUse MCP prompt `cms_edit_create_article` for guided creation.\n\n## Common sequences\n\n### List all pages\n\n```\n[\"list\", \"--type\", \"page\"]\n```\n\n### Refresh local index (assets, media, templates, taxonomy)\n\nRun before asset filename search, media-by-filename list, or fast template/taxonomy lookup:\n\n```\n[\"index\", \"sync\"]\n[\"index\", \"status\"]\n[\"list\", \"--type\", \"template\"]\n```\n\nAsset search and media-by-filename list **require** the index. Template/taxonomy list prefers the index when built.\n\n### Explore the homepage\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"snapshot\"]\n[\"read\", \"@c1\"]\n```\n\n### Edit copy on a page\n\n```\n[\"open\", \"--page-slug\", \"{{EXAMPLE_SLUG}}\"]\n[\"snapshot\"]\n[\"read\", \"@c1\", \"heading\"]\n[\"set\", \"@c1\", \"heading\", \"Updated heading\"]\n[\"diff\"]\n[\"save\"]\n```\n\n## Field discovery\n\n```\n[\"schema\", \"component\"]\n[\"list\", \"--type\", \"page\"]\n[\"search\", \"pricing\"]\n```\n\n## Hosted connector rules\n\n{{HOSTED_RULES}}\n\n## Session tips\n\n- After `open`, subsequent MCP commands share session `_mcp` automatically (stored in Redis on hosted).\n- Use `--session <name>` only when juggling multiple pages — pass it **before** the subcommand on every call: `[\"--session\", \"my-work\", \"open\", \"--page-slug\", \"/\"]`.\n- Snapshot JSON includes `sessionName` and `sessionKey` for debugging.\n- If you see \"No active session\", check `/api/health` (Redis must be ok), then run `open` again. Set `LOG_CMS_SESSION=1` on Vercel and search runtime logs for `[cms-edit:session]` (`redis save ok` / `redis load hit` / `requireSession miss`).\n\n### peek vs open vs read\n\n| Goal | MCP args |\n|------|----------|\n| Edit workflow (session) | `[\"open\", \"--page-slug\", \"/\"]` then `[\"read\", \"@c0\"]` |\n| Preview tree + fields, no session | `[\"peek\", \"--page-slug\", \"/pricing\"]` or `[\"peek\", \"--id\", \"<entry-id>\"]` (JSON includes `rootFields`) |\n| Read fields by entry ID, no session | `[\"read\", \"<entry-id>\", \"--id\"]` or `[\"read\", \"<entry-id>\", \"--id\", \"heading\"]` |\n| Debug session persistence | `[\"diagnose\"]` — reports store, userId, active session key |\n\n- **`peek` is one-shot** — prints tree and **root field values** (`rootFields` in JSON). No session is created; do not chain `read @ref` afterward.\n- **Use flat lookup flags** for `open` and `peek` — same as CLI (`--page-slug`, `--id`, etc.). See `help lookup`.\n- **`read @root`** only works after `open` (uses the active session). The hint in peek output is for terminal users who already ran `open`.\n- **Do not invent flags** — there is no `--read`, `--then`, or chained peek+read syntax. One command per `cms_edit` call.\n\n## Troubleshooting\n\n| Problem | What to do |\n|---------|------------|\n| **401 / connection failed** | Claude → Settings → Integrations → Connect again; complete Contentful sign-in. On Vercel, search runtime logs for `[cms-edit:oauth] auth_failure` (always logged). Set `LOG_CMS_OAUTH=1` for connect success traces. |\n| **No cms_edit tool** | Confirm the integration is connected under Settings → Integrations |\n| **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\", \"--page-slug\", \"/\"]`. Fallback: `[\"read\", \"<entry-id>\", \"--id\"]` |\n| **Wrong space** | Your Contentful account must have access to this deployment's space |\n| **Check version** | Call `cms_edit_version` or `curl /api/health` and read `cmsEdit` |\n\n## Articles\n\n**Recent articles** (by publication `date`, not last-updated):\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\", \"-n\", \"10\"]\n```\n\nAlternative: `[\"search\", \"<keyword>\", \"--type\", \"article\"]` (also sorts by date).\n\n**Draft articles** — `peek` and `open` load drafts via CMA (not published-only). To discover drafts:\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\"]\n[\"search\", \"<title>\", \"--type\", \"article\"]\n[\"list\", \"--type\", \"article\", \"--slug\", \"<slug>\"]\n```\n\nThen open: `[\"peek\", \"--article-slug\", \"<slug>\"]` or `[\"open\", \"--id\", \"<entry-id>\"]`. Use `--article-slug`, not `--page-slug`.\n\n**Published-only** is opt-in: `list --published` and `resolve --published` use the Delivery API index and omit never-published drafts.\n\nAfter upgrading cms-edit, run `[\"index\", \"sync\"]` once so the local index includes article `date` values (schema v4).\n\n**Index freshness on hosted MCP:** The catalog index is shared via Redis (gzipped SQLite blob). `index status` on a cold instance may show **not built** until `list`, `open`, or another index command runs — that is normal. Committed writes (`save`, `create page`, `asset upload`, …) mark the index dirty; the next discovery command refreshes it. In-session `set` edits do not trigger a sync.\n\n## Command reference (cms_edit args)\n\n**Discovery:** `list --type <type>`, `search <query>`, `schema <contentType>`, `index sync`, `index status`\n\n**Reading:** `open --page-slug <slug>`, `open --id <id>`, `peek --page-slug <slug>`, `peek --id <id>`, `snapshot`, `read <ref>`, `read <ref> <field>`, `read <id> --id [field]`\n\n**Diagnostics:** `diagnose` — session store, userId, active session (after open/read issues)\n\n**Editing:** `set <ref> <field> <value>`, `rtf <ref> <field> --content \"<md>\"`, `diff`, `save`, `discard`\n\n**Creating:** `create page --slug … --title …`, `create article --slug … --title … --article-type-slug …`, `create from-json --file …`, `add <type> --content-type … --parent @c0 --target content`\n\n**Other:** `health`, `version`, `guide [topic]`\n";
|
|
2
|
+
export const HOSTED_GUIDE_TEMPLATE = "# cms-edit MCP guide\n\nUse this guide when editing Contentful draft content through a hosted MCP connector (Claude Desktop Integrations + OAuth, or Grok Build).\n\n{{SITE_INTRO}}\n\n## Safety rules\n\ncms-edit **cannot and will not**:\n\n- Publish or unpublish entries\n- Archive or delete published entries\n\nAll `save` operations create **drafts only**. A human must review and publish in Contentful.\n\n**Assets:** cms-edit **can upload** draft assets (`asset upload` from file, URL, or base64). Always **search and reuse existing assets first** (`index sync`, then `asset search` or `list --type media`). Use `--if-exists-by-filename` when uploading to avoid duplicates.\n\n## MCP tools\n\n| Tool | Purpose |\n|------|---------|\n| `cms_edit` | Run any cms-edit command via an `args` array |\n| `cms_edit_version` | Check the installed cms-edit version (no session required) |\n| `cms_edit_help` | Read this guide by topic (`overview`, `workflow`, `commands`, `troubleshooting`, `hosted`) |\n\n## Customer editor pack (read first)\n\nWhen a site editor pack is deployed, these MCP resources provide **site-specific** context. Read them before creating or editing content:\n\n| Resource | Purpose |\n|----------|---------|\n| `cms-edit://customer/index` | List of all customer resources |\n| `cms-edit://customer/tasks-index` | Intent → task playbook map (filtered for this site) |\n| `cms-edit://customer/capabilities` | Machine-readable list of what this site supports |\n| `cms-edit://customer/checklist` | First-session onboarding steps |\n| `cms-edit://customer/overview` | Site name, space, staging URL, handoff rules |\n| `cms-edit://customer/routing` | Article/tag URL rules for this site |\n| `cms-edit://customer/production-site` | Production URL and how to fetch page markdown (do not guess `.md` URLs) |\n| `cms-edit://customer/components-index` | Component types and when to use each |\n| `cms-edit://customer/collections-index` | Collection types |\n| `cms-edit://customer/brand` | Brand voice and terminology (if configured) |\n| `cms-edit://customer/articles` | Article/publication playbook (if configured) |\n| `cms-edit://customer/defaults` | Featured image rules and article types (if configured) |\n| `cms-edit://customer/site-facts` | Optional canonical business facts (if configured) |\n| `cms-edit://customer/task-*` | Capability playbooks (e.g. `task-media-reuse-and-upload`) |\n\n**Workflow:** read `tasks-index` → `capabilities` → `checklist` → `overview` → `routing` → `production-site` → pick a `task-*` playbook for your goal → `components-index` → then use `cms_edit` commands.\n\n## MCP prompts\n\n| Prompt | Purpose |\n|--------|---------|\n| `cms_edit_verify` | Check version and connectivity |\n| `cms_edit_explore` | List site content and open a page |\n| `cms_edit_edit_page` | Edit a page through diff → save |\n| `cms_edit_edit_article` | Edit an article through diff → save |\n| `cms_edit_index_sync` | Build/refresh local index (assets, media, templates, taxonomy) |\n| `cms_edit_create_page` | Create a page with template selection |\n| `cms_edit_create_article` | Create an article (requires article type; featured image rules) |\n| `cms_edit_create_from_doc` | Create a page from a freeform document (infer → confirm → dry-run) |\n| `cms_edit_create_article_from_doc` | Create an article from a freeform document |\n| `cms_edit_taxonomy` | Import taxonomy entries (`create … --if-not-exists`) |\n| `cms_edit_bulk_seo` | Update SEO meta descriptions (read `task-seo-descriptions`) |\n| `cms_edit_bulk_find_replace` | Bulk find-replace in rich text across entries |\n| `cms_edit_bulk_article_tags` | Update tags on one or more articles |\n| `cms_edit_import_authors` | Create person/author entries from a list or sheet |\n| `cms_edit_media` | Find existing assets or upload new ones (reuse-first) |\n\nRead the full guide anytime via the `cms-edit://guide` resource or `cms_edit_help`.\n\n## End-to-end QA prompt\n\nFor release QA after cms-edit or editor-pack upgrades, use a **copy-paste Claude Desktop test script** (phases: connector → customer resources → discovery → session → schema → media → dry-run writes → negatives). See [e2e-test-prompt.md](./e2e-test-prompt.md) to author one per customer site. Example: Brightline `docs/cms-edit/MCP-E2E-TEST.md`.\n\n## Core workflow\n\nStandard editing flow: **open → snapshot → read → set/rtf → diff → save**\n\nEach step is a separate `cms_edit` call. Sessions persist in Redis between calls (hosted) or on disk (local). MCP auto-uses session `_mcp`.\n\n### 1. Open a page\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"open\", \"--page-slug\", \"/pricing\"]\n[\"open\", \"--id\", \"<entry-id>\"]\n```\n\n**Homepage (all SE Studio sites):** Contentful stores the marketing homepage slug as `index`. The live site URL is `/`. In cms-edit, `--page-slug /` and `--page-slug /index` are equivalent (both resolve to `index`). Read `cms-edit://customer/routing` for site-specific exceptions (e.g. Pedestal uses `home`).\n\n### 2. Snapshot — see the content tree\n\n```\n[\"snapshot\"]\n```\n\nOutput shows `@c0`, `@c1`, … refs for each component. Use these refs in `read`, `set`, and `rtf`.\n\n### 3. Read fields\n\n```\n[\"read\", \"@c1\"]\n[\"read\", \"@c1\", \"heading\"]\n```\n\n### 4. Edit fields\n\n```\n[\"set\", \"@c1\", \"heading\", \"New heading text\"]\n[\"rtf\", \"@c1\", \"body\", \"--content\", \"# Title\\n\\nParagraph text.\"]\n```\n\nFor rich text, prefer `--content` with inline markdown. Use `--base64` when special characters cause issues.\n\n### 5. Review and save\n\n```\n[\"diff\"]\n[\"save\"]\n```\n\nAlways run `diff` before `save`. To abandon changes: `[\"discard\"]`.\n\n## When to use Contentful UI\n\n| Task | Where |\n|------|-------|\n| Edit copy, add sections, create pages/articles | **Claude + cms-edit** (drafts) |\n| Publish approved drafts | **Contentful UI** |\n| Upload new images and files | **Contentful UI** asset library |\n| Edit copy directly in Contentful | **Avoid** — use Claude instead |\n\ncms-edit saves **drafts only**. A colleague must **publish in Contentful** for changes to go live.\n\n## Featured images (articles)\n\nRead `cms-edit://customer/defaults` when present. Otherwise:\n\n1. **Custom** — set `featuredImage` or `featuredImageAssetFilename` on the article when the editor provides a specific image\n2. **Article type** — if omitted, cms-edit inherits the linked **articleType** `featuredImage`\n3. **Site default** — from `editor.defaults` in the site config (also in `defaults.json` in the editor pack)\n\nRun `[\"index\", \"sync\"]` before resolving assets by filename.\n\n## Create content\n\n### Create a page\n\n```\n[\"index\", \"sync\"]\n[\"list\", \"--type\", \"template\"]\n[\"create\", \"page\", \"--slug\", \"/about-us\", \"--title\", \"About Us\", \"--template-id\", \"<id>\"]\n[\"snapshot\"]\n```\n\nOr use `create from-json` with `--dry-run --strict` for multi-section pages.\n\n### Create an article\n\nEvery article requires an **articleType**:\n\n```\n[\"index\", \"sync\"]\n[\"list\", \"--type\", \"articleType\"]\n[\"create\", \"article\", \"--slug\", \"resources/blog/my-post\", \"--title\", \"My Post\", \"--article-type-slug\", \"resources/blog\"]\n```\n\nOr `create from-json` with `\"type\": \"article\"` and `articleTypeSlug` / `articleTypeId`.\n\nUse MCP prompt `cms_edit_create_article` for guided creation.\n\n## Common sequences\n\n### List all pages\n\n```\n[\"list\", \"--type\", \"page\"]\n```\n\n### Refresh local index (assets, media, templates, taxonomy)\n\nRun before asset filename search, media-by-filename list, or fast template/taxonomy lookup:\n\n```\n[\"index\", \"sync\"]\n[\"index\", \"status\"]\n[\"list\", \"--type\", \"template\"]\n```\n\nAsset search and media-by-filename list **require** the index. Template/taxonomy list prefers the index when built.\n\n### Explore the homepage\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"snapshot\"]\n[\"read\", \"@c1\"]\n```\n\n### Edit copy on a page\n\n```\n[\"open\", \"--page-slug\", \"{{EXAMPLE_SLUG}}\"]\n[\"snapshot\"]\n[\"read\", \"@c1\", \"heading\"]\n[\"set\", \"@c1\", \"heading\", \"Updated heading\"]\n[\"diff\"]\n[\"save\"]\n```\n\n## Field discovery\n\n```\n[\"schema\", \"component\"]\n[\"list\", \"--type\", \"page\"]\n[\"search\", \"pricing\"]\n```\n\n## Grok Build setup\n\nGrok connects to the same hosted MCP URL as Claude. Add to `~/.grok/config.toml`:\n\n```toml\n[mcp_servers.cms-edit-brightline]\nurl = \"https://brightline.content.se.studio/api/mcp\"\nenabled = true\n```\n\nReplace the server name and host with your site's deployment. The URL **must** end with `/api/mcp` (not the site root).\n\n**Connect:**\n\n1. In Grok, run `/mcps` and select your cms-edit server\n2. Press **`i`** to initiate OAuth (not just enable the toggle)\n3. Sign in with Contentful when the browser opens\n4. Verify with `grok mcp doctor <server-name>` or call `cms_edit_version`\n\nOAuth is two steps: Grok obtains an MCP token, then you sign in with Contentful to link your account. If the browser flashes and closes immediately, reconnect after upgrading cms-edit (loopback redirect handling).\n\n## Hosted connector rules\n\n{{HOSTED_RULES}}\n\n## Session tips\n\n- After `open`, subsequent MCP commands share session `_mcp` automatically (stored in Redis on hosted).\n- Use `--session <name>` only when juggling multiple pages — pass it **before** the subcommand on every call: `[\"--session\", \"my-work\", \"open\", \"--page-slug\", \"/\"]`.\n- Snapshot JSON includes `sessionName` and `sessionKey` for debugging.\n- If you see \"No active session\", check `/api/health` (Redis must be ok), then run `open` again. Set `LOG_CMS_SESSION=1` on Vercel and search runtime logs for `[cms-edit:session]` (`redis save ok` / `redis load hit` / `requireSession miss`).\n\n### peek vs open vs read\n\n| Goal | MCP args |\n|------|----------|\n| Edit workflow (session) | `[\"open\", \"--page-slug\", \"/\"]` then `[\"read\", \"@c0\"]` |\n| Preview tree + fields, no session | `[\"peek\", \"--page-slug\", \"/pricing\"]` or `[\"peek\", \"--id\", \"<entry-id>\"]` (JSON includes `rootFields`) |\n| Read fields by entry ID, no session | `[\"read\", \"<entry-id>\", \"--id\"]` or `[\"read\", \"<entry-id>\", \"--id\", \"heading\"]` |\n| Debug session persistence | `[\"diagnose\"]` — reports store, userId, active session key |\n\n- **`peek` is one-shot** — prints tree and **root field values** (`rootFields` in JSON). No session is created; do not chain `read @ref` afterward.\n- **Use flat lookup flags** for `open` and `peek` — same as CLI (`--page-slug`, `--id`, etc.). See `help lookup`.\n- **`read @root`** only works after `open` (uses the active session). The hint in peek output is for terminal users who already ran `open`.\n- **Do not invent flags** — there is no `--read`, `--then`, or chained peek+read syntax. One command per `cms_edit` call.\n\n## Troubleshooting\n\n| Problem | What to do |\n|---------|------------|\n| **401 / connection failed** | Reconnect: Claude → Settings → Integrations, or Grok `/mcps` → press `i`. Complete Contentful sign-in. On Vercel, search runtime logs for `[cms-edit:oauth] auth_failure` (always logged). Set `LOG_CMS_OAUTH=1` for connect success traces. |\n| **No cms_edit tool** | Confirm the integration is connected under Settings → Integrations |\n| **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\", \"--page-slug\", \"/\"]`. Fallback: `[\"read\", \"<entry-id>\", \"--id\"]` |\n| **Wrong space** | Your Contentful account must have access to this deployment's space |\n| **Check version** | Call `cms_edit_version` or `curl /api/health` and read `cmsEdit` |\n\n## Articles\n\n**Recent articles** (by publication `date`, not last-updated):\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\", \"-n\", \"10\"]\n```\n\nAlternative: `[\"search\", \"<keyword>\", \"--type\", \"article\"]` (also sorts by date).\n\n**Draft articles** — `peek` and `open` load drafts via CMA (not published-only). To discover drafts:\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\"]\n[\"search\", \"<title>\", \"--type\", \"article\"]\n[\"list\", \"--type\", \"article\", \"--slug\", \"<slug>\"]\n```\n\nThen open: `[\"peek\", \"--article-slug\", \"<slug>\"]` or `[\"open\", \"--id\", \"<entry-id>\"]`. Use `--article-slug`, not `--page-slug`.\n\n**Published-only** is opt-in: `list --published` and `resolve --published` use the Delivery API index and omit never-published drafts.\n\nAfter upgrading cms-edit, run `[\"index\", \"sync\"]` once so the local index includes article `date` values (schema v4).\n\n**Index freshness on hosted MCP:** The catalog index is shared via Redis (gzipped SQLite blob). `index status` on a cold instance may show **not built** until `list`, `open`, or another index command runs — that is normal. Committed writes (`save`, `create page`, `asset upload`, …) mark the index dirty; the next discovery command refreshes it. In-session `set` edits do not trigger a sync.\n\n## Command reference (cms_edit args)\n\n**Discovery:** `list --type <type>`, `search <query>`, `schema <contentType>`, `index sync`, `index status`\n\n**Reading:** `open --page-slug <slug>`, `open --id <id>`, `peek --page-slug <slug>`, `peek --id <id>`, `snapshot`, `read <ref>`, `read <ref> <field>`, `read <id> --id [field]`\n\n**Diagnostics:** `diagnose` — session store, userId, active session (after open/read issues)\n\n**Editing:** `set <ref> <field> <value>`, `rtf <ref> <field> --content \"<md>\"`, `diff`, `save`, `discard`\n\n**Creating:** `create page --slug … --title …`, `create article --slug … --title … --article-type-slug …`, `create from-json --file …`, `add <type> --content-type … --parent @c0 --target content`\n\n**Other:** `health`, `version`, `guide [topic]`\n";
|
|
3
3
|
//# sourceMappingURL=hosted-guide.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-guide.js","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG
|
|
1
|
+
{"version":3,"file":"hosted-guide.js","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,2nbAA2nb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../../../src/hosted/oauth/complete.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../../../src/hosted/oauth/complete.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEjE,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,UAAU,EACjB,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED,wBAAsB,8BAA8B,CAClD,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE;IACL,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GACA,OAAO,CAAC;IACT,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC,CAuCD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { signMcpAccessToken } from './jwt.js';
|
|
3
3
|
import { generateAuthCode } from './pkce.js';
|
|
4
|
+
import { redirectUrisEquivalent } from './redirect-uri.js';
|
|
4
5
|
export async function issueAuthorizationRedirect(store, authRequestId, sub, request) {
|
|
5
6
|
const code = generateAuthCode();
|
|
6
7
|
await store.saveAuthCode(code, { authRequestId, sub });
|
|
@@ -23,7 +24,7 @@ export async function completeAuthorizationCodeGrant(store, input) {
|
|
|
23
24
|
if (authRequest.clientId !== input.clientId) {
|
|
24
25
|
throw new Error('Invalid client_id.');
|
|
25
26
|
}
|
|
26
|
-
if (authRequest.redirectUri
|
|
27
|
+
if (!redirectUrisEquivalent(authRequest.redirectUri, input.redirectUri)) {
|
|
27
28
|
throw new Error('Invalid redirect_uri.');
|
|
28
29
|
}
|
|
29
30
|
const { createHash } = await import('node:crypto');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complete.js","sourceRoot":"","sources":["../../../src/hosted/oauth/complete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"complete.js","sourceRoot":"","sources":["../../../src/hosted/oauth/complete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,KAAiB,EACjB,aAAqB,EACrB,GAAW,EACX,OAA2B;IAE3B,MAAM,IAAI,GAAG,gBAAgB,EAAE,CAAC;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AAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACnF,IAAI,MAAM,KAAK,WAAW,CAAC,aAAa,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,MAAM,kBAAkB,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAElG,MAAM,YAAY,GAAG,UAAU,EAAE,CAAC;IAClC,MAAM,KAAK,CAAC,gBAAgB,CAAC,YAAY,EAAE;QACzC,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,QAAQ,EAAE,WAAW,CAAC,QAAQ;KAC/B,CAAC,CAAC;IAEH,OAAO;QACL,WAAW;QACX,SAAS,EAAE,QAAQ;QACnB,SAAS;QACT,YAAY;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/hosted/oauth/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/hosted/oauth/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;AAgB/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,sBAAsB,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAeD,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,QAAQ,CAAC,CAuDnB;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,QAAQ,CAAC,CAyBnB;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,QAAQ,CAAC,CA0FnB;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,QAAQ,CAAC,CA8CnB;AAED,wBAAgB,yCAAyC,IAAI,QAAQ,CAYpE;AAED,wBAAgB,uCAAuC,IAAI,QAAQ,CAMlE;AAED,wBAAsB,sBAAsB,IAAI,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBvF"}
|
|
@@ -3,6 +3,7 @@ import { flushTelemetry, recordOAuthTelemetryFailure, recordOAuthTelemetrySucces
|
|
|
3
3
|
import { completeAuthorizationCodeGrant, issueAuthorizationRedirect } from './complete.js';
|
|
4
4
|
import { getContentfulAuthorizeUrl, getMcpResourceUrl, getPublicOrigin } from './config.js';
|
|
5
5
|
import { authorizationCodeGrantFailureReason, oauthLogAuthFailure, oauthLogVerbose, patValidationFailureReason, } from './log.js';
|
|
6
|
+
import { normalizeLoopbackRedirectUri, redirectUriMatchesRegistered } from './redirect-uri.js';
|
|
6
7
|
import { completeRefreshTokenGrant, isRefreshTokenGrantError } from './refresh.js';
|
|
7
8
|
function errorRedirect(redirectUri, message, state) {
|
|
8
9
|
if (!redirectUri) {
|
|
@@ -47,41 +48,19 @@ export async function handleOAuthAuthorizeGet(request, ctx) {
|
|
|
47
48
|
return errorRedirect(redirectUri, 'Only S256 code challenge is supported', state);
|
|
48
49
|
}
|
|
49
50
|
const client = await ctx.store.getOAuthClient(clientId);
|
|
50
|
-
if (!client
|
|
51
|
+
if (!client || !redirectUriMatchesRegistered(client.redirectUris, redirectUri)) {
|
|
51
52
|
return errorRedirect(redirectUri, 'Invalid client or redirect_uri', state);
|
|
52
53
|
}
|
|
54
|
+
const normalizedRedirectUri = normalizeLoopbackRedirectUri(redirectUri);
|
|
53
55
|
const { authRequestId } = await ctx.store.savePendingAuthRequest({
|
|
54
56
|
clientId,
|
|
55
|
-
redirectUri,
|
|
57
|
+
redirectUri: normalizedRedirectUri,
|
|
56
58
|
codeChallenge,
|
|
57
59
|
state,
|
|
58
60
|
resource,
|
|
59
61
|
});
|
|
60
|
-
const siteName = ctx.displayName ?? ctx.deployment.projectKey;
|
|
61
62
|
const contentfulAuthorizeUrl = getContentfulAuthorizeUrl(authRequestId);
|
|
62
|
-
|
|
63
|
-
<html lang="en">
|
|
64
|
-
<head>
|
|
65
|
-
<meta charset="utf-8" />
|
|
66
|
-
<title>Connect Contentful</title>
|
|
67
|
-
<style>
|
|
68
|
-
body { font-family: system-ui, sans-serif; padding: 2rem; max-width: 32rem; line-height: 1.5; }
|
|
69
|
-
a.button {
|
|
70
|
-
display: inline-block; margin-top: 1rem; padding: 0.75rem 1.25rem;
|
|
71
|
-
background: #111; color: #fff; text-decoration: none; border-radius: 0.375rem; font-weight: 600;
|
|
72
|
-
}
|
|
73
|
-
</style>
|
|
74
|
-
</head>
|
|
75
|
-
<body>
|
|
76
|
-
<h1>Connect Contentful</h1>
|
|
77
|
-
<p>Authorize Claude to edit <strong>${siteName}</strong> draft content in Contentful. You will sign in with Contentful first.</p>
|
|
78
|
-
<a class="button" href="${contentfulAuthorizeUrl}">Sign in with Contentful</a>
|
|
79
|
-
</body>
|
|
80
|
-
</html>`;
|
|
81
|
-
return new Response(html, {
|
|
82
|
-
status: 200,
|
|
83
|
-
headers: { 'Content-Type': 'text/html; charset=utf-8' },
|
|
84
|
-
});
|
|
63
|
+
return Response.redirect(contentfulAuthorizeUrl, 302);
|
|
85
64
|
}
|
|
86
65
|
export async function handleOAuthRegisterPost(request, ctx) {
|
|
87
66
|
let body;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../../src/hosted/oauth/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EACL,cAAc,EACd,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,EACL,mCAAmC,EACnC,mBAAmB,EACnB,eAAe,EACf,0BAA0B,GAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AASnF,SAAS,aAAa,CAAC,WAA0B,EAAE,OAAe,EAAE,KAAc;IAChF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IACjC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC/C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;IACnD,IAAI,KAAK,EAAE,CAAC;QACV,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,K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AAE,CAAC,MAAM,CAAC;KAChD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,uCAAuC;IACrD,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,OAAO,QAAQ,CAAC,IAAI,CAAC;QACnB,QAAQ,EAAE,iBAAiB,EAAE;QAC7B,qBAAqB,EAAE,CAAC,MAAM,CAAC;KAChC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,IAAI,CAAC;QACH,eAAe,EAAE,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;YACjD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,8BAA8B,EAAE,CAAC;QAC/D,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;YACvD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,oCAAoC,EAAE,CAAC;QACrE,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,6BAA6B,EAAE,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC/D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonicalize loopback redirect URIs so 127.0.0.1 and localhost compare equal.
|
|
3
|
+
* Non-loopback URIs are returned unchanged.
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeLoopbackRedirectUri(uri: string): string;
|
|
6
|
+
/** True when requested matches any registered URI (exact or loopback-equivalent). */
|
|
7
|
+
export declare function redirectUriMatchesRegistered(registered: string[], requested: string): boolean;
|
|
8
|
+
/** True when two redirect URIs are equivalent for OAuth token exchange. */
|
|
9
|
+
export declare function redirectUrisEquivalent(stored: string, requested: string): boolean;
|
|
10
|
+
//# sourceMappingURL=redirect-uri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect-uri.d.ts","sourceRoot":"","sources":["../../../src/hosted/oauth/redirect-uri.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQhE;AA+BD,qFAAqF;AACrF,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAE7F;AAED,2EAA2E;AAC3E,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAKjF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '[::1]']);
|
|
2
|
+
function parseRedirectUri(uri) {
|
|
3
|
+
try {
|
|
4
|
+
return new URL(uri);
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function isLoopbackHost(hostname) {
|
|
11
|
+
return LOOPBACK_HOSTS.has(hostname);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Canonicalize loopback redirect URIs so 127.0.0.1 and localhost compare equal.
|
|
15
|
+
* Non-loopback URIs are returned unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export function normalizeLoopbackRedirectUri(uri) {
|
|
18
|
+
const parsed = parseRedirectUri(uri);
|
|
19
|
+
if (!parsed || !isLoopbackHost(parsed.hostname)) {
|
|
20
|
+
return uri;
|
|
21
|
+
}
|
|
22
|
+
parsed.hostname = '127.0.0.1';
|
|
23
|
+
return parsed.toString();
|
|
24
|
+
}
|
|
25
|
+
function redirectUriPartsMatch(a, b) {
|
|
26
|
+
const left = parseRedirectUri(a);
|
|
27
|
+
const right = parseRedirectUri(b);
|
|
28
|
+
if (!left || !right) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (left.protocol !== right.protocol) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (left.pathname !== right.pathname) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (left.search !== right.search) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (left.port !== right.port) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const leftLoopback = isLoopbackHost(left.hostname);
|
|
44
|
+
const rightLoopback = isLoopbackHost(right.hostname);
|
|
45
|
+
if (leftLoopback && rightLoopback) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return left.hostname === right.hostname;
|
|
49
|
+
}
|
|
50
|
+
/** True when requested matches any registered URI (exact or loopback-equivalent). */
|
|
51
|
+
export function redirectUriMatchesRegistered(registered, requested) {
|
|
52
|
+
return registered.some((uri) => redirectUriPartsMatch(uri, requested));
|
|
53
|
+
}
|
|
54
|
+
/** True when two redirect URIs are equivalent for OAuth token exchange. */
|
|
55
|
+
export function redirectUrisEquivalent(stored, requested) {
|
|
56
|
+
if (stored === requested) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return redirectUriPartsMatch(stored, requested);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=redirect-uri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect-uri.js","sourceRoot":"","sources":["../../../src/hosted/oauth/redirect-uri.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAEpE,SAAS,gBAAgB,C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AAM,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,YAAY,IAAI,aAAa,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC;AAC1C,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,4BAA4B,CAAC,UAAoB,EAAE,SAAiB;IAClF,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,qBAAqB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,sBAAsB,CAAC,MAAc,EAAE,SAAiB;IACtE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,qBAAqB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC"}
|
package/docs/mcp/hosted-guide.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# cms-edit MCP guide
|
|
2
2
|
|
|
3
|
-
Use this guide when editing Contentful draft content through Claude Desktop
|
|
3
|
+
Use this guide when editing Contentful draft content through a hosted MCP connector (Claude Desktop Integrations + OAuth, or Grok Build).
|
|
4
4
|
|
|
5
5
|
{{SITE_INTRO}}
|
|
6
6
|
|
|
@@ -216,6 +216,27 @@ Asset search and media-by-filename list **require** the index. Template/taxonomy
|
|
|
216
216
|
["search", "pricing"]
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
+
## Grok Build setup
|
|
220
|
+
|
|
221
|
+
Grok connects to the same hosted MCP URL as Claude. Add to `~/.grok/config.toml`:
|
|
222
|
+
|
|
223
|
+
```toml
|
|
224
|
+
[mcp_servers.cms-edit-brightline]
|
|
225
|
+
url = "https://brightline.content.se.studio/api/mcp"
|
|
226
|
+
enabled = true
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Replace the server name and host with your site's deployment. The URL **must** end with `/api/mcp` (not the site root).
|
|
230
|
+
|
|
231
|
+
**Connect:**
|
|
232
|
+
|
|
233
|
+
1. In Grok, run `/mcps` and select your cms-edit server
|
|
234
|
+
2. Press **`i`** to initiate OAuth (not just enable the toggle)
|
|
235
|
+
3. Sign in with Contentful when the browser opens
|
|
236
|
+
4. Verify with `grok mcp doctor <server-name>` or call `cms_edit_version`
|
|
237
|
+
|
|
238
|
+
OAuth is two steps: Grok obtains an MCP token, then you sign in with Contentful to link your account. If the browser flashes and closes immediately, reconnect after upgrading cms-edit (loopback redirect handling).
|
|
239
|
+
|
|
219
240
|
## Hosted connector rules
|
|
220
241
|
|
|
221
242
|
{{HOSTED_RULES}}
|
|
@@ -245,7 +266,7 @@ Asset search and media-by-filename list **require** the index. Template/taxonomy
|
|
|
245
266
|
|
|
246
267
|
| Problem | What to do |
|
|
247
268
|
|---------|------------|
|
|
248
|
-
| **401 / connection failed** | Claude → Settings → Integrations →
|
|
269
|
+
| **401 / connection failed** | Reconnect: Claude → Settings → Integrations, or Grok `/mcps` → press `i`. Complete Contentful sign-in. On Vercel, search runtime logs for `[cms-edit:oauth] auth_failure` (always logged). Set `LOG_CMS_OAUTH=1` for connect success traces. |
|
|
249
270
|
| **No cms_edit tool** | Confirm the integration is connected under Settings → Integrations |
|
|
250
271
|
| **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", "--page-slug", "/"]`. Fallback: `["read", "<entry-id>", "--id"]` |
|
|
251
272
|
| **Wrong space** | Your Contentful account must have access to this deployment's space |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@se-studio/contentful-cms",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.7",
|
|
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",
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
65
65
|
"commander": "^15.0.0",
|
|
66
66
|
"contentful": "^11.12.5",
|
|
67
|
-
"contentful-management": "^12.
|
|
67
|
+
"contentful-management": "^12.8.0",
|
|
68
68
|
"dotenv": "^17.4.2",
|
|
69
69
|
"jose": "^6.2.3",
|
|
70
70
|
"picocolors": "^1.1.1",
|
|
71
71
|
"zod": "^4.4.3"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@biomejs/biome": "^2.5.
|
|
74
|
+
"@biomejs/biome": "^2.5.1",
|
|
75
75
|
"@types/node": "^24.13.2",
|
|
76
76
|
"@types/react": "^19.2.17",
|
|
77
77
|
"@types/react-dom": "^19.2.3",
|
package/skills/manifest.json
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
"core": "Use cms-edit CLI to read/edit Contentful content (open → snapshot → read → set/rtf → diff → save).",
|
|
3
3
|
"editor-tasks": "Route CMS editing intents to site task playbooks via tasks-index (hosted MCP resources or local editor-pack files).",
|
|
4
4
|
"templates": "Create or edit templates (preContent, postContent, menu, footer, colours) in Contentful via cms-edit.",
|
|
5
|
-
"setup": "Guide a user through connecting hosted cms-edit MCP for Claude
|
|
5
|
+
"setup": "Guide a user through connecting hosted cms-edit MCP for Claude or Grok (OAuth)."
|
|
6
6
|
}
|
package/skills/setup/SKILL.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: contentful-cms-setup
|
|
3
|
-
description: "Guide a user through connecting hosted cms-edit MCP for Claude
|
|
3
|
+
description: "Guide a user through connecting hosted cms-edit MCP for Claude or Grok (OAuth)."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Skill: cms-edit Setup
|
|
7
7
|
|
|
8
|
-
Use this skill when the user wants to connect Claude to their Contentful site via **hosted cms-edit MCP**.
|
|
8
|
+
Use this skill when the user wants to connect Claude or Grok to their Contentful site via **hosted cms-edit MCP**.
|
|
9
9
|
|
|
10
10
|
Local stdio MCP and the setup wizard are **not supported**. Editors connect through the site's `/cms-edit` onboarding flow.
|
|
11
11
|
|
|
@@ -35,6 +35,39 @@ Use skill **`contentful-cms-editor-tasks`** for the tasks-index → capability p
|
|
|
35
35
|
|
|
36
36
|
---
|
|
37
37
|
|
|
38
|
+
## Hosted setup (Grok Build)
|
|
39
|
+
|
|
40
|
+
Use when the user wants cms-edit in **Grok Build** (not local stdio MCP).
|
|
41
|
+
|
|
42
|
+
### Step 1: Configure Grok
|
|
43
|
+
|
|
44
|
+
Add to `~/.grok/config.toml`:
|
|
45
|
+
|
|
46
|
+
```toml
|
|
47
|
+
[mcp_servers.cms-edit-<projectKey>]
|
|
48
|
+
url = "https://<host>/api/mcp"
|
|
49
|
+
enabled = true
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The URL **must** end with `/api/mcp`. Use the MCP URL from the site's `/cms-edit` page.
|
|
53
|
+
|
|
54
|
+
### Step 2: Connect
|
|
55
|
+
|
|
56
|
+
1. In Grok, run `/mcps`
|
|
57
|
+
2. Select the cms-edit server
|
|
58
|
+
3. Press **`i`** to initiate OAuth (not just enable)
|
|
59
|
+
4. Sign in with Contentful when prompted
|
|
60
|
+
|
|
61
|
+
### Step 3: Verify
|
|
62
|
+
|
|
63
|
+
Run `grok mcp doctor cms-edit-<projectKey>` or call `cms_edit_version` in a Grok session.
|
|
64
|
+
|
|
65
|
+
**Reconnect:** `/mcps` → press `i` again if OAuth expires.
|
|
66
|
+
|
|
67
|
+
Full guide: `packages/contentful-cms/docs/mcp/hosted-guide.md` (Grok Build section).
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
38
71
|
## Developers (CLI + skills, not local MCP)
|
|
39
72
|
|
|
40
73
|
For engineering work in a site repo (Cursor, Grok, terminal):
|
|
@@ -51,7 +84,10 @@ Do **not** register a local `mcpServers.cms-edit` entry in Claude Desktop — us
|
|
|
51
84
|
## Troubleshooting
|
|
52
85
|
|
|
53
86
|
**OAuth / sign-in fails**
|
|
54
|
-
→ Confirm the user was invited to the Contentful space and is signing in with the correct account.
|
|
87
|
+
→ Confirm the user was invited to the Contentful space and is signing in with the correct account. In Grok, use `/mcps` → press `i` (not just toggle). Confirm config URL ends with `/api/mcp`.
|
|
88
|
+
|
|
89
|
+
**Grok browser flashes and closes**
|
|
90
|
+
→ Usually a redirect_uri mismatch before cms-edit v2.7.7+; upgrade the hosted deployment and retry OAuth.
|
|
55
91
|
|
|
56
92
|
**`cms_edit` tool not available**
|
|
57
93
|
→ Reconnect via `/cms-edit` or Claude Integrations. Remove any legacy local MCP or `.mcpb` extension entries.
|