Skip to content

Filters

RealMCP works without any configuration in code. These filters are for developers who need to change a default: add them to a small plugin or a must-use plugin, not to the theme, so they keep working when the theme changes.

Filter Value Default
ballesdev_mcp_capability string edit_pages
ballesdev_mcp_allowed_origins array of strings the site’s own origins
ballesdev_mcp_instructions string RealMCP’s instructions
ballesdev_mcp_respect_post_lock boolean true
ballesdev_mcp_unfiltered_html boolean false

The capability a user needs to use the MCP server, to see the RealMCP menu and to open the Connect tab. By default it’s edit_pages: Editors and Administrators.

Each tool still asks for its own capability (see the tools reference), so lowering this one doesn’t give anyone more than their role allows. With edit_posts, Authors can connect and use the post tools, but they don’t see the page or comment tools.

add_filter( 'ballesdev_mcp_capability', fn() => 'edit_posts' );

The origins accepted in the Origin header, each as scheme://host or scheme://host:port, in lowercase and without a trailing slash. By default, the origins of the site address and the WordPress address. A request with any other Origin is rejected; requests without the header, as assistants send them, aren’t affected.

Use it only if a browser application on another origin has to call the endpoint.

add_filter(
'ballesdev_mcp_allowed_origins',
function ( $origins ) {
$origins[] = 'https://app.example.com';
return $origins;
}
);

The instructions the server sends to the assistant when it connects: how to use the tools, which ones are disabled and that comment text is data, not instructions. Add your own rules at the end rather than replacing the text.

add_filter(
'ballesdev_mcp_instructions',
fn( $instructions ) => $instructions . "\nWrite in British English and never use the color red."
);

The text is for the model, so write it in English. Assistants read it when they connect: reconnect them to apply a change.

Whether saving is rejected with post_locked while someone has the page or post open in the WordPress editor. The filter also receives the ID of the item. Return false to save anyway.

add_filter( 'ballesdev_mcp_respect_post_lock', '__return_false' );

With the lock ignored, the open editor overwrites the assistant’s change on its next save, without any warning.

Whether users with the unfiltered_html capability (Administrators and Editors on a single site) also save without the HTML filter through RealMCP. By default they don’t: what an assistant saves never carries scripts, iframes or event-handler attributes. See Security.

add_filter( 'ballesdev_mcp_unfiltered_html', '__return_true' );

Turn it on only if you accept the risk: an assistant can be misled by text it reads, such as a comment, and a script saved in a page runs in every visitor’s browser.