AI Agents
Cursor Rules for PageGun
Add PageGun to Cursor with dedicated rule files. Each rule is generated from the canonical PageGun skill at content/agents/skills/<name>/SKILL.md — the body is identical to the Claude Code / Codex / Copilot skill; only the frontmatter is transformed for Cursor.
Quick Setup
- Create
.cursor/rules/in your project root. - Copy the rule files below into that folder.
- Set your API key:
export PAGEGUN_API_KEY="pgk_live_your_key_here"Rule Files
| File | Purpose | When It Fires |
|---|---|---|
pagegun.mdc | Core API: projects, landing pages, subroutes, media, endpoint split | On generic PageGun API tasks |
pagegun-articles.mdc | Blog/article CRUD, markdown video embeds, publishing | When the task involves blog or article content |
pagegun-docs.mdc | Docs pages, nested slugs, sidebar navigation, docs markdown directives | When the task involves documentation pages |
pagegun-i18n.mdc | Locale rows, translation rules, and locale coverage audits | When the task involves multilingual content |
pagegun-onboarding.mdc | Repo-local PageGun MCP/Data Mode setup | When connecting another repo to PageGun |
pagegun.mdc
Save as .cursor/rules/pagegun.mdc:
---
description: Manage PageGun projects, route/index pages, landing pages, subroutes, page-level JSON schemas, media, MCP tools, and publishing. For article or blog content use the pagegun-articles skill; for documentation pages use the pagegun-docs skill.
globs:
alwaysApply: false
---
# PageGun Skill
Use this skill when a user wants to inspect, create, update, validate, or publish PageGun landing/page content.
For article/blog operations, load the `pagegun-articles` skill — it has the full article workflow, list rules, and markdown embeds.
For documentation pages, load the `pagegun-docs` skill — it has nested slugs, sidebar navigation, and docs markdown directives.
For translation, locale variants, or i18n coverage, load the `pagegun-i18n` skill.
## Auth And Discovery
Use the API key from `PAGEGUN_API_KEY`.
All requests must include:
```bash
Authorization: Bearer $PAGEGUN_API_KEY
```
REST base URL:
```bash
https://api.pagegun.com
```
MCP server URL:
```bash
https://mcp.pagegun.com
```
MCP uses the same API key auth:
```text
Authorization: Bearer $PAGEGUN_API_KEY
```
Default MCP tool profile is `seo-agent`, which hides page/doc mutation plus low-level/destructive operator tools. Call `get_tool_profiles` to inspect the current profile and switch instructions. Use `https://mcp.pagegun.com?profile=full` or header `x-pagegun-mcp-profile: full` for the complete tool surface. Other profiles: `readonly`, `cms`, `publisher`.
Never print raw secrets. Never put the raw API key in tracked files.
## Project-Based MCP Install
For another repo, install this as repo-local tooling:
1. Copy the PageGun skills that match the target repo:
- Always: `.agents/skills/pagegun`
- If the repo is being connected to PageGun/Data Mode: `.agents/skills/pagegun-onboarding`
- If the repo manages blog/news/changelog content: `.agents/skills/pagegun-articles`
- If the repo manages docs: `.agents/skills/pagegun-docs`
- If the repo manages translations/locales: `.agents/skills/pagegun-i18n`
2. Add a repo-root `.mcp.json` with an env-var reference, not a raw key:
```json
{
"mcpServers": {
"pagegun": {
"type": "http",
"url": "https://mcp.pagegun.com",
"headers": {
"Authorization": "Bearer ${PAGEGUN_API_KEY}"
}
}
}
}
```
3. Set `PAGEGUN_API_KEY` in the local shell or secret manager.
4. Restart the agent session from that repo.
For Codex CLI, registering the streamable HTTP server directly is the clearest path:
```bash
codex mcp add pagegun --url https://mcp.pagegun.com --bearer-token-env-var PAGEGUN_API_KEY
```
Use a project-scoped API key when possible. If the key is not project-scoped, every project operation must pass an explicit `project_id`; do not guess.
Do not use `PAGEGUN_MCP_SECRET` or `x-mcp-secret`. That old shared-secret path is stale.
## MCP-First Workflow
Prefer MCP when the client has it connected. Otherwise use REST.
Before any page mutation:
1. Call `get_workflow_guide`.
2. Call the smallest task guide that applies: `get_json_page_guide`, `get_article_guide`, `get_docs_guide`, or `get_i18n_guide`.
3. Read the project with `get_project`.
4. Read the target page with `get_page` or `list_pages`.
5. Read schema state with `get_page_schema`.
Recommended paths:
| Job | Path |
|-----|------|
| Tactic discovery | translate the user's intent into concise canonical English → `seo_tactics` with `action="recommend"` → same tool with `action="get"` for selected stable IDs → inspect evidence → decide use/test/defer/reject |
| SEO audit | `context_get_project_brief` → `content_get_inventory` → `seo_get_overview` → `seo_audit_page` |
| Commercial SEO growth | `seo_get_growth_brief` → `analytics_get_domain_metrics` → `gsc_get_ranked_keywords_by_url` → `content_get_url_snapshot` → `linking_find_opportunities` |
| Backlink outreach prompts | `backlink_outreach_generate_pitches` with 1-3 competitor domains → pass returned `pitch_prompt.prompt` values to the email-writing agent |
| New content | `context_get_project_brief` → `content_list_site_surface` → `seo_find_keyword_owner` → `content_site_search` → task guide → draft create only if no owner exists |
| Existing-page refresh | `content_get_url_snapshot` → `gsc_get_ranked_keywords_by_url` → `seo_get_content_brief` → `seo_get_onpage_optimization` for the exact stored page → revise the existing owner |
| Publish | `publishing_get_readiness` → fix blockers → `publish_page` |
| Launch audit | `publishing_get_launch_audit` → `linking_start_crawl` if no recent crawl exists → `publishing_get_launch_audit` again |
| Static site adapter | `content_get_inventory` or `content_search` → `adapter_get_static_site_plan` → apply JSON/Markdown/route plan in the target repo |
Available MCP tools:
| Goal | MCP tool |
|------|----------|
| Current server guidance | `get_workflow_guide` |
| JSON page workflow | `get_json_page_guide` |
| Article workflow | `get_article_guide` |
| Category workflow | `get_category_guide` |
| Docs workflow | `get_docs_guide` |
| I18n workflow | `get_i18n_guide` |
| Tactic and prompt library | `seo_tactics` (`search`, `get`, and `recommend` actions) |
| Project intelligence | `context_get_project_brief`, `context_get_brand_profile`, `context_get_product_capabilities` |
| Content discovery | `content_get_inventory`, `content_list_site_surface`, `content_site_search`, `content_get_url_snapshot`, `content_search`, `content_get_summary` |
| Recent activity | `activity_list_recent_changes` |
| SEO intelligence | `seo_get_overview`, `seo_get_growth_brief`, `seo_get_content_brief`, `seo_get_onpage_optimization`, `seo_export_audit`, `seo_get_canonical_groups`, `seo_plan_bulk_repairs`, `seo_audit_page`, `seo_find_keyword_owner`, `seo_find_cannibalization`, `seo_find_content_gaps` |
| GSC/indexing/conversion intelligence | `gsc_get_page_query_metrics`, `gsc_get_ranked_keywords_by_url`, `analytics_get_domain_metrics`, `analytics_get_url_conversions`, `indexing_get_status` |
| Internal linking intelligence | `linking_start_crawl`, `linking_get_crawl`, `linking_get_graph`, `linking_find_opportunities` |
| Keyword target management | `keyword_targets_list`, `keyword_targets_upsert`, `keyword_targets_update`, `keyword_targets_delete` |
| New keywords and gaps found by the daily scan | `keyword_opportunities_list`, `keyword_opportunities_get`, `keyword_opportunities_events` (cursor), `keyword_opportunities_update` (mark building/live) |
| GEO/entity intelligence | `geo_get_entity_profile` |
| Live/cache research | `research_fetch_serp`, `research_get_serp_snapshot`, `research_keyword_metrics`, `seo_get_onpage_optimization`, `competitor_research_get_overlap`, `backlink_outreach_generate_pitches`, `analytics_get_domain_metrics` |
| Publish readiness | `publishing_get_readiness` |
| Site launch audit | `publishing_get_launch_audit` |
| Static site adapter plan | `adapter_get_static_site_plan`, `adapter_get_static_collection_plan` |
| Collection CMS workflow | `get_collection_guide` |
| Article authors | `list_authors`, `get_author`, `create_author`, `update_author` |
| Article categories | `list_categories`, `get_category`, `create_category`, `update_category`, `delete_category`, `merge_category`, `reorder_categories` |
| Browse pages | `list_pages` |
| Create draft page | `create_page` |
| Read one page | `get_page` |
| Read effective schema | `get_page_schema` |
| Set page-level schema | `set_page_schema` |
| Update page content | `update_page` |
| Publish page | `publish_page` |
| Unpublish page | `unpublish_page` |
| Read project/settings | `get_project` |
| Merge project/settings changes | `update_project` |
| Merge project settings safely | `update_project_settings` |
| Browse route metadata | `list_subroutes`, `get_subroute` |
| Create/update route metadata | `create_subroute`, `update_subroute` |
| Audit/bind immutable route schema set | `bind_subroute_schema_set` |
| Delete route metadata | `delete_subroute` |
| Read fallback route schema | `get_subroute_schema` |
| Browse pages under one route | `list_subroute_pages` |
| Browse/upload media | `list_media`, `upload_media_from_url`, `upload_media_from_file`, `delete_media` |
| Articles/blog/news | `list_articles`, `get_article`, `create_article`, `update_article` |
| Documentation pages | `list_docs`, `get_doc`, `create_doc`, `update_doc` |
| Browse directory items | `list_items`, `get_item`, `update_item` |
| Structured collections | `collection_list`, `collection_get_schema`, `collection_list_items`, `collection_get_item`, `collection_validate_item`, `relation_validate`, `collection_diff_items`, `collection_export_items`, `route_ownership_list`, `route_ownership_suggest_from_crawl` |
| Structured collection writes | `collection_create`, `collection_update_schema`, `collection_update_item`, `collection_bulk_upsert_items`, `route_ownership_upsert`, `collection_publish_snapshot` |
| Homepage convenience | `get_homepage`, `update_homepage` |
For tactic results, only `capability.available_tool` is callable. A
`suggested_capability` with `availability: "planned"` is a product capability
idea, not an MCP tool name. Reference-only grey knowledge is hidden from normal
recommendations; request `include_reference_only: true` together with
`risk_tolerance: "aggressive"` only after the user explicitly accepts that the
result is risk analysis, not an execution plan.
`seo_tactics` uses canonical English retrieval. If the user writes in Chinese,
Japanese, French, or another language, understand the request normally and pass
a short English query/goal to the tool. Do not build language-specific query
syntax or expose translation work to the user.
MCP page updates are full overwrites for `config`. GET first, merge locally, then update.
Strategy/read tools are cache-first. Default `refresh_policy: "cache_only"` never spends live research quota. Tools that expose `refresh_policy` may use `refresh_if_missing` or `force_refresh` to run live research; `refresh_if_missing` refreshes missing or stale rows. Most provider rows use a 14-day TTL; `seo_get_onpage_optimization` uses a 30-day competitor-corpus TTL. They must persist the response and return freshness/cost status without exposing upstream vendor details.
`seo_get_onpage_optimization` accepts only an exact tenant-owned PageGun page (`page_id` preferred, or an unambiguous route lookup) plus a target keyword. It does not accept arbitrary URLs or body text, update a page, or publish. Treat missing/underused/overused phrase counts as comparative diagnostics, not density targets; fewer than two readable competitors is blocking evidence, not a rewrite brief.
For GSC setup, read the `gsc_setup` object returned by `gsc_get_page_query_metrics` when access is missing. If it returns a configured PageGun service-account email, ask the user to add that email to the matching Google Search Console property as a Restricted user. If no email is returned, ask the user to use PageGun OAuth or contact an admin. Never guess or hard-code a service-account email.
Before drafting net-new SEO/GEO content, treat `seo_find_keyword_owner` as the check that matters. If it returns `owned` or `conflict`, update, merge, differentiate, or internally link existing URLs instead of creating another generic page.
Audit, gap, readiness, and launch tools return actionability fields: `severity`, `recommended_next_action`, `blocking_reason`, and `safe_followup_tools`. Use those before choosing another tool.
`linking_start_crawl` has two modes. Bounded sync crawls are smoke tests capped at 80 pages. Full-site crawls must use `crawl_scope: "full_site"` or `execution_mode: "async"`; they enqueue a Trigger.dev job, default to 20k pages, return a `run_id`, and should be polled with `linking_get_crawl`. After page-level fixes, prefer `refresh_paths` / `refresh_target_paths`; crawl retention keeps the current run plus the latest full-site baseline and prunes removed current-graph edges in bounded batches.
Research tools return first-class `data_source`, `freshness`, `cost_units`, `refresh_policy_used`, and `external_call` fields. `data_source` is `cache`, `live`, or `none`; `cache_only` should show `external_call.made: false`.
Do not publish by setting `status`. MCP update tools intentionally do not expose that path; use `publish_page` after `publishing_get_readiness`. Publishing content the user asked for needs no separate approval round-trip. Ask first only when they framed the request as a draft, or when readiness returns `requires_explicit_publish_approval=true` (already-live page with a stale snapshot, so publishing would also ship pending edits they have not seen). Use `unpublish_page` only when the user explicitly wants the live CDN page removed.
For structured directory/tool/local SEO sites, use Collection CMS tools instead of forcing every provider, city, service, directory profile, calculator page, or ranking row into `pages`. Collections are source-of-truth records; pages are presentation surfaces or templates. Use `collection_bulk_upsert_items` with `dry_run: true` before applying imports, and only call `collection_publish_snapshot` after explicit approval because it writes encrypted Data Mode artifacts and triggers deploy hooks.
REST equivalents exist for scripts and admin UI:
- `GET/POST /api/projects/{projectId}/collections`
- `GET/PUT /api/projects/{projectId}/collections/{collection}/schema`
- `GET/POST /api/projects/{projectId}/collections/{collection}/items`
- `POST /api/projects/{projectId}/collections/{collection}/publish`
- `GET/POST /api/projects/{projectId}/route-ownership`
## Endpoint Split
- `/pages` is for landing pages only (`type: "page"`).
- `/articles` is for article/blog/news content (`type: "article"`).
- `/docs` is for docs content (`type: "docs"`).
- Publish and unpublish always go through `/pages/{id}/publish` and `/pages/{id}/unpublish`, regardless of content type.
- If the API returns `wrong_endpoint`, switch to the dedicated endpoint instead of retrying the same call.
MCP mirrors this split: use `update_page` only for `type: "page"`, `update_article` for articles, and `update_doc` for docs.
## Which Endpoint to Use
| Content type | Create | Update | Publish |
|--------------|--------|--------|---------|
| Landing page | `POST /pages` | `PUT /pages/:id` | `POST /pages/:id/publish` |
| Article | `POST /articles` | `PUT /articles/:id` | `POST /pages/:id/publish` |
| Docs | `POST /docs` | `PUT /docs/:id` | `POST /pages/:id/publish` |
## Route Pages And Subroutes
PageGun can have both:
- A route/subroute definition, such as `project.settings.site_routes["/{route}"]` and optionally a `subroutes.slug = "{route}"` row.
- A page row for that route's own index/page content.
Do not conflate them. The route is routing/navigation/fallback metadata. The page row is the JSON content rendered at `/{route}`.
Route page identity:
| URL | `pages.subroute` | `pages.slug` | Meaning |
|----|----|----|----|
| `/` | `null` | `null` | homepage |
| `/{route}` | `"{route}"` | `null` | route index/page row |
| `/{route}/{slug}` | `"{route}"` | `"{slug}"` | child page under a route |
Important: `slug = null` means "the route's index/page row." It does not prove the route is single. A route can have an index page and still have child pages.
Do not create both `{ slug: "{route}", subroute: null }` and `{ subroute: "{route}", slug: null }` for the same project/locale. They publish to the same Data Mode CDN object, and PageGun MCP/API will reject the write with `data_mode_cdn_path_collision`.
When asked to manage the page at `/{route}`, work on the page row first:
1. `get_project` and inspect `settings.site_routes["/{route}"]`.
2. `get_page({ project_id, subroute: "{route}" })` with no slug.
3. `get_page_schema` for that page.
4. Set or update `pages.content_schema` with `set_page_schema`.
5. Update the page `config` with `update_page`.
6. Publish once readiness is clean.
Only edit `project.settings.site_routes` when the route is missing or the user asked to change routing. Only edit the `subroutes` row when the user asked for route-wide navigation or fallback schema behavior.
Use MCP `create_page` for a missing route/index page row:
```json
{
"project_id": "proj_...",
"title": "Route Title",
"subroute": "{route}",
"slug": null,
"content_schema": "name: route-page\nversion: 1\ntype: sections\nsections:\n - type: hero\n required: true\n fields:\n headline:\n type: string\n",
"config": {
"meta": { "title": "Route Title", "description": "Draft route page." },
"sections": [{ "type": "hero", "headline": "Draft headline" }]
}
}
```
`create_page` creates drafts only. Take the page live with `publish_page` once `publishing_get_readiness` is clean.
`create_page` requires an effective schema. It accepts a page-level `content_schema`; if that is missing, it can use `subroutes.config.content_schema` as the fallback. If neither exists, the MCP tool will remind you and refuse the write unless the user explicitly approved `skip_schema: true`.
When a subroute row is missing, `create_page` will check/create route metadata only enough to make the page row valid. Still treat route metadata and page content as separate objects.
## JSON Schema Guardrail
JSON page writes require an effective content schema.
Priority order:
1. `pages.content_schema` on the exact page row.
2. `subroutes.config.content_schema` as fallback.
Page-level schema wins. If it conflicts with the subroute schema, the page schema trumps it.
`pages.content_schema` may contain inline YAML or an immutable
`pagegun-schema://id@version` registry reference. Registered page identities
remain explicit page-level exceptions; they are not a renderer-migration
workflow.
A subroute fallback may instead bind an immutable, source-controlled schema set.
The Tools set is `pagegun-schema-set://tools@1`; it selects exactly one member
from `config.renderer`:
- missing `renderer` → legacy Tools
- `renderer: "new"` → NewPageRenderer
- `renderer: "v5"` → V5PageRenderer
Unknown renderers, member shape mismatches, page-level schema-set references,
route mismatches, and registry fingerprint drift fail closed. Ordinary Tools
pages should inherit the set; existing page-level schemas keep their normal
override priority.
Use `bind_subroute_schema_set` for the MCP workflow. It defaults to a zero-write
inventory audit. Apply requires the exact `updated_at` from `get_subroute`, a
caller-stable idempotency key, and `apply: true`; the write changes only the
subroute fallback with a row CAS. REST clients use
`POST /ext/subroutes/tools/schema-set?project_id=...`, which is also dry-run by
default and requires `confirm_bind: true`, `expected_updated_at`, and an
`Idempotency-Key` to apply. Generic create/update/delete surfaces cannot install,
replace, remove, or delete a bound schema set.
This applies to JSON page create/update/publish. Missing schema prevents JSON writes and publish. `skip_schema` cannot bypass registered page schemas or a registered subroute schema set. On routes with only inline schemas, use bypass only when the user explicitly approves it:
- REST: `?skip_schema=true`
- MCP: `skip_schema: true`
`publishing_get_readiness` returning `ready_to_publish: false` for a missing or invalid effective schema is by design. Treat it as a PageGun publish policy blocker, not an MCP failure. Fix it with `set_page_schema` or a subroute fallback schema, then rerun readiness.
Call out bypasses in the final report. Silent bypass is a bug.
Schema format is YAML:
```yaml
name: route-index-page
description: JSON contract for a route index page
version: 1
type: sections
sections:
- type: hero
required: true
fields:
headline:
type: string
min: 8
max: 90
body:
type: string
max: 220
optional: true
actions:
type: list
optional: true
max: 2
item:
label:
type: string
href:
type: path
variant:
type: string
optional: true
enum: [primary, secondary, outline]
- type: features
required: false
fields:
headline:
type: string
items:
type: list
min: 3
max: 12
item:
title:
type: string
description:
type: string
icon:
type: lucide-icon
optional: true
- type: cta
required: false
fields:
headline:
type: string
body:
type: string
optional: true
```
Supported field types: `string`, `number`, `boolean`, `url`, `path`, `lucide-icon`, `list`, `markdown`, `string[]`, `datetime`.
Fields are required by default. Use `optional: true` or `required: false` when absent values are allowed.
## Projects
Prefer MCP:
- Read: `get_project`, `get_project_settings`
- Settings merge: `update_project_settings`
- Full update: `update_project`
REST fallback:
```bash
GET /projects
GET /projects/{project_id}
PUT /projects/{project_id}
```
## Pages (Landing Pages)
Prefer MCP: `list_pages`, `get_page`, `create_page`, `update_page`, `publish_page`, `unpublish_page`.
REST fallback:
```bash
GET /pages?project_id={project_id}
POST /pages
GET /pages/{page_id}
PUT /pages/{page_id}
POST /pages/{page_id}/publish
POST /pages/{page_id}/unpublish
```
## Subroutes
Prefer MCP: `list_subroutes`, `get_subroute`, `create_subroute`, `update_subroute`, `bind_subroute_schema_set`, `delete_subroute`, `get_subroute_schema`, `list_subroute_pages`.
REST fallback:
```bash
GET /subroutes?project_id={project_id}
POST /subroutes
GET /subroutes/{slug}?project_id={project_id}
PUT /subroutes/{slug}?project_id={project_id}
DELETE /subroutes/{slug}?project_id={project_id}
GET /subroutes/{slug}/pages?project_id={project_id}
POST /subroutes/{slug}/schema-set?project_id={project_id}
GET /subroutes/{slug}/delivery?project_id={project_id}
PUT /subroutes/{slug}/delivery?project_id={project_id}
DELETE /subroutes/{slug}/delivery?project_id={project_id}
```
- Articles live under subroutes like `blog`, `news`, or `changelog`.
- Docs use the `docs` subroute automatically.
- Navigation lives on the subroute config, not on individual pages.
- `subroutes.config.content_schema` is route-wide fallback schema, not the first choice for a specific route page.
- Updating subroute navigation republishes the sidebar.
- Headless sites: `PUT /subroutes/{slug}/delivery` (MCP `enable_route_delivery`, admin key) turns on live delivery for the route: plaintext JSON at `content.pagegun.com/{project_id}/pages/{subroute}/{slug}/{locale}.json` and live lists, updated on every publish. Empty body = inferred defaults (site URL from root_url, `/<route>`, no trailing slash, list fields from `/pagegun.schema.json`); any value can be overridden. See `get_data_mode_renderer_guide`.
## Authors and Media
For article/blog/news/changelog content, always choose an author and managed category slugs before creating the article:
1. Use `list_authors`.
2. If none exists, use `create_author`.
3. Use `list_categories` for the target subroute.
4. If the needed category does not exist, use `create_category`.
5. Pass the selected `author_id` and category slugs to `create_article`.
Keep avatar, bio, role/title, and links on the author record. The article should only reference `author_id`.
Use the author's `writing_style_prompt` when drafting or revising article prose.
Article category labels/SEO/order/visibility live on category records. Use `get_category_guide` when managing taxonomy. New MCP article writes store category slugs; legacy rows may still contain labels.
Prefer MCP for media: `list_media`, `upload_media_from_url`, `upload_media_from_file`, `delete_media`.
- Use `upload_media_from_url` for public image URLs.
- Use `upload_media_from_file` for local/generated images by passing raw base64 bytes or a `data:image/...;base64,...` URL.
- Media uploads are image-only. PageGun validates the payload, rewrites normal images to optimized WebP, resizes non-ICO favicons to PNG, and verifies ICO signatures.
```bash
GET /authors?project_id={project_id}
POST /authors
PUT /authors/{author_id}
GET /media?project_id={project_id}
POST /media
```
## Discovery Workflow
- If the user did not specify a project, list projects first.
- If the user did not specify a target page, use the correct list endpoint first.
- Read before write.
- Apply minimal updates instead of full-object overwrites.
- For JSON route pages, set page-level schema before changing `config`.
- Never print or echo the raw API key.
## Delegated subroute keys
A `pgk_sub_` API key is limited to its assigned project and subroute roots, including descendant paths and all languages. Lists are filtered. You may create, edit, publish, unpublish and delete authorized content and update its navigation. Project settings, shared media/author mutations, webhooks, automations and out-of-scope content return 403. Use existing author IDs and uploaded image URLs. Connect MCP with `?profile=cms` for docs/page tools. Use `delete_page` with `page_id` and `confirm: true` to permanently delete an unpublished page/doc/article with no CDN snapshot; REST uses `DELETE /pages/{id}?confirm=true` or `DELETE /docs/{id}?confirm=true`. Unpublish first. A scoped article create that detects an existing topic returns 409; update the original explicitly or pass `allow_duplicate=true`.pagegun-articles.mdc
Save as .cursor/rules/pagegun-articles.mdc:
---
description: Manage PageGun article, blog, and news content via the PageGun Articles API. Use when listing articles, creating blog posts, updating article markdown, publishing articles, or working with article markdown embeds like video.
globs:
alwaysApply: false
---
# PageGun Articles Skill
Use PageGun MCP article tools first for all blog, news, and article content. Use the Articles REST API only when MCP is unavailable.
Before article mutations, call `get_workflow_guide` and `get_article_guide`.
## Auth
All requests require `Authorization: Bearer $PAGEGUN_API_KEY`. Base URL: `https://api.pagegun.com`.
## MCP Tool Summary
| Action | MCP tool |
|--------|----------|
| List | `list_articles` |
| List authors | `list_authors` |
| Read author | `get_author` |
| Create author | `create_author` |
| Update author | `update_author` |
| List categories | `list_categories` |
| Read category | `get_category` |
| Create category | `create_category` |
| Update category | `update_category` |
| Delete category | `delete_category` |
| Merge category | `merge_category` |
| Reorder categories | `reorder_categories` |
| Category workflow | `get_category_guide` |
| Create draft | `create_article` |
| Read | `get_article` |
| Update draft | `update_article` |
| Publish | `publish_page` |
| Unpublish | `unpublish_page` |
| Server article guide | `get_article_guide` |
`create_article` and `update_article` never publish. Publish separately with `publish_page` once readiness blockers are clear. Ask first only if the user framed the request as a draft, or if readiness returns `requires_explicit_publish_approval=true` (already-live page with a stale snapshot, so publishing would also ship pending edits they have not seen).
Do not use `update_page` for articles. Articles are `type: "article"` and have their own MCP tools.
## REST Endpoint Summary
| Action | Endpoint |
|--------|----------|
| List | `GET /articles?project_id=xxx&subroute=blog` |
| Create | `POST /articles` |
| Read | `GET /articles/{id}` |
| Update | `PUT /articles/{id}` |
| Publish | `POST /pages/{id}/publish` |
| Unpublish | `POST /pages/{id}/unpublish` |
Publish/unpublish go through `/pages`, not `/articles`.
## Article Rules
- `GET /articles` requires both `project_id` and `subroute`.
- Default list size is `50`. Pass `limit` explicitly for other sizes.
- Sorting supports `sort=published_at|created_at|updated_at|title`.
- Ordering supports `order=asc|desc`.
- For the oldest articles, use `sort=created_at&order=asc`.
- Updating an article title does not imply a slug change. Only send `slug` when the user explicitly wants the URL changed.
## List Articles
MCP:
```json
list_articles({
"project_id": "YOUR_PROJECT_ID",
"subroute": "blog",
"sort": "created_at",
"order": "asc",
"limit": 3
})
```
REST fallback:
### Newest first
```bash
curl -sS "https://api.pagegun.com/articles?project_id=YOUR_PROJECT_ID&subroute=blog" \
-H "Authorization: Bearer $PAGEGUN_API_KEY"
```
### Earliest 3 posts
```bash
curl -sS "https://api.pagegun.com/articles?project_id=YOUR_PROJECT_ID&subroute=blog&sort=created_at&order=asc&limit=3" \
-H "Authorization: Bearer $PAGEGUN_API_KEY"
```
## Create an Article
Always choose an author and category slugs before creating an article:
1. Call `list_authors`.
2. If no active author exists, call `create_author`.
3. Call `list_categories` for the target `subroute`.
4. If the right category does not exist, call `create_category`.
5. Pass the selected `author_id` and category slugs to `create_article`.
Author profile fields such as avatar, bio, role/title, and links belong on the author record, not on the article.
When drafting or revising prose, read the author's `writing_style_prompt` from `list_authors` or `get_author` and follow it.
## Category Workflow
Categories are managed taxonomy records, not loose strings:
- New MCP article writes store slugs like `founder-notes`; legacy article rows may still contain display labels.
- `content_categories.label` stores display text like `Founder Notes`.
- Category SEO metadata lives on the category record.
- Renaming a label does not require article rewrites.
- Changing, deleting, or merging slugs updates DB article references but does not publish CDN snapshots; republish affected published articles when the live site should change.
MCP:
```json
list_categories({
"project_id": "YOUR_PROJECT_ID",
"subroute": "blog"
})
```
```json
get_category({
"project_id": "YOUR_PROJECT_ID",
"subroute": "blog",
"slug": "founder-notes"
})
```
```json
create_category({
"project_id": "YOUR_PROJECT_ID",
"subroute": "blog",
"label": "Founder Notes",
"slug": "founder-notes",
"description": "Behind-the-scenes notes from the PageGun team.",
"seo_title": "Founder Notes - PageGun",
"seo_description": "Product strategy, shipping notes, and PageGun company updates."
})
```
Use `merge_category` for taxonomy cleanup instead of manually editing every article.
MCP:
```json
create_article({
"project_id": "YOUR_PROJECT_ID",
"title": "How We Demo Product Updates",
"slug": "how-we-demo-product-updates",
"subroute": "blog",
"description": "A short walkthrough of our release demo workflow.",
"author_id": "AUTHOR_ID",
"markdown_content": "# How We Demo Product Updates\n\n::video[https://www.youtube.com/watch?v=dQw4w9WgXcQ]\n"
})
```
REST fallback:
```bash
curl -sS -X POST "https://api.pagegun.com/articles" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "How We Demo Product Updates",
"slug": "how-we-demo-product-updates",
"subroute": "blog",
"project_id": "YOUR_PROJECT_ID",
"description": "A short walkthrough of our release demo workflow.",
"author_id": "AUTHOR_ID",
"markdown_content": "# How We Demo Product Updates\n\n::video[https://www.youtube.com/watch?v=dQw4w9WgXcQ]\n"
}'
```
Required by MCP article workflow: `author_id`.
Useful optional fields: `slug`, `description`, `og_image_url`, `categories`, `locale`.
For MCP writes, `categories` must be category slugs, not display labels. Call `list_categories` first. If the needed category does not exist, call `create_category` and use the returned `slug`.
## Update an Article
MCP:
```json
update_article({
"article_id": "ARTICLE_ID",
"updates": {
"title": "How We Demo Product Updates",
"description": "Updated SEO description.",
"markdown_content": "# How We Demo Product Updates\n\nUpdated body."
}
})
```
REST fallback:
```bash
curl -sS -X PUT "https://api.pagegun.com/articles/ARTICLE_ID" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "How We Demo Product Updates",
"description": "Updated SEO description.",
"markdown_content": "# How We Demo Product Updates\n\nUpdated body."
}'
```
If the user explicitly wants a new URL, send `slug` in the update body. Otherwise leave it alone.
## Publish an Article
MCP:
```json
publish_page({ "page_id": "ARTICLE_ID" })
```
REST fallback:
```bash
curl -sS -X POST "https://api.pagegun.com/pages/ARTICLE_ID/publish" \
-H "Authorization: Bearer $PAGEGUN_API_KEY"
```
## Article Markdown
Article body lives in `markdown_content`. Use standard markdown for headings, lists, links, images, code blocks, tables, and blockquotes.
### Video Embeds
Use a single `::video[URL]` directive with the full video URL:
```markdown
::video[https://www.youtube.com/watch?v=dQw4w9WgXcQ]
```
- YouTube and Vimeo URLs are supported.
- Append `?t=1m30s` to the URL for a start timestamp.
- Raw `<iframe>` HTML is not supported.
- Use image markdown for images: ``
### Dofollow Links
Article-body links to external domains render as `rel="nofollow noopener noreferrer"` by default. To make a specific link **dofollow** (pass SEO equity), append `{dofollow}` directly after the markdown link:
```markdown
[anchor text](https://example.com){dofollow}
[Read more](https://example.com "Title"){dofollow}
```
The `{dofollow}` marker is stripped at render time and the resulting `<a>` gets `rel="noopener noreferrer"` (no `nofollow`).
**Do not modify `config/link-whitelist.ts`** for one-off article links — that file's whitelist is only consulted for author-bio markdown and as a fallback. The `{dofollow}` suffix is the right tool for per-article dofollow links and works on any URL.
## CDN Reads
Published articles are available on the CDN:
- `https://content.pagegun.com/{project_id}/{subroute}/{slug}.enc`
- `https://content.pagegun.com/{project_id}/nav.enc`
If you just need article listings, prefer the Articles API over CDN parsing.
## Safety
- Read the article before overwriting it.
- Keep `slug` stable unless the user explicitly wants a URL change.
- Publish after every article update that should go live.
- Never set `status` directly; use `publish_page` or `unpublish_page`.
- Never print the raw API key.pagegun-docs.mdc
Save as .cursor/rules/pagegun-docs.mdc:
---
description: Manage PageGun documentation pages via the PageGun Docs API. Use when creating docs pages, working with nested slugs, updating docs navigation/sidebar, or using docs markdown directives like cards, callouts, steps, and code tabs.
globs:
alwaysApply: false
---
# PageGun Docs Skill
Use PageGun MCP docs tools first for documentation pages. Use the Docs REST API only when MCP is unavailable.
Before docs mutations, call `get_workflow_guide` and `get_docs_guide`.
## Auth
All requests require `Authorization: Bearer $PAGEGUN_API_KEY`. Base URL: `https://api.pagegun.com`.
## MCP Tool Summary
| Action | MCP tool |
|--------|----------|
| List | `list_docs` |
| Create draft | `create_doc` |
| Read | `get_doc` |
| Update draft | `update_doc` |
| Publish | `publish_page` |
| Unpublish | `unpublish_page` |
| Update sidebar/navigation | `update_subroute` |
| Upload image from URL | `upload_media_from_url` |
| Server docs guide | `get_docs_guide` |
`create_doc` and `update_doc` never publish. Publish separately with `publish_page` once readiness blockers are clear. Ask first only if the user framed the request as a draft, or if readiness returns `requires_explicit_publish_approval=true` (already-live page with a stale snapshot, so publishing would also ship pending edits they have not seen).
Do not use `update_page` for docs. Docs are `type: "docs"` and have their own MCP tools.
## REST Endpoint Summary
| Action | Endpoint |
|--------|----------|
| List | `GET /docs?project_id=xxx` |
| Create | `POST /docs` |
| Read | `GET /docs/{id}` |
| Update | `PUT /docs/{id}` |
| Publish | `POST /pages/{id}/publish` |
| Unpublish | `POST /pages/{id}/unpublish` |
Publish/unpublish go through `/pages`, not `/docs`.
## Create a Doc
MCP:
```json
create_doc({
"project_id": "YOUR_PROJECT_ID",
"title": "Authentication",
"slug": "api/authentication",
"markdown_content": "# Authentication\n\nOur API uses Bearer tokens."
})
```
REST fallback:
```bash
curl -sS -X POST "https://api.pagegun.com/docs" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Authentication",
"project_id": "YOUR_PROJECT_ID",
"slug": "api/authentication",
"markdown_content": "# Authentication\n\nOur API uses Bearer tokens."
}'
```
Required fields: `title`, `project_id`, `markdown_content`.
Optional fields: `slug`, `description`, `og_image_url`, `locale`.
## Update a Doc
MCP:
```json
update_doc({
"doc_id": "DOC_ID",
"updates": {
"title": "Updated Authentication",
"markdown_content": "# Updated Authentication\n\nNew content."
}
})
```
REST fallback:
```bash
curl -sS -X PUT "https://api.pagegun.com/docs/DOC_ID" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Updated Authentication",
"markdown_content": "# Updated Authentication\n\nNew content."
}'
```
## Publish a Doc
MCP:
```json
publish_page({ "page_id": "DOC_ID" })
```
REST fallback:
```bash
curl -sS -X POST "https://api.pagegun.com/pages/DOC_ID/publish?project_id=YOUR_PROJECT_ID" \
-H "Authorization: Bearer $PAGEGUN_API_KEY"
```
## Nested Slugs
Use `/` in doc slugs for hierarchy:
```text
overview
quickstart
api/authentication
api/pages/create
guides/webhooks/setup
agents/best-practices
```
## Navigation
Docs sidebar navigation lives on the `docs` subroute:
MCP:
```json
update_subroute({
"project_id": "YOUR_PROJECT_ID",
"slug": "docs",
"updates": {
"navigation": {
"groups": [
{"group": "Getting Started", "pages": ["overview", "quickstart"]},
{"group": "API", "pages": ["api/authentication", "api/pages/create"]}
]
}
}
})
```
REST fallback:
```bash
curl -sS -X PUT "https://api.pagegun.com/subroutes/docs?project_id=YOUR_PROJECT_ID" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"navigation": {
"groups": [
{"group": "Getting Started", "pages": ["overview", "quickstart"]},
{"group": "API", "pages": ["api/authentication", "api/pages/create"]}
]
}
}'
```
Updating subroute navigation republishes the sidebar.
## Docs Markdown Directives
### Cards
```markdown
:::cards
- title: Quick Start
href: /docs/quick-start
description: Get up and running in 5 minutes
icon: rocket
:::
```
### Callouts
```markdown
:::callout{type="info"}
This is an informational note.
:::
```
### Steps
````markdown
:::steps
### Create an API Key
Go to Settings -> API Keys and click "Create".
### Make Your First Request
```bash
curl https://api.pagegun.com/projects \
-H "Authorization: Bearer $PAGEGUN_API_KEY"
```
:::
````
### Code Tabs
````markdown
:::code-tabs
```bash
curl https://api.pagegun.com/projects \
-H "Authorization: Bearer $PAGEGUN_API_KEY"
```
```javascript
const res = await fetch('https://api.pagegun.com/projects', {
headers: { Authorization: `Bearer ${API_KEY}` },
})
```
:::
````
## Images in Docs
Upload with MCP `upload_media_from_url` when using a public source URL, or REST `POST /media` for local files. Then reference with standard markdown:
```json
upload_media_from_url({
"project_id": "YOUR_PROJECT_ID",
"url": "https://example.com/screenshot.png",
"alt_text": "Dashboard screenshot"
})
```
```bash
curl -sS -X POST "https://api.pagegun.com/media" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-F "file=@./screenshot.png" \
-F "project_id=YOUR_PROJECT_ID" \
-F "alt_text=Dashboard screenshot"
```
```markdown

```
## Safety
- Use `/docs`, not `/pages`, for docs writes.
- Read the current doc before updating it.
- Publish after every doc update that should go live.
- Never set `status` directly; use `publish_page` or `unpublish_page`.
- Never print the raw API key.
## Delegated subroute keys
A `pgk_sub_` API key is limited to its assigned project and subroute roots, including descendant paths and all languages. Lists are filtered. You may create, edit, publish, unpublish and delete authorized content and update its navigation. Project settings, shared media/author mutations, webhooks, automations and out-of-scope content return 403. Use existing author IDs and uploaded image URLs. Connect MCP with `?profile=cms` for docs/page tools. Use `delete_page` with `page_id` and `confirm: true` to permanently delete an unpublished page/doc/article with no CDN snapshot; REST uses `DELETE /pages/{id}?confirm=true` or `DELETE /docs/{id}?confirm=true`. Unpublish first. A scoped article create that detects an existing topic returns 409; update the original explicitly or pass `allow_duplicate=true`.pagegun-i18n.mdc
Save as .cursor/rules/pagegun-i18n.mdc:
---
description: Manage PageGun multilingual content. Use when translating PageGun landing pages, route/index pages, articles, docs, Data Mode content, or auditing locale coverage across pages.
globs:
alwaysApply: false
---
# PageGun I18n Skill
Use this skill when the user asks to translate PageGun content, create locale variants, audit missing locales, or publish multilingual PageGun pages.
Load the relevant content skill too:
- Landing/JSON pages: `pagegun`
- Articles/blog/news: `pagegun-articles`
- Docs: `pagegun-docs`
## Core Model
Each locale is a separate `pages` row.
Identity is:
```text
project_id + subroute + slug + locale
```
Examples:
| URL | subroute | slug | locale |
|----|----|----|----|
| `/` | `null` | `null` | `en` |
| `/features` | `features` | `null` | `en` |
| `/features` translated | `features` | `null` | `de` |
| `/blog/post` | `blog` | `post` | `en` |
| `/blog/post` translated | `blog` | `post` | `ja` |
Do not translate `subroute` or `slug` unless the user explicitly asks for localized URLs. Stable URLs are the default.
## Supported Locales
Use only PageGun-supported locale codes:
```text
en, de, ja, es, fr, ko, it, th, ru, zh-Hant, zh-Hans, pt-BR, ar
```
Default locale is `en`.
## Workflow
1. Call `get_workflow_guide`.
2. Call `get_i18n_guide`.
3. Call the matching content guide: `get_json_page_guide`, `get_article_guide`, or `get_docs_guide`.
4. Read the project with `get_project`.
5. Find the source page by ID, or by `subroute + slug + locale`.
6. Read the effective schema for JSON pages with `get_page_schema`.
7. Check whether the target locale row already exists.
8. If missing, create a draft row for the target locale.
9. If present, update that draft row.
10. Verify the translated row by reading it back.
11. Publish once readiness is clean.
## Field Rules
Translate user-visible text:
- `title`
- `description`
- `meta_title`
- `meta_description`
- `markdown_content`
- JSON `config` strings visible to readers, such as headings, body copy, CTA labels, FAQ text, card titles, image alt text, testimonials, pricing labels, and table text.
Preserve structural and routing fields:
- `project_id`
- `subroute`
- `slug`
- `type`
- `content_schema`
- `categories` unless the user asks for localized category labels
- `author_id`
- `og_image_url` unless the image itself contains source-language text
- URLs, anchors, tracking params, video embed URLs, and media URLs
- section `type` values
- IDs and analytics keys
- numbers, prices, dates, and product names unless localization is explicitly requested
For JSON pages, keep the same structure. Translate strings inside the existing structure; do not invent new sections during translation unless the user asks for a rewrite.
## Landing And Route Pages
For a route/index page like `/{route}`, use:
```text
subroute = "{route}"
slug = null
locale = target locale
```
Do not confuse the route/subroute metadata with the page row. The translated route page is still a page row.
When creating a localized JSON page, copy the page-level `content_schema` from the source page unless the target needs a different schema. Page-level schema remains preferred; subroute schema is only fallback.
MCP example:
```json
create_page({
"project_id": "PROJECT_ID",
"title": "Funktionen",
"subroute": "features",
"slug": null,
"locale": "de",
"content_schema": "SOURCE_PAGE_SCHEMA_YAML",
"config": {
"sections": []
}
})
```
Then update with the translated full config:
```json
update_page({
"page_id": "TARGET_PAGE_ID",
"updates": {
"title": "Funktionen",
"description": "Translated SEO description.",
"config": {
"sections": []
}
}
})
```
## Articles
Use article tools, not page tools.
For a translated article, preserve:
- `subroute`
- `slug`
- `author_id`
- `categories` by default
- media URLs
Create draft:
```json
create_article({
"project_id": "PROJECT_ID",
"title": "Translated title",
"subroute": "blog",
"slug": "same-source-slug",
"locale": "ja",
"description": "Translated SEO description.",
"markdown_content": "# Translated article\n"
})
```
Update existing draft:
```json
update_article({
"article_id": "ARTICLE_ID",
"updates": {
"title": "Translated title",
"description": "Translated SEO description.",
"markdown_content": "# Translated article\n"
}
})
```
## Docs
Use docs tools, not page tools.
For a translated doc, preserve nested slugs like `api/authentication` unless localized URLs were requested.
Create draft:
```json
create_doc({
"project_id": "PROJECT_ID",
"title": "Translated title",
"subroute": "docs",
"slug": "api/authentication",
"locale": "fr",
"description": "Translated SEO description.",
"markdown_content": "# Translated doc\n"
})
```
Docs navigation lives on the subroute. Do not rewrite navigation unless the user asks for localized sidebar labels or ordering.
## Locale Coverage Audit
To audit a route:
1. Use `list_subroute_pages` for the subroute.
2. Group rows by `slug || "__index__"`.
3. Compare each group against the requested locale set.
4. Report missing locale rows and draft vs published status.
For articles, prefer `list_articles` with each locale filter when the subroute is known.
For docs, prefer `list_docs` with each locale filter.
## Publishing
Translations are drafts until published.
Only call:
```json
publish_page({ "page_id": "TARGET_PAGE_ID" })
```
once readiness blockers are clear for that locale. Ask first only if the user framed the request as a draft, or if readiness returns `requires_explicit_publish_approval=true` on a row.
Publish all affected locale rows if the user wants the translated site live. Publishing the source locale does not publish target locales.
## Final Report
Keep the final report short:
- source page and locale
- target locales created or updated
- draft/published status
- missing locales
- whether anything was published
Call out any untranslated text, schema bypass, changed URLs, or media that still contains source-language text.pagegun-onboarding.mdc
Save as .cursor/rules/pagegun-onboarding.mdc:
---
description: Onboard a TypeScript repo to PageGun MCP/Data Mode page management. Use when connecting an existing app to PageGun, deriving JSON page schemas from local components/routes, setting page-level content_schema, updating route/index pages, and publishing.
globs:
alwaysApply: false
---
# PageGun Onboarding Skill
Use this skill when a TypeScript repo should be managed through PageGun pages and MCP.
This is not a generic "make pages pretty" guide. It is the operational workflow for letting agents safely manage PageGun JSON pages from a real app's component contract.
## Core Model
PageGun has separate concepts that are easy to mix up:
- Project route config: `project.settings.site_routes["/{route}"]`
- Optional route metadata row: `subroutes.slug = "{route}"`
- Page content row: `pages.subroute = "{route}"`, `pages.slug = null`
- Child page row: `pages.subroute = "{route}"`, `pages.slug = "{slug}"`
The page content row is the thing rendered at `/{route}`. Do that first.
`slug = null` means "route index/page row." It does not mean the route is single. A collection route can still have an index page.
## Non-Negotiables
- Read before write.
- Publish content the user asked for once readiness blockers are clear; ask first only if they framed it as a draft or readiness sets `requires_explicit_publish_approval`.
- Do not print API keys or Data Mode content keys.
- Do not write PageGun secrets to tracked files.
- Do not overwrite `config` blindly; it is a full replacement.
- Do not overwrite `project.settings`; it is a full replacement.
- Do not use subroute schema as the first choice for a route page. Page-level schema goes first.
## Auth
REST uses:
```bash
Authorization: Bearer $PAGEGUN_API_KEY
```
REST base URL:
```bash
https://api.pagegun.com
```
MCP server:
```bash
https://mcp.pagegun.com
```
MCP uses the same API key auth:
```text
Authorization: Bearer $PAGEGUN_API_KEY
```
If auth is missing, do not stub writes. Get a key with agent connect, which needs one click from the human:
1. `POST https://api.pagegun.com/agent-connect/start` with `{"client_name": "<your agent name>"}`.
2. Show the human `data.verification_url` and `data.user_code`, and ask them to sign in and approve.
3. Poll `POST https://api.pagegun.com/agent-connect/poll` with `{"poll_token": "<data.poll_token>"}` every `data.interval` seconds.
4. On `status: "approved"`, store `data.api_key` as `PAGEGUN_API_KEY` in the local environment or secret manager (it is returned once). Use the ready-made MCP commands in `data.mcp`.
Then call the MCP tool `get_onboarding_status`; it returns the checklist and the next tool to call. The full walkthrough is at https://www.pagegun.com/agents.md.
Onboarding MCP tools:
| Goal | MCP tool |
|------|----------|
| Checklist and the next tool to call | `get_onboarding_status` |
| Have PageGun draft the first blog posts (idempotent, never auto-publishes) | `request_managed_drafts` |
| Rewrite snippet to serve PageGun paths on the customer's domain | `get_domain_setup` |
| Confirm the deployed rewrite works through the live domain | `validate_domain_setup` |
## Project-Based MCP Install
For a target repo, install PageGun as repo-local agent tooling:
1. Copy the PageGun skills that match the target repo:
- Always: `.agents/skills/pagegun`, `.agents/skills/pagegun-onboarding`
- If the repo manages blog/news: `.agents/skills/pagegun-articles`
- If the repo manages docs: `.agents/skills/pagegun-docs`
- If the repo manages translations/locales: `.agents/skills/pagegun-i18n`
2. Add `.mcp.json` at the target repo root:
```json
{
"mcpServers": {
"pagegun": {
"type": "http",
"url": "https://mcp.pagegun.com",
"headers": {
"Authorization": "Bearer ${PAGEGUN_API_KEY}"
}
}
}
}
```
3. Put the raw key only in the local environment or secret manager.
4. Restart the agent session from the target repo.
For Codex CLI, register the streamable HTTP server directly:
```bash
codex mcp add pagegun --url https://mcp.pagegun.com --bearer-token-env-var PAGEGUN_API_KEY
```
Prefer a project-scoped API key. With a non-project-scoped key, pass `project_id` explicitly on every PageGun tool call. Never guess the project.
Do not use `PAGEGUN_MCP_SECRET` or `x-mcp-secret`; that early shared-secret path is obsolete.
## Preferred Tool Order
Use MCP first when available:
1. `get_workflow_guide`
2. Task guide: `get_json_page_guide`, `get_article_guide`, `get_docs_guide`, or `get_i18n_guide`
3. `get_project`
4. `list_subroutes` / `get_subroute` when route metadata matters
5. `list_pages` or `get_page`
6. `get_page_schema`
7. `set_page_schema`
8. `create_page` for a missing draft page row
9. `update_page`
10. `update_project_settings` if routing/settings need a top-level merge
11. `publish_page` once readiness blockers are clear
Use REST only when MCP cannot do the needed action.
## Onboarding Flow
### 1. Identify The Local Contract
Read the target repo before touching PageGun:
```bash
test -f package.json
test -f tsconfig.json
rg --files . | rg '(^|/)(app|pages|src|components)/.*\.(ts|tsx)What You Can Ask Cursor
- "List the earliest 3 blog posts in my PageGun project."
- "Create a blog post with a YouTube embed."
- "Update this article body without changing the slug."
- "Create a docs page under
agents/best-practices." - "Update the docs sidebar navigation."
- "Translate this blog post into Japanese without changing the slug."
- "Onboard this TypeScript app so PageGun MCP can safely update its route pages."
rg -n "export (function|const)|interface .*Props|type .*Props" app pages src components
Find:
- The route/component that renders the page.
- The section components it accepts.
- The JSON shape the renderer can handle.
- Required fields vs optional fields.
- Asset fields that must be URLs or local paths.
Prefer existing local component props over invented PageGun fields. If the renderer already has a section registry, use it.
### 2. Select The PageGun Project
If the user did not specify a project, list projects:
```bash
curl -sS "https://api.pagegun.com/projects" \
-H "Authorization: Bearer $PAGEGUN_API_KEY"Show project IDs and names. Do not guess the target project.
3. Resolve The Route Page
For a route /{route}:
- Read the project:
get_project({ project_id }) - Check
settings.site_routes["/{route}"] - Read the page row:
get_page({ project_id, subroute: "{route}" }) - If the page exists, continue with schema first.
- If the page does not exist, create a draft page row with
create_page.
MCP create shape:
{
"project_id": "proj_...",
"title": "Route Title",
"subroute": "{route}",
"slug": null,
"content_schema": "name: route-page\nversion: 1\ntype: sections\nsections:\n - type: hero\n required: true\n fields:\n headline:\n type: string\n",
"config": {
"meta": { "title": "Route Title", "description": "Draft route page." },
"sections": [
{ "type": "hero", "headline": "Draft headline" }
]
}
}create_page creates drafts only. Publishing is a separate publish_page call.
create_page requires an effective schema. Pass page-level content_schema when creating a route/index page, or make sure subroutes.config.content_schema exists for the route. If neither exists, MCP should remind you and refuse the write unless the user explicitly approved skip_schema: true.
Only add or edit settings.site_routes["/{route}"] if routing is missing or the user asked for routing changes. Prefer update_project_settings for top-level settings merges. If you use update_project, GET the project first and PUT the merged full settings object.
Use this route config shape unless the existing project uses another compatible shape:
{
"site_routes": {
"/{route}": { "template_type": "page" }
}
}Set subroute_type only when the user or existing settings clearly require single or collection.
4. Build The Page-Level Schema
The page-level schema lives on pages.content_schema. It validates that one page row and wins over route fallback schema.
Priority:
pages.content_schemasubroutes.config.content_schema
If both exist and conflict, page schema wins.
Every JSON page create/update/publish must have an effective schema. If no schema exists, the write should fail. Bypass only with explicit approval:
- MCP:
skip_schema: true - REST:
?skip_schema=true
Use bypass only to recover from a known bad state, then immediately set a real schema.
5. Schema Format
Schema is YAML. Top-level name is required. version is a number when present.
Sections mode validates config.sections:
name: route-index-page
description: Contract for a route index page
version: 1
type: sections
sections:
- type: hero
required: true
fields:
headline:
type: string
min: 8
max: 90
body:
type: string
max: 220
optional: true
actions:
type: list
optional: true
max: 2
item:
label:
type: string
href:
type: path
variant:
type: string
optional: true
enum: [primary, secondary, outline]
- type: features
required: false
fields:
headline:
type: string
items:
type: list
min: 3
max: 12
item:
title:
type: string
description:
type: string
href:
type: path
optional: true
- type: cta
required: false
fields:
headline:
type: string
body:
type: string
optional: trueSupported field types:
string, number, boolean, url, path, lucide-icon, list, markdown, string[], datetimeFields are required by default. Add optional: true or required: false for optional fields.
The schema validates allowed section types and required/typed fields. It does not replace renderer QA; if the renderer silently drops unknown fields, tighten the schema and read back the page.
6. Set Schema Before Content
For an existing route page:
get_page_schema({ page_id })set_page_schema({ page_id, content_schema })- If current config fails the new schema, either adjust the schema or update content in the same safe sequence.
For a missing route page:
- Create it via REST with
content_schemaand a minimal valid draftconfig. - Read it back with
get_page. - Continue through MCP.
Never update JSON config first and hope schema catches up later. That's backwards.
7. Update Content
Always fetch current config first:
get_page({ page_id })- Merge the intended section changes locally.
- Validate the merged shape against the page schema mentally before writing.
update_page({ page_id, updates: { config: mergedConfig } })get_page({ page_id })again and inspect the result.
If the target page uses PageGun's standard section config, use the v5 section types documented in get_json_page_guide.
If the target app uses a custom local renderer, match that renderer's section contract exactly.
8. Publish
Publishing writes the live Data Mode snapshot/CDN state. A request to make the site or page live is authorisation to publish it. Ask first only if the user framed the request as a draft, or if readiness returns requires_explicit_publish_approval=true.
Then:
publish_page({ page_id })Publish after schema/content/metadata changes when the user wants the public site updated.
9. Subroute Schema
Use subroute schema only for route-wide fallback behavior, especially child pages under the route.
Do not put a specific route page's schema only on the subroute if that page has its own contract. Put it on pages.content_schema.
Subroute schema is useful when many child pages share the same shape. It should not override a custom page-level schema.
10. Final Report
Report:
- Project ID/name.
- Route path.
- Page ID.
- Whether the page row existed or was created.
- Effective schema source:
page,subroute, or none. - Whether
pages.content_schemawas set or changed. - Whether
configwas changed. - Whether publish was skipped or completed.
- Any bypass used. If bypass was used, say why.
Completion Standard
The work is done only when:
- The correct project was selected.
- The route page row was found or created.
- Page-level schema exists before JSON content writes.
- The page config validates under the effective schema.
- Changes were read back after write.
- Publish ran only after readiness blockers were clear.
## What You Can Ask Cursor
- "List the earliest 3 blog posts in my PageGun project."
- "Create a blog post with a YouTube embed."
- "Update this article body without changing the slug."
- "Create a docs page under `agents/best-practices`."
- "Update the docs sidebar navigation."
- "Translate this blog post into Japanese without changing the slug."
- "Onboard this TypeScript app so PageGun MCP can safely update its route pages."