Update Yoast Canonical URL


Sets or clears the canonical URL for a post. Only absolute http(s) URLs are accepted. Pass an empty string to clear the override and fall back to the post permalink. Warnings are returned when the canonical points at another domain or at a different post on this site, because either one removes this post from search results.

Property Value
Ability slug mosmcp/update-canonical
Wire tool name mosmcp__update-canonical
Category Yoast SEO (mosmcp-yoast)
Plan Free

 

Required access

Requirement Value
Capability edit_posts, edit_post (checked against the specific post)
Minimum default role Contributor
Requires Yoast SEO
Annotations readOnly: false · destructive: false · idempotent: true · openWorld: true

 

Input schema

Field Type Required Default Description
post_id integer Yes — ID of the post/page/CPT entry.
canonical_url string Yes — Absolute http(s) URL, or an empty string to clear the override.

 

Output schema

Field Type Required
success boolean
canonical_url string
cleared boolean
warnings object[]
warnings[].code string
warnings[].message string

 

Example

Sample prompt
Set the canonical URL of post 42 to https://example.com/speed-guide/.

Example request (json)

{
  "jsonrpc": "2.0",
  "id": 397,
  "method": "tools/call",
  "params": {
    "name": "mosmcp__update-canonical",
    "arguments": {
      "input": {
        "post_id": 42,
        "canonical_url": "https://example.com/speed-guide/"
      }
    }
  }
}

Example response (json)

{
  "jsonrpc": "2.0",
  "id": 397,
  "result": {
    "isError": false,
    "structuredContent": {
      "success": true,
      "canonical_url": "https://example.com/speed-guide/",
      "cleared": false,
      "warnings": []
    }
  }
}

 

Edge cases / errors

  • Relative, non-http(s) or host-less URL -> refused with ysoa_invalid_canonical.
  • Canonical on another domain -> saved with a cross_domain_canonical warning; pointing at a different post on this site -> canonical_points_to_other_post warning (either drops this post from search).
  • Yoast discards the value as unsafe -> refused with ysoa_canonical_rejected rather than a silent no-op.
  • Empty canonical_url -> override removed, cleared true, falls back to the permalink.

 


<< Previous Next >>
Update Yoast Breadcrumb Title Update Yoast Focus Keyword

For more information about the Secure MCP Server for WordPress plugin, explore the following resources:

Product Overview | Pricing | Try for Free | Documentation

If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.