Action
uncanny-automator
uncanny_automator_mcp_tool_registry_register
Fires when the Uncanny Automator MCP tool registry is being registered to allow for custom tool additions.
add_action( 'uncanny_automator_mcp_tool_registry_register', $callback, 10, 1 );
Description
Fires after core Uncanny Automator Model Context Protocol tools are registered. Developers can hook into this action to register their own custom MCP tools, extending Automator's API capabilities with new integrations. The registered tools are available via the `$this` parameter.
Usage
add_action( 'uncanny_automator_mcp_tool_registry_register', 'your_function_name', 10, 1 );
Parameters
-
$this(mixed) - This parameter is an instance of the `ToolRegistry` class itself, providing access to its methods for registering tools.
Examples
<?php
/**
* Example function to add a new custom tool to the Uncanny Automator MCP tool registry.
*
* This function demonstrates how to hook into 'uncanny_automator_mcp_tool_registry_register'
* and register a new custom tool.
*
* @param object $tool_registry The instance of the Tool_Registry class.
*/
function my_custom_automator_tool_registry_register( $tool_registry ) {
// Ensure we have the correct object type, though Uncanny Automator's hook usually handles this.
if ( ! is_a( $tool_registry, 'Uncanny_Automator_Mcp_Tool_Registry' ) ) {
return;
}
// Registering a hypothetical custom tool. Replace 'My_Custom_Tool' with your actual tool class name.
// You would need to define the 'My_Custom_Tool' class elsewhere, implementing the necessary interfaces
// for Uncanny Automator tools.
if ( class_exists( 'My_Custom_Tool' ) ) {
$tool_registry->register_tool( new My_Custom_Tool() );
}
}
// Add the action to the 'uncanny_automator_mcp_tool_registry_register' hook.
// The third parameter '1' indicates that this callback accepts 1 argument ($this from the hook).
add_action( 'uncanny_automator_mcp_tool_registry_register', 'my_custom_automator_tool_registry_register', 10, 1 );
?>
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/api/transports/model-context-protocol/tools/class-tool-registry.php:258
public function auto_register_tools() {
// Recipe tools.
$this->register_tool( new Get_Recipe_Tool() );
$this->register_tool( new List_Recipes_Tool() );
$this->register_tool( new Save_Recipe_Tool() );
// Discovery tools.
$this->register_tool( new Search_Tool() );
$this->register_tool( new Get_Component_Schema_Tool() );
// Not auto-registered on the server: the MCP client injects a local tool exposed to the
// model as get_field_options, backed by the standalone dropdown REST endpoint.
$this->register_tool( new Get_Posts_Tool() );
$this->register_tool( new Get_Terms_Tool() );
$this->register_tool( new List_Plugins_Tool() );
$this->register_tool( new List_Users_Tool() );
$this->register_tool( new List_Roles_Tool() );
// MySQL tools.
$this->register_tool( new Mysql_Get_Tables_Tool() );
$this->register_tool( new Mysql_Get_Table_Columns_Tool() );
$this->register_tool( new Mysql_Select_From_Table_Tool() );
// Consolidated CRUD tools (upsert pattern: id absent = create, id present = update).
$this->register_tool( new Save_Trigger_Tool() );
$this->register_tool( new Save_Action_Tool() );
$this->register_tool( new Save_Condition_Group_Tool() );
$this->register_tool( new Save_Condition_Tool() );
$this->register_tool( new Save_Loop_Tool() );
$this->register_tool( new Save_Loop_Filter_Tool() );
// Consolidated utility tools.
$this->register_tool( new Execute_Tool() );
$this->register_tool( new Get_Tokens_Tool() );
$this->register_tool( new Get_Logs_Tool() );
$this->register_tool( new Delete_Tool() );
do_action( 'uncanny_automator_mcp_tool_registry_register', $this );
}