Files

306 lines
53 KiB
PHP

<?php
namespace AskTamMCP\MCP;
defined('ABSPATH') || exit;
class Registry {
private array $tools = [];
public function __construct() {
$this->registerAll();
}
public function getToolDefinitions(): array {
return array_values(array_map(function($t) {
$schema = $t['inputSchema'];
if (isset($schema['properties']) && $schema['properties'] === []) {
$schema['properties'] = new \stdClass();
}
return ['name'=>$t['name'],'description'=>$t['description'],'inputSchema'=>$schema];
}, $this->tools));
}
public function getHandler(string $name): ?callable {
if (!isset($this->tools[$name])) return null;
$h = $this->tools[$name]['handler'];
if ($h instanceof \Closure) return $h;
if (is_array($h)) return $h;
if (is_string($h) && str_contains($h, '::')) {
[$class, $method] = explode('::', $h, 2);
return function(array $args) use ($class, $method) {
return $class::$method($args);
};
}
return null;
}
public function getTool(string $name): ?array {
return $this->tools[$name] ?? null;
}
private function registerAll(): void {
$this->registerPostTools();
$this->registerPageTools();
$this->registerMediaTools();
$this->registerUserTools();
$this->registerTaxonomyTools();
$this->registerOptionTools();
$this->registerPluginTools();
$this->registerThemeTools();
$this->registerMenuTools();
$this->registerCommentTools();
$this->registerSeoTools();
$this->registerSiteTools();
if (class_exists('WooCommerce')) $this->registerWooCommerceTools();
if (defined('ELEMENTOR_VERSION')) $this->registerElementorTools();
$this->registerFileManagerTools();
$this->registerEmailTools();
$this->registerTransientTools();
$this->registerWidgetTools();
$this->registerCliTools();
$this->registerRawSqlTools();
$this->registerThemeDiscoveryTools();
do_action('asktam_mcp_register_tools', $this);
}
public function register(array $tool): void {
$this->tools[$tool['name']] = $tool;
}
private function registerElementorTools(): void {
$et = new \AskTamMCP\Elementor\Abilities\ElementorTools();
foreach ($et->getToolDefinitions() as $tool) {
$this->register($tool);
}
}
private function registerPostTools(): void {
$this->register(['name'=>'list_posts','description'=>'List WordPress posts.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PostTools::listPosts','inputSchema'=>['type'=>'object','properties'=>['status'=>['type'=>'string','default'=>'publish'],'per_page'=>['type'=>'integer','default'=>20,'maximum'=>100],'page'=>['type'=>'integer','default'=>1],'search'=>['type'=>'string'],'author'=>['type'=>'integer'],'category_id'=>['type'=>'integer'],'tag_id'=>['type'=>'integer'],'orderby'=>['type'=>'string','default'=>'date'],'order'=>['type'=>'string','default'=>'DESC','enum'=>['ASC','DESC']],'after'=>['type'=>'string'],'before'=>['type'=>'string'],'post_type'=>['type'=>'string','default'=>'post']]]]);
$this->register(['name'=>'get_post','description'=>'Get full details of a WordPress post.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PostTools::getPost','inputSchema'=>['type'=>'object','required'=>['post_id'],'properties'=>['post_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'create_post','description'=>'Create a new WordPress post.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PostTools::createPost','inputSchema'=>['type'=>'object','required'=>['title'],'properties'=>['title'=>['type'=>'string'],'content'=>['type'=>'string'],'excerpt'=>['type'=>'string'],'status'=>['type'=>'string','default'=>'draft','enum'=>['publish','draft','pending','private']],'author'=>['type'=>'integer'],'categories'=>['type'=>'array','items'=>['type'=>'integer']],'tags'=>['type'=>'array','items'=>['type'=>'integer']],'meta'=>['type'=>'object'],'featured_media'=>['type'=>'integer'],'slug'=>['type'=>'string'],'post_type'=>['type'=>'string','default'=>'post']]]]);
$this->register(['name'=>'update_post','description'=>'Update an existing WordPress post.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PostTools::updatePost','inputSchema'=>['type'=>'object','required'=>['post_id'],'properties'=>['post_id'=>['type'=>'integer'],'title'=>['type'=>'string'],'content'=>['type'=>'string'],'excerpt'=>['type'=>'string'],'status'=>['type'=>'string'],'categories'=>['type'=>'array','items'=>['type'=>'integer']],'tags'=>['type'=>'array','items'=>['type'=>'integer']],'meta'=>['type'=>'object'],'featured_media'=>['type'=>'integer'],'slug'=>['type'=>'string']]]]);
$this->register(['name'=>'delete_post','description'=>'Delete or trash a WordPress post.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PostTools::deletePost','inputSchema'=>['type'=>'object','required'=>['post_id'],'properties'=>['post_id'=>['type'=>'integer'],'force'=>['type'=>'boolean','default'=>false]]]]);
$this->register(['name'=>'get_post_meta','description'=>'Get post meta data.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PostTools::getPostMeta','inputSchema'=>['type'=>'object','required'=>['post_id'],'properties'=>['post_id'=>['type'=>'integer'],'meta_key'=>['type'=>'string']]]]);
$this->register(['name'=>'update_post_meta','description'=>'Update post meta data.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PostTools::updatePostMeta','inputSchema'=>['type'=>'object','required'=>['post_id','meta_key','meta_value'],'properties'=>['post_id'=>['type'=>'integer'],'meta_key'=>['type'=>'string'],'meta_value'=>[]]]]);
$this->register(['name'=>'delete_post_meta','description'=>'Delete post meta data.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PostTools::deletePostMeta','inputSchema'=>['type'=>'object','required'=>['post_id','meta_key'],'properties'=>['post_id'=>['type'=>'integer'],'meta_key'=>['type'=>'string']]]]);
$this->register(['name'=>'set_featured_image','description'=>'Set featured image on a post. media_id must be an existing attachment.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PostTools::setFeaturedImage','inputSchema'=>['type'=>'object','required'=>['post_id','media_id'],'properties'=>['post_id'=>['type'=>'integer'],'media_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'count_posts','description'=>'Get post counts by status.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PostTools::countPosts','inputSchema'=>['type'=>'object','properties'=>['post_type'=>['type'=>'string','default'=>'post']]]]);
$this->register(['name'=>'get_post_revisions','description'=>'Get the revision history for a post.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PostTools::getPostRevisions','inputSchema'=>['type'=>'object','required'=>['post_id'],'properties'=>['post_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'get_post_types','description'=>'Get all registered public post types.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PostTools::getPostTypes','inputSchema'=>['type'=>'object','properties'=>['include_builtin'=>['type'=>'boolean','default'=>true]]]]);
$this->register(['name'=>'add_post_terms','description'=>'Add or replace terms on a post in any taxonomy.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PostTools::addPostTerms','inputSchema'=>['type'=>'object','required'=>['post_id','taxonomy','terms'],'properties'=>['post_id'=>['type'=>'integer'],'taxonomy'=>['type'=>'string'],'terms'=>['type'=>'array','items'=>['type'=>['integer','string']]],'append'=>['type'=>'boolean','default'=>true]]]]);
$this->register(['name'=>'wp_restore_revision','description'=>'Restore a post to a specific revision.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PostTools::restoreRevision','inputSchema'=>['type'=>'object','required'=>['revision_id'],'properties'=>['revision_id'=>['type'=>'integer']]]]);
}
private function registerPageTools(): void {
$this->register(['name'=>'list_pages','description'=>'List WordPress pages.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PageTools::listPages','inputSchema'=>['type'=>'object','properties'=>['status'=>['type'=>'string','default'=>'publish'],'per_page'=>['type'=>'integer','default'=>20],'page'=>['type'=>'integer','default'=>1],'search'=>['type'=>'string'],'parent'=>['type'=>'integer']]]]);
$this->register(['name'=>'get_page','description'=>'Get a single WordPress page.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PageTools::getPage','inputSchema'=>['type'=>'object','required'=>['page_id'],'properties'=>['page_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'create_page','description'=>'Create a new WordPress page.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PageTools::createPage','inputSchema'=>['type'=>'object','required'=>['title'],'properties'=>['title'=>['type'=>'string'],'content'=>['type'=>'string'],'status'=>['type'=>'string','default'=>'draft'],'parent'=>['type'=>'integer'],'slug'=>['type'=>'string'],'template'=>['type'=>'string'],'meta'=>['type'=>'object']]]]);
$this->register(['name'=>'update_page','description'=>'Update an existing WordPress page.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PageTools::updatePage','inputSchema'=>['type'=>'object','required'=>['page_id'],'properties'=>['page_id'=>['type'=>'integer'],'title'=>['type'=>'string'],'content'=>['type'=>'string'],'status'=>['type'=>'string'],'parent'=>['type'=>'integer'],'template'=>['type'=>'string'],'meta'=>['type'=>'object']]]]);
$this->register(['name'=>'delete_page','description'=>'Delete or trash a WordPress page.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\PageTools::deletePage','inputSchema'=>['type'=>'object','required'=>['page_id'],'properties'=>['page_id'=>['type'=>'integer'],'force'=>['type'=>'boolean','default'=>false]]]]);
}
private function registerMediaTools(): void {
$this->register(['name'=>'list_media','description'=>'List WordPress media library items.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\MediaTools::listMedia','inputSchema'=>['type'=>'object','properties'=>['per_page'=>['type'=>'integer','default'=>20],'page'=>['type'=>'integer','default'=>1],'mime_type'=>['type'=>'string'],'search'=>['type'=>'string']]]]);
$this->register(['name'=>'get_media','description'=>'Get a single media item by ID.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\MediaTools::getMedia','inputSchema'=>['type'=>'object','required'=>['media_id'],'properties'=>['media_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'upload_media','description'=>'Upload a media file from a public URL.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\MediaTools::uploadMedia','inputSchema'=>['type'=>'object','required'=>['source_url'],'properties'=>['source_url'=>['type'=>'string'],'title'=>['type'=>'string'],'alt_text'=>['type'=>'string'],'caption'=>['type'=>'string'],'post_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'update_media','description'=>'Update metadata on an existing media attachment.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\MediaTools::updateMedia','inputSchema'=>['type'=>'object','required'=>['media_id'],'properties'=>['media_id'=>['type'=>'integer'],'title'=>['type'=>'string'],'alt_text'=>['type'=>'string'],'caption'=>['type'=>'string'],'description'=>['type'=>'string']]]]);
$this->register(['name'=>'delete_media','description'=>'Delete a media item permanently.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\MediaTools::deleteMedia','inputSchema'=>['type'=>'object','required'=>['media_id'],'properties'=>['media_id'=>['type'=>'integer'],'force'=>['type'=>'boolean','default'=>true]]]]);
$this->register(['name'=>'count_media','description'=>'Get media counts by type.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\MediaTools::countMedia','inputSchema'=>['type'=>'object','properties'=>[]]]);
}
private function registerUserTools(): void {
$this->register(['name'=>'list_users','description'=>'List WordPress users.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\UserTools::listUsers','inputSchema'=>['type'=>'object','properties'=>['role'=>['type'=>'string'],'per_page'=>['type'=>'integer','default'=>20],'page'=>['type'=>'integer','default'=>1],'search'=>['type'=>'string']]]]);
$this->register(['name'=>'get_user','description'=>'Get a single user by ID.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\UserTools::getUser','inputSchema'=>['type'=>'object','required'=>['user_id'],'properties'=>['user_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'create_user','description'=>'Create a new WordPress user.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\UserTools::createUser','inputSchema'=>['type'=>'object','required'=>['username','email','password'],'properties'=>['username'=>['type'=>'string'],'email'=>['type'=>'string'],'password'=>['type'=>'string'],'first_name'=>['type'=>'string'],'last_name'=>['type'=>'string'],'role'=>['type'=>'string','default'=>'subscriber']]]]);
$this->register(['name'=>'update_user','description'=>'Update an existing WordPress user.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\UserTools::updateUser','inputSchema'=>['type'=>'object','required'=>['user_id'],'properties'=>['user_id'=>['type'=>'integer'],'email'=>['type'=>'string'],'first_name'=>['type'=>'string'],'last_name'=>['type'=>'string'],'role'=>['type'=>'string'],'password'=>['type'=>'string'],'meta'=>['type'=>'object']]]]);
$this->register(['name'=>'delete_user','description'=>'Delete a WordPress user.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\UserTools::deleteUser','inputSchema'=>['type'=>'object','required'=>['user_id'],'properties'=>['user_id'=>['type'=>'integer'],'reassign'=>['type'=>'integer']]]]);
}
private function registerTaxonomyTools(): void {
$this->register(['name'=>'list_terms','description'=>'List terms in any taxonomy.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::listTerms','inputSchema'=>['type'=>'object','required'=>['taxonomy'],'properties'=>['taxonomy'=>['type'=>'string'],'parent'=>['type'=>'integer'],'search'=>['type'=>'string'],'per_page'=>['type'=>'integer','default'=>50]]]]);
$this->register(['name'=>'create_term','description'=>'Create a new term in a taxonomy.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::createTerm','inputSchema'=>['type'=>'object','required'=>['taxonomy','name'],'properties'=>['taxonomy'=>['type'=>'string'],'name'=>['type'=>'string'],'slug'=>['type'=>'string'],'description'=>['type'=>'string'],'parent'=>['type'=>'integer']]]]);
$this->register(['name'=>'update_term','description'=>'Update an existing term.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::updateTerm','inputSchema'=>['type'=>'object','required'=>['taxonomy','term_id'],'properties'=>['taxonomy'=>['type'=>'string'],'term_id'=>['type'=>'integer'],'name'=>['type'=>'string'],'slug'=>['type'=>'string'],'description'=>['type'=>'string'],'parent'=>['type'=>'integer']]]]);
$this->register(['name'=>'delete_term','description'=>'Delete a term from a taxonomy.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::deleteTerm','inputSchema'=>['type'=>'object','required'=>['taxonomy','term_id'],'properties'=>['taxonomy'=>['type'=>'string'],'term_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'count_terms','description'=>'Get term counts in a taxonomy.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::countTerms','inputSchema'=>['type'=>'object','required'=>['taxonomy'],'properties'=>['taxonomy'=>['type'=>'string']]]]);
$this->register(['name'=>'get_categories','description'=>'Get all categories.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::getCategories','inputSchema'=>['type'=>'object','properties'=>['parent'=>['type'=>'integer'],'search'=>['type'=>'string'],'per_page'=>['type'=>'integer','default'=>100]]]]);
$this->register(['name'=>'get_tags','description'=>'Get all tags.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::getTags','inputSchema'=>['type'=>'object','properties'=>['search'=>['type'=>'string'],'per_page'=>['type'=>'integer','default'=>100]]]]);
$this->register(['name'=>'get_taxonomies','description'=>'Get all registered public taxonomies.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::getTaxonomies','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'get_term_meta','description'=>'Get term meta data.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::getTermMeta','inputSchema'=>['type'=>'object','required'=>['term_id'],'properties'=>['term_id'=>['type'=>'integer'],'taxonomy'=>['type'=>'string'],'meta_key'=>['type'=>'string']]]]);
$this->register(['name'=>'update_term_meta','description'=>'Update term meta data.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::updateTermMeta','inputSchema'=>['type'=>'object','required'=>['term_id','meta_key','meta_value'],'properties'=>['term_id'=>['type'=>'integer'],'meta_key'=>['type'=>'string'],'meta_value'=>[]]]]);
$this->register(['name'=>'delete_term_meta','description'=>'Delete term meta data.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\TaxonomyTools::deleteTermMeta','inputSchema'=>['type'=>'object','required'=>['term_id','meta_key'],'properties'=>['term_id'=>['type'=>'integer'],'meta_key'=>['type'=>'string']]]]);
}
private function registerOptionTools(): void {
$this->register(['name'=>'get_option','description'=>'Get a WordPress option value.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\OptionTools::getOption','inputSchema'=>['type'=>'object','required'=>['option_name'],'properties'=>['option_name'=>['type'=>'string']]]]);
$this->register(['name'=>'update_option','description'=>'Update a WordPress option.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\OptionTools::updateOption','inputSchema'=>['type'=>'object','required'=>['option_name','option_value'],'properties'=>['option_name'=>['type'=>'string'],'option_value'=>['type'=>['string','number','boolean','object','array']]]]]);
$this->register(['name'=>'list_options','description'=>'List WordPress options matching a prefix.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\OptionTools::listOptions','inputSchema'=>['type'=>'object','properties'=>['prefix'=>['type'=>'string']]]]);
}
private function registerPluginTools(): void {
$this->register(['name'=>'list_plugins','description'=>'List all installed WordPress plugins with their status.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PluginTools::listPlugins','inputSchema'=>['type'=>'object','properties'=>['status'=>['type'=>'string','enum'=>['all','active','inactive'],'default'=>'all']]]]);
$this->register(['name'=>'get_plugins','description'=>'Get installed plugins (alias for list_plugins).','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PluginTools::listPlugins','inputSchema'=>['type'=>'object','properties'=>['status'=>['type'=>'string','default'=>'all']]]]);
$this->register(['name'=>'activate_plugin','description'=>'Activate a WordPress plugin.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\PluginTools::activatePlugin','inputSchema'=>['type'=>'object','required'=>['plugin'],'properties'=>['plugin'=>['type'=>'string']]]]);
$this->register(['name'=>'deactivate_plugin','description'=>'Deactivate a WordPress plugin.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\PluginTools::deactivatePlugin','inputSchema'=>['type'=>'object','required'=>['plugin'],'properties'=>['plugin'=>['type'=>'string']]]]);
$this->register(['name'=>'get_plugin_settings','description'=>'Get all options stored by a plugin, looked up by slug.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\PluginTools::getPluginSettings','inputSchema'=>['type'=>'object','required'=>['plugin_slug'],'properties'=>['plugin_slug'=>['type'=>'string']]]]);
}
private function registerThemeTools(): void {
$this->register(['name'=>'list_themes','description'=>'List all installed WordPress themes.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeTools::listThemes','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'get_themes','description'=>'Get installed themes (alias for list_themes).','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeTools::listThemes','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'get_active_theme','description'=>'Get the currently active WordPress theme.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeTools::getActiveTheme','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'switch_theme','description'=>'Switch the active WordPress theme.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\ThemeTools::switchTheme','inputSchema'=>['type'=>'object','required'=>['stylesheet'],'properties'=>['stylesheet'=>['type'=>'string']]]]);
$this->register(['name'=>'get_custom_css','description'=>'Get the active theme custom CSS.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeTools::getCustomCss','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'update_custom_css','description'=>'Update the active theme custom CSS.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\ThemeTools::updateCustomCss','inputSchema'=>['type'=>'object','required'=>['css'],'properties'=>['css'=>['type'=>'string']]]]);
$this->register(['name'=>'get_theme_mods','description'=>'Get all customizer settings (theme_mods) for the active theme.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeTools::getThemeMods','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'update_theme_mod','description'=>'Update a single theme customizer setting.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\ThemeTools::updateThemeMod','inputSchema'=>['type'=>'object','required'=>['mod_name','mod_value'],'properties'=>['mod_name'=>['type'=>'string'],'mod_value'=>[]]]]);
}
private function registerMenuTools(): void {
$this->register(['name'=>'list_menus','description'=>'List all WordPress navigation menus.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\MenuTools::listMenus','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'get_menus','description'=>'Get all navigation menus (alias for list_menus).','scope'=>'read','handler'=>'AskTamMCP\\Tools\\MenuTools::listMenus','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'get_menu','description'=>'Get all items in a navigation menu.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\MenuTools::getMenu','inputSchema'=>['type'=>'object','required'=>['menu'],'properties'=>['menu'=>['type'=>['string','integer']]]]]);
$this->register(['name'=>'get_menu_items','description'=>'Get items in a navigation menu.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\MenuTools::getMenuItems','inputSchema'=>['type'=>'object','required'=>['menu'],'properties'=>['menu'=>['type'=>['string','integer']]]]]);
$this->register(['name'=>'create_menu_item','description'=>'Create a new menu item in a navigation menu.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\MenuTools::createMenuItem','inputSchema'=>['type'=>'object','required'=>['menu'],'properties'=>['menu'=>['type'=>['string','integer']],'title'=>['type'=>'string'],'url'=>['type'=>'string'],'type'=>['type'=>'string','default'=>'custom'],'parent'=>['type'=>'integer'],'position'=>['type'=>'integer'],'object_id'=>['type'=>'integer'],'object'=>['type'=>'string']]]]);
$this->register(['name'=>'update_menu_item','description'=>'Update an existing navigation menu item.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\MenuTools::updateMenuItem','inputSchema'=>['type'=>'object','required'=>['menu','item_id'],'properties'=>['menu'=>['type'=>['string','integer']],'item_id'=>['type'=>'integer'],'title'=>['type'=>'string'],'url'=>['type'=>'string'],'parent'=>['type'=>'integer'],'position'=>['type'=>'integer']]]]);
$this->register(['name'=>'delete_menu_item','description'=>'Delete a navigation menu item.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\MenuTools::deleteMenuItem','inputSchema'=>['type'=>'object','required'=>['item_id'],'properties'=>['item_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'reorder_menu_items','description'=>'Reorder menu items by passing an array of menu_item_ids in the desired order.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\MenuTools::reorderMenuItems','inputSchema'=>['type'=>'object','required'=>['menu_item_ids'],'properties'=>['menu_item_ids'=>['type'=>'array','items'=>['type'=>'integer']]]]]);
}
private function registerCommentTools(): void {
$this->register(['name'=>'list_comments','description'=>'List WordPress comments.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\CommentTools::listComments','inputSchema'=>['type'=>'object','properties'=>['post_id'=>['type'=>'integer'],'status'=>['type'=>'string','default'=>'approve','enum'=>['approve','hold','spam','trash','all']],'per_page'=>['type'=>'integer','default'=>20],'page'=>['type'=>'integer','default'=>1]]]]);
$this->register(['name'=>'get_comments','description'=>'Get comments for a post.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\CommentTools::listComments','inputSchema'=>['type'=>'object','properties'=>['post_id'=>['type'=>'integer'],'status'=>['type'=>'string','default'=>'all'],'per_page'=>['type'=>'integer','default'=>20]]]]);
$this->register(['name'=>'get_pending_comments','description'=>'Get comments awaiting moderation.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\CommentTools::getPendingComments','inputSchema'=>['type'=>'object','properties'=>['per_page'=>['type'=>'integer','default'=>20]]]]);
$this->register(['name'=>'approve_comment','description'=>'Approve a pending comment.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\CommentTools::approveComment','inputSchema'=>['type'=>'object','required'=>['comment_id'],'properties'=>['comment_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'spam_comment','description'=>'Mark a comment as spam.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\CommentTools::spamComment','inputSchema'=>['type'=>'object','required'=>['comment_id'],'properties'=>['comment_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'trash_comment','description'=>'Move a comment to trash.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\CommentTools::trashComment','inputSchema'=>['type'=>'object','required'=>['comment_id'],'properties'=>['comment_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'delete_comment','description'=>'Delete or trash a comment.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\CommentTools::deleteComment','inputSchema'=>['type'=>'object','required'=>['comment_id'],'properties'=>['comment_id'=>['type'=>'integer'],'force'=>['type'=>'boolean','default'=>false]]]]);
$this->register(['name'=>'create_comment','description'=>'Create a comment.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\CommentTools::createComment','inputSchema'=>['type'=>'object','required'=>['content'],'properties'=>['post_id'=>['type'=>'integer'],'content'=>['type'=>'string'],'author_name'=>['type'=>'string'],'author_email'=>['type'=>'string'],'parent'=>['type'=>'integer'],'status'=>['type'=>'string','default'=>'approve']]]]);
}
private function registerSeoTools(): void {
$this->register(['name'=>'get_seo_meta','description'=>'Get SEO meta for a post/page (Yoast or RankMath).','scope'=>'read','handler'=>'AskTamMCP\\Tools\\SeoTools::getSeoMeta','inputSchema'=>['type'=>'object','required'=>['post_id'],'properties'=>['post_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'update_seo_meta','description'=>'Update SEO meta for a post/page.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\SeoTools::updateSeoMeta','inputSchema'=>['type'=>'object','required'=>['post_id'],'properties'=>['post_id'=>['type'=>'integer'],'title'=>['type'=>'string'],'description'=>['type'=>'string'],'focus_keyword'=>['type'=>'string'],'robots'=>['type'=>'string']]]]);
$this->register(['name'=>'get_post_seo_meta','description'=>'Get the SEO meta fields for a post.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\SeoTools::getSeoMeta','inputSchema'=>['type'=>'object','required'=>['post_id'],'properties'=>['post_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'update_post_seo_meta','description'=>'Update SEO meta fields on a post.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\SeoTools::updateSeoMeta','inputSchema'=>['type'=>'object','required'=>['post_id'],'properties'=>['post_id'=>['type'=>'integer'],'title'=>['type'=>'string'],'description'=>['type'=>'string'],'focus_keyword'=>['type'=>'string'],'robots'=>['type'=>'string']]]]);
}
private function registerSiteTools(): void {
$this->register(['name'=>'get_site_info','description'=>'Get WordPress site information.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\SiteTools::getSiteInfo','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'get_health','description'=>'Run WordPress site health checks.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\SiteTools::getHealth','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'run_cron','description'=>'Trigger WordPress cron manually.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\SiteTools::runCron','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'search_content','description'=>'Search across posts, pages, and custom post types.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\SiteTools::searchContent','inputSchema'=>['type'=>'object','required'=>['query'],'properties'=>['query'=>['type'=>'string'],'post_types'=>['type'=>'array','items'=>['type'=>'string'],'default'=>['post','page']],'per_page'=>['type'=>'integer','default'=>20]]]]);
$this->register(['name'=>'get_permalink_structure','description'=>'Get the WordPress permalink structure.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\SiteTools::getPermalinkStructure','inputSchema'=>['type'=>'object','properties'=>[]]]);
}
private function registerWooCommerceTools(): void {
// Products
$this->register(['name'=>'wc_list_products','description'=>'List WooCommerce products.','handler'=>'AskTamMCP\\Tools\\WooTools::listProducts','scope'=>'read','inputSchema'=>['type'=>'object','properties'=>['status'=>['type'=>'string','default'=>'publish'],'per_page'=>['type'=>'integer','default'=>20],'page'=>['type'=>'integer','default'=>1],'search'=>['type'=>'string']]]]);
$this->register(['name'=>'wc_get_product','description'=>'Get a WooCommerce product.','handler'=>'AskTamMCP\\Tools\\WooTools::getProduct','scope'=>'read','inputSchema'=>['type'=>'object','required'=>['product_id'],'properties'=>['product_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'wc_create_product','description'=>'Create a WooCommerce product.','handler'=>'AskTamMCP\\Tools\\WooTools::createProduct','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['name','regular_price'],'properties'=>['name'=>['type'=>'string'],'regular_price'=>['type'=>'string'],'description'=>['type'=>'string'],'status'=>['type'=>'string','default'=>'draft'],'stock_quantity'=>['type'=>'integer'],'sku'=>['type'=>'string']]]]);
$this->register(['name'=>'wc_update_product','description'=>'Update a WooCommerce product.','handler'=>'AskTamMCP\\Tools\\WooTools::updateProduct','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['product_id'],'properties'=>['product_id'=>['type'=>'integer'],'name'=>['type'=>'string'],'regular_price'=>['type'=>'string'],'sale_price'=>['type'=>'string'],'status'=>['type'=>'string'],'stock_quantity'=>['type'=>'integer'],'description'=>['type'=>'string']]]]);
// Orders
$this->register(['name'=>'wc_list_orders','description'=>'List WooCommerce orders.','handler'=>'AskTamMCP\\Tools\\WooTools::listOrders','scope'=>'read','inputSchema'=>['type'=>'object','properties'=>['status'=>['type'=>'string','default'=>'any'],'per_page'=>['type'=>'integer','default'=>20],'page'=>['type'=>'integer','default'=>1],'customer_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'wc_get_order','description'=>'Get a WooCommerce order.','handler'=>'AskTamMCP\\Tools\\WooTools::getOrder','scope'=>'read','inputSchema'=>['type'=>'object','required'=>['order_id'],'properties'=>['order_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'wc_update_order_status','description'=>'Update WooCommerce order status.','handler'=>'AskTamMCP\\Tools\\WooTools::updateOrderStatus','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['order_id','status'],'properties'=>['order_id'=>['type'=>'integer'],'status'=>['type'=>'string','enum'=>['pending','processing','on-hold','completed','cancelled','refunded','failed']]]]]);
// Customers
$this->register(['name'=>'wc_list_customers','description'=>'List WooCommerce customers.','handler'=>'AskTamMCP\\Tools\\WooTools::listCustomers','scope'=>'read','inputSchema'=>['type'=>'object','properties'=>['per_page'=>['type'=>'integer','default'=>20],'page'=>['type'=>'integer','default'=>1],'search'=>['type'=>'string']]]]);
$this->register(['name'=>'wc_get_customers','description'=>'Get WooCommerce customers (alias for wc_list_customers).','handler'=>'AskTamMCP\\Tools\\WooTools::getCustomers','scope'=>'read','inputSchema'=>['type'=>'object','properties'=>['per_page'=>['type'=>'integer','default'=>20],'page'=>['type'=>'integer','default'=>1],'search'=>['type'=>'string']]]]);
// Store stats
$this->register(['name'=>'wc_get_store_stats','description'=>'Get WooCommerce store stats.','handler'=>'AskTamMCP\\Tools\\WooTools::getStoreStats','scope'=>'read','inputSchema'=>['type'=>'object','properties'=>['period'=>['type'=>'string','enum'=>['day','week','month','year'],'default'=>'month']]]]);
// Coupons
$this->register(['name'=>'wc_get_coupons','description'=>'List WooCommerce coupons with optional code search, status filter, and pagination.','handler'=>'AskTamMCP\\Tools\\WooTools::getCoupons','scope'=>'read','inputSchema'=>['type'=>'object','properties'=>['per_page'=>['type'=>'integer','default'=>20],'page'=>['type'=>'integer','default'=>1],'code'=>['type'=>'string'],'status'=>['type'=>'string','default'=>'publish']]]]);
$this->register(['name'=>'wc_get_coupon','description'=>'Get a single WooCommerce coupon by ID or code.','handler'=>'AskTamMCP\\Tools\\WooTools::getCoupon','scope'=>'read','inputSchema'=>['type'=>'object','properties'=>['coupon_id'=>['type'=>'integer'],'code'=>['type'=>'string']]]]);
$this->register(['name'=>'wc_create_coupon','description'=>'Create a new WooCommerce coupon.','handler'=>'AskTamMCP\\Tools\\WooTools::createCoupon','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['code'],'properties'=>['code'=>['type'=>'string'],'discount_type'=>['type'=>'string','enum'=>['percent','fixed_cart','fixed_product'],'default'=>'percent'],'amount'=>['type'=>'number'],'expiry_date'=>['type'=>'string'],'usage_limit'=>['type'=>'integer'],'usage_limit_per_user'=>['type'=>'integer'],'minimum_amount'=>['type'=>'string'],'maximum_amount'=>['type'=>'string'],'free_shipping'=>['type'=>'boolean'],'description'=>['type'=>'string']]]]);
$this->register(['name'=>'wc_update_coupon','description'=>'Update an existing WooCommerce coupon; only supplied fields are changed.','handler'=>'AskTamMCP\\Tools\\WooTools::updateCoupon','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['coupon_id'],'properties'=>['coupon_id'=>['type'=>'integer'],'code'=>['type'=>'string'],'discount_type'=>['type'=>'string'],'amount'=>['type'=>'number'],'expiry_date'=>['type'=>'string'],'usage_limit'=>['type'=>'integer'],'minimum_amount'=>['type'=>'string'],'maximum_amount'=>['type'=>'string'],'free_shipping'=>['type'=>'boolean']]]]);
$this->register(['name'=>'wc_delete_coupon','description'=>'Delete a WooCommerce coupon; moves to trash by default, set force=true to permanently delete.','handler'=>'AskTamMCP\\Tools\\WooTools::deleteCoupon','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['coupon_id'],'properties'=>['coupon_id'=>['type'=>'integer'],'force'=>['type'=>'boolean','default'=>false]]]]);
$this->register(['name'=>'wc_get_coupon_count','description'=>'Return published, draft, and trashed WooCommerce coupon counts.','handler'=>'AskTamMCP\\Tools\\WooTools::getCouponCount','scope'=>'read','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'wc_empty_coupon_trash','description'=>'Permanently delete all trashed WooCommerce coupons.','handler'=>'AskTamMCP\\Tools\\WooTools::emptyCouponTrash','scope'=>'write','inputSchema'=>['type'=>'object','properties'=>[]]]);
// Product attributes
$this->register(['name'=>'wc_get_product_attributes','description'=>'List all registered global WooCommerce product attributes with their pa_* taxonomy slugs.','handler'=>'AskTamMCP\\Tools\\WooTools::getProductAttributes','scope'=>'read','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'wc_create_product_attribute','description'=>'Register a new global WooCommerce product attribute taxonomy.','handler'=>'AskTamMCP\\Tools\\WooTools::createProductAttribute','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['name'],'properties'=>['name'=>['type'=>'string'],'slug'=>['type'=>'string'],'type'=>['type'=>'string','default'=>'select'],'order_by'=>['type'=>'string','default'=>'menu_order'],'is_visible'=>['type'=>'boolean','default'=>true]]]]);
$this->register(['name'=>'wc_get_attribute_terms','description'=>'Get sample values and statistics for a WooCommerce product attribute.','handler'=>'AskTamMCP\\Tools\\WooTools::getAttributeTerms','scope'=>'read','inputSchema'=>['type'=>'object','properties'=>['attribute_id'=>['type'=>'integer'],'attribute_slug'=>['type'=>'string']]]]);
$this->register(['name'=>'wc_set_product_attributes','description'=>'Set which attributes a variable product uses — required before creating variations.','handler'=>'AskTamMCP\\Tools\\WooTools::setProductAttributes','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['product_id','attributes'],'properties'=>['product_id'=>['type'=>'integer'],'attributes'=>['type'=>'array','items'=>['type'=>'object']]]]]);
// Product variations
$this->register(['name'=>'wc_get_product_variations','description'=>'Get all variations for a variable WooCommerce product.','handler'=>'AskTamMCP\\Tools\\WooTools::getProductVariations','scope'=>'read','inputSchema'=>['type'=>'object','required'=>['product_id'],'properties'=>['product_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'wc_get_variation','description'=>'Get a single product variation by ID.','handler'=>'AskTamMCP\\Tools\\WooTools::getVariation','scope'=>'read','inputSchema'=>['type'=>'object','required'=>['variation_id'],'properties'=>['variation_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'wc_create_variation','description'=>'Create a new variation for a variable product.','handler'=>'AskTamMCP\\Tools\\WooTools::createVariation','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['product_id'],'properties'=>['product_id'=>['type'=>'integer'],'regular_price'=>['type'=>'string'],'sale_price'=>['type'=>'string'],'sku'=>['type'=>'string'],'status'=>['type'=>'string','default'=>'publish'],'stock_quantity'=>['type'=>'integer'],'attributes'=>['type'=>'object']]]]);
$this->register(['name'=>'wc_update_variation','description'=>'Update an existing product variation.','handler'=>'AskTamMCP\\Tools\\WooTools::updateVariation','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['variation_id'],'properties'=>['variation_id'=>['type'=>'integer'],'regular_price'=>['type'=>'string'],'sale_price'=>['type'=>'string'],'sku'=>['type'=>'string'],'status'=>['type'=>'string'],'stock_quantity'=>['type'=>'integer']]]]);
$this->register(['name'=>'wc_delete_variation','description'=>'Delete a product variation.','handler'=>'AskTamMCP\\Tools\\WooTools::deleteVariation','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['variation_id'],'properties'=>['variation_id'=>['type'=>'integer']]]]);
$this->register(['name'=>'wc_batch_update_variations','description'=>'Batch create, update, and/or delete product variations in one call.','handler'=>'AskTamMCP\\Tools\\WooTools::batchUpdateVariations','scope'=>'write','inputSchema'=>['type'=>'object','required'=>['product_id'],'properties'=>['product_id'=>['type'=>'integer'],'create'=>['type'=>'array','items'=>['type'=>'object']],'update'=>['type'=>'array','items'=>['type'=>'object']],'delete'=>['type'=>'array','items'=>['type'=>'integer']]]]]);
}
private function registerFileManagerTools(): void {
$this->register(['name'=>'fs_list_dir','description'=>'List files and directories in the uploads folder.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\FileManagerTools::listDir','inputSchema'=>['type'=>'object','properties'=>['path'=>['type'=>'string']]]]);
$this->register(['name'=>'fs_read_file','description'=>'Read a file from the uploads directory.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\FileManagerTools::readFile','inputSchema'=>['type'=>'object','required'=>['path'],'properties'=>['path'=>['type'=>'string']]]]);
$this->register(['name'=>'fs_delete_file','description'=>'Delete a file from the uploads directory.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\FileManagerTools::deleteFile','inputSchema'=>['type'=>'object','required'=>['path'],'properties'=>['path'=>['type'=>'string']]]]);
$this->register(['name'=>'fs_delete_dir','description'=>'Delete a directory and all its contents from uploads. Cannot delete uploads root.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\FileManagerTools::deleteDirectory','inputSchema'=>['type'=>'object','required'=>['path'],'properties'=>['path'=>['type'=>'string']]]]);
$this->register(['name'=>'fs_uploads_info','description'=>'Get uploads directory path, URL, and total disk usage.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\FileManagerTools::getUploadsInfo','inputSchema'=>['type'=>'object','properties'=>[]]]);
// Aliases for legacy tool names
$this->register(['name'=>'list_files','description'=>'List files in the uploads folder (alias for fs_list_dir).','scope'=>'read','handler'=>'AskTamMCP\\Tools\\FileManagerTools::listDir','inputSchema'=>['type'=>'object','properties'=>['path'=>['type'=>'string']]]]);
$this->register(['name'=>'read_file','description'=>'Read a file from the uploads directory (alias for fs_read_file).','scope'=>'read','handler'=>'AskTamMCP\\Tools\\FileManagerTools::readFile','inputSchema'=>['type'=>'object','required'=>['path'],'properties'=>['path'=>['type'=>'string']]]]);
$this->register(['name'=>'delete_file','description'=>'Delete a file from the uploads directory (alias for fs_delete_file).','scope'=>'write','handler'=>'AskTamMCP\\Tools\\FileManagerTools::deleteFile','inputSchema'=>['type'=>'object','required'=>['path'],'properties'=>['path'=>['type'=>'string']]]]);
// write_file — writes a text file to the uploads directory
$this->register(['name'=>'write_file','description'=>'Write a text file to the uploads directory. Path is relative to uploads root.','scope'=>'write','handler'=>function(array $a) {
$path = ltrim($a['path'] ?? '', '/');
if (empty($path)) return ['error'=>'path is required'];
$uploads = wp_upload_dir();
$full = realpath($uploads['basedir']) . '/' . $path;
if (strpos(dirname($full), realpath($uploads['basedir'])) !== 0 && dirname($full) !== realpath($uploads['basedir'])) {
return ['error'=>'Path traversal denied'];
}
wp_mkdir_p(dirname($full));
$bytes = file_put_contents($full, $a['content'] ?? '');
if ($bytes === false) return ['error'=>'Write failed'];
return ['path'=>$path,'bytes'=>$bytes,'url'=>$uploads['baseurl'].'/'.$path];
},'inputSchema'=>['type'=>'object','required'=>['path','content'],'properties'=>['path'=>['type'=>'string'],'content'=>['type'=>'string']]]]);
}
private function registerEmailTools(): void {
$this->register(['name'=>'email_send_test','description'=>'Send a test email to verify WordPress mail is working.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\EmailTools::sendTestEmail','inputSchema'=>['type'=>'object','properties'=>['to'=>['type'=>'string'],'subject'=>['type'=>'string'],'message'=>['type'=>'string']]]]);
$this->register(['name'=>'email_get_config','description'=>'Get the current WordPress email configuration: admin email, SMTP settings, active mail plugins.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\EmailTools::getEmailConfig','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'email_list_log','description'=>'List recent emails from WP Mail SMTP log (if plugin is active).','scope'=>'read','handler'=>'AskTamMCP\\Tools\\EmailTools::listEmailLog','inputSchema'=>['type'=>'object','properties'=>['per_page'=>['type'=>'integer','default'=>20]]]]);
$this->register(['name'=>'send_email','description'=>'Send an email via wp_mail. Requires to, subject, and message.','scope'=>'write','handler'=>'AskTamMCP\\Tools\\EmailTools::sendTestEmail','inputSchema'=>['type'=>'object','required'=>['to','subject','message'],'properties'=>['to'=>['type'=>'string'],'subject'=>['type'=>'string'],'message'=>['type'=>'string']]]]);
}
private function registerTransientTools(): void {
$this->register(['name'=>'transient_get','description'=>'Get a WordPress transient value by key.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\TransientTools::getTransient','inputSchema'=>['type'=>'object','required'=>['key'],'properties'=>['key'=>['type'=>'string']]]]);
$this->register(['name'=>'transient_set','description'=>'Set a WordPress transient with optional expiration.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\TransientTools::setTransient','inputSchema'=>['type'=>'object','required'=>['key','value'],'properties'=>['key'=>['type'=>'string'],'value'=>[],'expiration'=>['type'=>'integer']]]]);
$this->register(['name'=>'transient_delete','description'=>'Delete a WordPress transient by key.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\TransientTools::deleteTransient','inputSchema'=>['type'=>'object','required'=>['key'],'properties'=>['key'=>['type'=>'string']]]]);
$this->register(['name'=>'transient_list','description'=>'List WordPress transients, optionally filtered by key prefix/search.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\TransientTools::listTransients','inputSchema'=>['type'=>'object','properties'=>['search'=>['type'=>'string']]]]);
$this->register(['name'=>'transient_flush_expired','description'=>'Delete all expired transients from the database.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\TransientTools::flushExpiredTransients','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'set_transient','description'=>'Set a WordPress transient (alias for transient_set).','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\TransientTools::setTransient','inputSchema'=>['type'=>'object','required'=>['key','value'],'properties'=>['key'=>['type'=>'string'],'value'=>[],'expiration'=>['type'=>'integer']]]]);
$this->register(['name'=>'get_transient','description'=>'Get a WordPress transient (alias for transient_get).','scope'=>'read','handler'=>'AskTamMCP\\Tools\\TransientTools::getTransient','inputSchema'=>['type'=>'object','required'=>['key'],'properties'=>['key'=>['type'=>'string']]]]);
$this->register(['name'=>'delete_transient','description'=>'Delete a WordPress transient (alias for transient_delete).','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\TransientTools::deleteTransient','inputSchema'=>['type'=>'object','required'=>['key'],'properties'=>['key'=>['type'=>'string']]]]);
}
private function registerWidgetTools(): void {
$this->register(['name'=>'widget_list_areas','description'=>'List all registered WordPress widget areas (sidebars).','scope'=>'read','handler'=>'AskTamMCP\\Tools\\WidgetTools::listWidgetAreas','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'list_widget_areas','description'=>'List all widget areas (alias for widget_list_areas).','scope'=>'read','handler'=>'AskTamMCP\\Tools\\WidgetTools::listWidgetAreas','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'widget_get_area','description'=>'Get all widgets in a specific widget area with their settings.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\WidgetTools::getWidgetArea','inputSchema'=>['type'=>'object','required'=>['sidebar_id'],'properties'=>['sidebar_id'=>['type'=>'string']]]]);
$this->register(['name'=>'widget_list_registered','description'=>'List all registered WordPress widget types.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\WidgetTools::listRegisteredWidgets','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'widget_update_area','description'=>'Reorder or set the widget list for a widget area.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\WidgetTools::updateWidgetArea','inputSchema'=>['type'=>'object','required'=>['sidebar_id','widget_ids'],'properties'=>['sidebar_id'=>['type'=>'string'],'widget_ids'=>['type'=>'array','items'=>['type'=>'string']]]]]);
$this->register(['name'=>'widget_remove','description'=>'Remove a specific widget from a widget area.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\WidgetTools::removeWidgetFromArea','inputSchema'=>['type'=>'object','required'=>['sidebar_id','widget_id'],'properties'=>['sidebar_id'=>['type'=>'string'],'widget_id'=>['type'=>'string']]]]);
}
private function registerCliTools(): void {
$this->register(['name'=>'cli_run','description'=>'Run a WP-CLI command (admin scope).','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\CliTools::run','inputSchema'=>['type'=>'object','required'=>['command'],'properties'=>['command'=>['type'=>'string']]]]);
$this->register(['name'=>'cli_available','description'=>'Check if WP-CLI is available on the server and list allowed commands.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\CliTools::isAvailable','inputSchema'=>['type'=>'object','properties'=>[]]]);
}
private function registerRawSqlTools(): void {
$this->register(['name'=>'sql_query','description'=>'Run a SELECT query against the WordPress database (admin scope, must be enabled in settings). Accepts "sql" or "query" parameter.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\RawSqlTools::query','inputSchema'=>['type'=>'object','properties'=>['sql'=>['type'=>'string'],'query'=>['type'=>'string'],'limit'=>['type'=>'integer','default'=>100,'maximum'=>500]]]]);
$this->register(['name'=>'sql_list_tables','description'=>'List WordPress database tables with row count and size.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\RawSqlTools::listTables','inputSchema'=>['type'=>'object','properties'=>['prefix'=>['type'=>'string']]]]);
$this->register(['name'=>'sql_describe_table','description'=>'Describe the columns of a WordPress database table. Accepts wp_ prefix even on sites with different prefixes.','scope'=>'admin','handler'=>'AskTamMCP\\Tools\\RawSqlTools::describeTable','inputSchema'=>['type'=>'object','required'=>['table'],'properties'=>['table'=>['type'=>'string']]]]);
}
private function registerThemeDiscoveryTools(): void {
$this->register(['name'=>'theme_elementor_support','description'=>'Check what Elementor features the active theme supports: full-width, canvas, templates.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeDiscoveryTools::getThemeElementorSupport','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'theme_widget_areas','description'=>'List all widget areas registered by the active theme.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeDiscoveryTools::getThemeWidgetAreas','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'theme_custom_post_types','description'=>'List all custom post types registered by the theme and active plugins.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeDiscoveryTools::getThemeCustomPostTypes','inputSchema'=>['type'=>'object','properties'=>['include_builtin'=>['type'=>'boolean','default'=>false]]]]);
$this->register(['name'=>'theme_taxonomies','description'=>'List all public taxonomies registered by the theme and active plugins.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeDiscoveryTools::getThemeTaxonomies','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'theme_elementor_tokens','description'=>'Get Elementor kit design tokens: global colors (with CSS vars), typography presets.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeDiscoveryTools::getElementorKitTokens','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'theme_woodmart_elements','description'=>'Discover WoodMart theme custom Elementor widgets, shortcodes, and widget areas.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeDiscoveryTools::getWoodmartElements','inputSchema'=>['type'=>'object','properties'=>[]]]);
$this->register(['name'=>'theme_page_templates','description'=>'List all page templates available in the active theme, including Elementor canvas and full-width.','scope'=>'read','handler'=>'AskTamMCP\\Tools\\ThemeDiscoveryTools::getAllPageTemplates','inputSchema'=>['type'=>'object','properties'=>[]]]);
}
}