| 开发者 | spokospace |
|---|---|
| 更新时间 | 2026年12月2日 04:11 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | MIT |
| 版权网址: | 版权信息 |
12.0.3), so a change replaces, inserts, moves or deletes exactly that block and leaves the rest of the post byte for byte.dry_run.find-posts: search posts and pages by title, slug or ID.get-outline: the block tree with paths, names and text previews, plus the content hash.get-blocks: the markup of blocks by path.validate-post: report broken block structure.find-media: search the media library by title or file name.replace-block, insert-blocks, delete-block, move-blocks, unwrap-block: edit blocks by path.link-images: link every unlinked image of a post to its full-size file, so a lightbox can open it.create-draft: create a new post or page as a draft, for example from a Markdown file. It never publishes.edit_post for the post, upload_files for the media library, which lists only files the user may read, edit_posts or edit_pages for create-draft). replace-block, unwrap-block and delete-block are marked destructive, so MCP clients that confirm destructive tools ask before running them. The plugin adds no settings screen. Its only data is a short-lived lock row in the options table while a write runs, and two post meta fields on the drafts create-draft makes.
Drafts from Markdown
create-draft puts an article written elsewhere into WordPress as a draft. The agent converts the Markdown to blocks and maps the front matter to the tool's fields: title, slug, excerpt, existing categories and tags, a featured image from the media library and, with Polylang, the language. The status is always draft, so the agent's user needs edit_posts and never publish_posts; a Contributor account is enough, and a person publishes. The markup is filtered and checked like every other write, dry_run creates nothing, and a source_key (for example the file path) keeps a retried call from making a second draft.
A site that wants the agent to edit only existing posts turns it off:
define( 'SPOKO_CONTENT_MCP_CREATE_DRAFTS', false );
or with the spoko_content_mcp_create_drafts filter.
HTML filtering
An agent decides what to write after reading content that other people wrote, and that content can contain instructions meant for it. So the markup an agent sends is filtered the way WordPress filters authors without the unfiltered_html capability (scripts, event handlers and unknown tags are removed), also when the agent signs in as an Administrator or Editor. The plugin filters only what the agent sends: for users with unfiltered_html the rest of the post, its title and excerpt stay as they are; for users without it WordPress filters every save of the whole post, as it always does. The tool reports content_filtered_on_save: true when the filter changed the markup (removed something, or normalized it, for example attribute order or <img/>), in a dry run too. An agent that re-sends a block containing such HTML, for example to fix a typo next to a script, loses that HTML unless the site opts in. Of core blocks, this affects data: URLs, as it does for Authors in the editor.
For users with unfiltered_html the filter also keeps what cannot run a script in the page: iframes from https:// embed addresses of YouTube, Vimeo, Google Maps, Google Drive and Docs, Spotify, SoundCloud and OpenStreetMap (change the list with the spoko_content_mcp_embed_hosts filter); PDFs from the media library in an iframe or in the File block's preview; and inline SVG drawings without scripts, links or animation. Any other iframe or object loses its address. The spoko_content_mcp_allowed_html filter ($tags, $post) changes the whole tag list.
A site that needs raw HTML from the agent can opt in, which only matters for users who have unfiltered_html:
define( 'SPOKO_CONTENT_MCP_ALLOW_UNFILTERED_HTML', true );
or with the spoko_content_mcp_allow_unfiltered_html filter ($allow, $post).
Headless sites
If your frontend serves the uploads under its own address, link-images can link there instead of to WordPress. Set the address in wp-config.php:
define( 'SPOKO_CONTENT_MCP_MEDIA_BASE', 'https://example.com/images' );
or with the spoko_content_mcp_media_base filter. Older media hosts to rewrite as well can be added with the spoko_content_mcp_media_aliases filter.
More about the plugin, with examples: spoko.space/wordpress-content-editor-mcp. Development happens on GitHub. Made by spoko.space.
https://your-site/wp-json/spoko/content, for example with @automattic/mcp-wordpress-remote, using that user and application password.Any client that can reach a WordPress MCP Adapter server, for example Claude (desktop and Claude Code) or Cursor through @automattic/mcp-wordpress-remote.
No more than the WordPress user it signs in as. Give that user the smallest role that works, for example Author for its own posts or Editor for everyone's, and never an administrator account. Its HTML is filtered either way (see HTML filtering).
No. create-draft makes drafts only, and the editing tools change content, not the status. A person publishes in WordPress.
Every save creates a normal revision. Restore it from the block editor (Revisions), or note the revision_id the tool returns.
The tools work on block content. Classic (freeform) content is reported as such and left alone.
code, message, data) instead of the message alone, so draft_exists carries the existing draft's post_id.find-posts gives a never-edited draft its real modified date instead of 0000-00-00 00:00:00.create-draft: an agent creates a new post or page as a draft, for example from a Markdown file, with title, slug, excerpt, existing categories and tags, featured image and Polylang language. It never publishes and needs no publish_posts. Turn it off with SPOKO_CONTENT_MCP_CREATE_DRAFTS or the spoko_content_mcp_create_drafts filter.viewBox, preserveAspectRatio, gradientUnits and the like) on WordPress 7.x, so an unchanged drawing is saved byte for byte and is not reported as filtered.unfiltered_html, also for Administrators and Editors (who keep iframes from known embed hosts, PDFs from the site and inline SVG drawings); the rest of the post is left as it is. Opt out with SPOKO_CONTENT_MCP_ALLOW_UNFILTERED_HTML or the spoko_content_mcp_allow_unfiltered_html filter.post_busy; one that ran so long that its lock was taken over returns lock_lost instead of saving.replace-block and unwrap-block are marked destructive.markup up to 1,000,000 characters, move-blocks count up to 100.spoko_content_mcp_image_attachment can pick another./wp-json/spoko/content.