Skip to content

feat(cms): add getPageUrl MCP tool for resolving page URLs#38

Merged
jhb-dev merged 2 commits into
mainfrom
claude/getpageurl-mcp-tool-d0kne1
Jun 27, 2026
Merged

feat(cms): add getPageUrl MCP tool for resolving page URLs#38
jhb-dev merged 2 commits into
mainfrom
claude/getpageurl-mcp-tool-d0kne1

Conversation

@jhb-dev

@jhb-dev jhb-dev commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new MCP (Model Context Protocol) tool called getPageUrl that allows resolving frontend page URLs for documents by their collection and ID. This tool supports both published and draft pages, with an optional preview mode.

Changes

  • New parameter schema (getPageUrlParameters): Defines the input parameters for the tool:

    • collection: The page collection slug (e.g., pages, projects, articles, authors)
    • id: The document ID (string or number)
    • preview: Optional boolean flag to generate preview URLs (defaults to true)
  • New MCP tool handler (getPageUrl): Implements the tool with the following logic:

    • Validates that the provided collection is a valid page collection
    • Fetches the document by ID with draft access enabled
    • Generates the appropriate frontend URL using the document's path
    • Returns the URL or descriptive error messages for invalid inputs or missing documents
    • Handles errors gracefully with detailed error reporting

Implementation Details

  • The tool uses req.payload.findByID() with draft: true to support both published and unpublished pages
  • URL generation delegates to the existing generatePageURL() utility function
  • All error cases return JSON-formatted responses for consistent API behavior
  • The tool respects access control by setting overrideAccess: false

https://claude.ai/code/session_01XoTWiBZkvv2xQ4UKHg7rsV

claude added 2 commits June 26, 2026 06:31
Resolves the frontend URL for a page document by its collection and ID,
working for both published and draft pages. Returns a preview URL with a
token by default; pass preview=false for the canonical public URL.

Mirrors the getPageUrl tool from the tm-websites repo, adapted to this
repo's inline MCP plugin config and zod v4 setup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XoTWiBZkvv2xQ4UKHg7rsV
This repo's generatePageURL does not append a preview token (it only
prepends the /preview path segment), so drop the inaccurate "with a
token" wording. Also reword the summary to "Get the frontend page URL".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XoTWiBZkvv2xQ4UKHg7rsV
@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
website Ignored Ignored Jun 27, 2026 3:06pm
website-cms Ignored Ignored Jun 27, 2026 3:06pm

Request Review

@jhb-dev jhb-dev changed the title Add getPageUrl MCP tool for resolving page URLs feat(cms): add getPageUrl MCP tool for resolving page URLs Jun 27, 2026
@jhb-dev
jhb-dev merged commit b89a47b into main Jun 27, 2026
16 of 17 checks passed
@jhb-dev
jhb-dev deleted the claude/getpageurl-mcp-tool-d0kne1 branch June 27, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants