Skip to content

Filters and hooks

EMCP Tools is built like a normal WordPress plugin. Features are wired through filters and actions so other plugins or your theme’s functions.php can extend them.

Runs on every MCP request after the plugin has registered its abilities. Receives the full array of ability names; return a modified array.

add_filter( 'emcp_tools_ability_names', function ( array $names ): array {
// Hide a specific tool from MCP clients regardless of admin toggles.
return array_diff( $names, array( 'emcp-tools/add-form' ) );
} );

The plugin uses this filter itself to apply the admin “disabled tools” toggles. Your filter runs alongside those, additive.

The URL the premium prompts fetcher calls. Defaults to https://emcptools.com/api/emcp/prompts.json. Override for staging environments:

add_filter( 'emcp_tools_pro_prompts_endpoint', function (): string {
return 'http://localhost:4321/api/emcp/prompts.json';
} );

New in 3.18.0. Filters the checks behind the Dashboard’s Needs your attention card. Each check is an object implementing the EMCP_Tools_Attention_Check interface: id() (a stable id, used for dismissal), applies() (whether the item shows now), state() (a short fingerprint of the condition; a dismissed item comes back when it changes) and item() (an array with id, icon, title, body, action_label, action_url and severity). Anything that isn’t an EMCP_Tools_Attention_Check is ignored.

add_filter( 'emcp_tools_attention_checks', function ( array $checks ): array {
$checks[] = new My_Plugin_Attention_Check(); // implements EMCP_Tools_Attention_Check
return $checks;
} );

Results are cached for 10 minutes, and a check that throws is skipped.

Filters the skill catalog that list-skills, get-skill, the discovery context and AI Chat read. Each entry is an array with slug, name, description and a source; an entry that is not a bundled skill also carries its Markdown body. EMCP’s own custom skills are added through this filter.

Fires once the built-in and Pro modules are registered, before module defaults are applied. It receives the module registry, so a plugin can register its own module (a class extending EMCP_Tools_Module), which then gets a card on EMCP Tools → Modules like the built-in ones. See Modules.

add_action( 'emcp_tools_register_modules', function ( $registry ) {
$registry->register( new My_Plugin_Module() ); // extends EMCP_Tools_Module
} );

Fires once after the Freemius SDK initializes. Use this to safely call emcp_tools_fs() from a plugin that loads before EMCP Tools:

add_action( 'emcp_tools_fs_loaded', function () {
if ( emcp_tools_fs()->can_use_premium_code() ) {
// Pro is active on this site.
}
} );

EMCP Tools wires the Freemius after_uninstall hook to clean up its options:

emcp_tools_fs()->add_action( 'after_uninstall', 'emcp_tools_after_uninstall' );

You can add your own callbacks on the same hook from another plugin:

emcp_tools_fs()->add_action( 'after_uninstall', function () {
delete_option( 'my_plugin_emcp_extension_options' );
} );

Other useful Freemius hooks: after_premium_version_activation, after_account_user_change, after_license_activation. See the Freemius docs for the full list.

The plugin uses the standard WordPress Abilities API to register every tool. To add your own MCP tool from another plugin:

add_action( 'wp_abilities_api_init', function () {
wp_register_ability( 'my-plugin/my-custom-tool', array(
'label' => __( 'My Custom Tool', 'my-plugin' ),
'description' => __( 'Does a custom thing.', 'my-plugin' ),
'category' => 'my-plugin',
'execute_callback' => function ( $input ) {
// Your logic here.
return array( 'result' => 'success' );
},
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
'input_schema' => array(
'type' => 'object',
'properties' => array(
'foo' => array( 'type' => 'string' ),
),
),
'output_schema' => array(
'type' => 'object',
'properties' => array(
'result' => array( 'type' => 'string' ),
),
),
) );
} );

Then add it to the MCP server’s tools array via mcp_adapter_init (see the WordPress MCP Adapter docs).

Your tool will appear in MCP clients alongside EMCP Tools’ built-ins, with the same permission and schema-validation guarantees.