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';
} );

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.