feat: full tool registry - 40+ tools across all categories

This commit is contained in:
2026-05-08 03:14:27 +00:00
parent 34c4d06024
commit bf4eda4d5f
+784
View File
@@ -0,0 +1,784 @@
<?php
namespace AskTamMCP\MCP;
defined('ABSPATH') || exit;
/**
* Tool Registry — registers all tools and maps names to handlers.
*
* Each tool entry:
* name string — MCP tool name (snake_case)
* description string — shown to AI clients
* scope string — required key scope: read|write|admin|woocommerce
* inputSchema array — JSON Schema for arguments
* handler string — "ClassName::method" or Closure
*/
class Registry {
/** @var array<string, array> */
private array $tools = [];
public function __construct() {
$this->registerAll();
}
// -------------------------------------------------------------------------
// Public API
// -------------------------------------------------------------------------
/** Returns MCP-formatted tool definitions for tools/list response */
public function getToolDefinitions(): array {
return array_values(array_map(fn($t) => [
'name' => $t['name'],
'description' => $t['description'],
'inputSchema' => $t['inputSchema'],
], $this->tools));
}
/** Returns callable handler for a tool, or null if not found */
public function getHandler(string $name): ?callable {
if (!isset($this->tools[$name])) {
return null;
}
$h = $this->tools[$name]['handler'];
if (is_callable($h)) {
return $h;
}
[$class, $method] = explode('::', $h);
return [new $class(), $method];
}
/** Returns full tool definition array */
public function getTool(string $name): ?array {
return $this->tools[$name] ?? null;
}
// -------------------------------------------------------------------------
// Tool Registration
// -------------------------------------------------------------------------
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();
}
// Allow third-party extensions
do_action('asktam_mcp_register_tools', $this);
}
public function register(array $tool): void {
$this->tools[$tool['name']] = $tool;
}
// -------------------------------------------------------------------------
// Posts
// -------------------------------------------------------------------------
private function registerPostTools(): void {
$this->register([
'name' => 'list_posts',
'description' => 'List WordPress posts. Supports filtering by status, author, category, tag, date range, and search. Returns id, title, status, date, link.',
'scope' => 'read',
'handler' => 'AskTamMCP\Tools\PostTools::listPosts',
'inputSchema' => [
'type' => 'object',
'properties' => [
'status' => ['type' => 'string', 'default' => 'publish', 'description' => 'Post status: publish|draft|pending|private|any'],
'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', 'description' => 'ISO 8601 date'],
'before' => ['type' => 'string', 'description' => 'ISO 8601 date'],
],
],
]);
$this->register([
'name' => 'get_post',
'description' => 'Get full details of a WordPress post including content, meta, taxonomies, and featured image.',
'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. Returns the new post ID and URL.',
'scope' => 'write',
'handler' => 'AskTamMCP\Tools\PostTools::createPost',
'inputSchema' => [
'type' => 'object',
'required' => ['title'],
'properties' => [
'title' => ['type' => 'string'],
'content' => ['type' => 'string', 'description' => 'HTML or Gutenberg block content'],
'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. Only supplied fields are changed.',
'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, 'description' => 'true = permanent delete, false = trash'],
],
],
]);
}
// -------------------------------------------------------------------------
// Pages
// -------------------------------------------------------------------------
private function registerPageTools(): void {
$this->register([
'name' => 'list_pages',
'description' => 'List WordPress pages with optional status filter.',
'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 including content and meta.',
'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]]],
]);
}
// -------------------------------------------------------------------------
// Media
// -------------------------------------------------------------------------
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', 'description' => 'e.g. image/jpeg, application/pdf'],
'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. Returns new media ID and URL.',
'scope' => 'write',
'handler' => 'AskTamMCP\Tools\MediaTools::uploadMedia',
'inputSchema' => [
'type' => 'object',
'required' => ['source_url'],
'properties' => [
'source_url' => ['type' => 'string', 'description' => 'Public URL to download and upload'],
'title' => ['type' => 'string'],
'alt_text' => ['type' => 'string'],
'caption' => ['type' => 'string'],
'post_id' => ['type' => 'integer', 'description' => 'Attach to this post ID'],
],
],
]);
$this->register([
'name' => 'update_media',
'description' => 'Update media metadata: alt text, title, caption, description.',
'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]]],
]);
}
// -------------------------------------------------------------------------
// Users
// -------------------------------------------------------------------------
private function registerUserTools(): void {
$this->register([
'name' => 'list_users',
'description' => 'List WordPress users with optional role filter.',
'scope' => 'read',
'handler' => 'AskTamMCP\Tools\UserTools::listUsers',
'inputSchema' => [
'type' => 'object',
'properties' => [
'role' => ['type' => 'string', 'description' => 'e.g. administrator, editor, author, subscriber'],
'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. Reassign their posts to another user.',
'scope' => 'admin',
'handler' => 'AskTamMCP\Tools\UserTools::deleteUser',
'inputSchema' => [
'type' => 'object',
'required' => ['user_id'],
'properties' => [
'user_id' => ['type' => 'integer'],
'reassign' => ['type' => 'integer', 'description' => 'User ID to reassign posts to'],
],
],
]);
}
// -------------------------------------------------------------------------
// Taxonomy
// -------------------------------------------------------------------------
private function registerTaxonomyTools(): void {
$this->register([
'name' => 'list_terms',
'description' => 'List terms in any taxonomy (category, post_tag, or custom).',
'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'],
],
],
]);
}
// -------------------------------------------------------------------------
// Options
// -------------------------------------------------------------------------
private function registerOptionTools(): void {
$this->register([
'name' => 'get_option',
'description' => 'Get a WordPress option value by key.',
'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 pattern prefix.',
'scope' => 'read',
'handler' => 'AskTamMCP\Tools\OptionTools::listOptions',
'inputSchema' => ['type' => 'object', 'properties' => ['prefix' => ['type' => 'string', 'description' => 'Option name prefix to filter by']]],
]);
}
// -------------------------------------------------------------------------
// Plugins
// -------------------------------------------------------------------------
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' => 'activate_plugin',
'description' => 'Activate a WordPress plugin by its slug/file path.',
'scope' => 'admin',
'handler' => 'AskTamMCP\Tools\PluginTools::activatePlugin',
'inputSchema' => ['type' => 'object', 'required' => ['plugin'], 'properties' => ['plugin' => ['type' => 'string', 'description' => 'Plugin file path, e.g. woocommerce/woocommerce.php']]],
]);
$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']]],
]);
}
// -------------------------------------------------------------------------
// Themes
// -------------------------------------------------------------------------
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_active_theme',
'description' => 'Get the currently active WordPress theme details.',
'scope' => 'read',
'handler' => 'AskTamMCP\Tools\ThemeTools::getActiveTheme',
'inputSchema' => ['type' => 'object', 'properties' => []],
]);
$this->register([
'name' => 'switch_theme',
'description' => 'Switch the active WordPress theme by stylesheet slug.',
'scope' => 'admin',
'handler' => 'AskTamMCP\Tools\ThemeTools::switchTheme',
'inputSchema' => ['type' => 'object', 'required' => ['stylesheet'], 'properties' => ['stylesheet' => ['type' => 'string']]],
]);
}
// -------------------------------------------------------------------------
// Menus
// -------------------------------------------------------------------------
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_menu',
'description' => 'Get all items in a navigation menu by menu ID or slug.',
'scope' => 'read',
'handler' => 'AskTamMCP\Tools\MenuTools::getMenu',
'inputSchema' => ['type' => 'object', 'required' => ['menu'], 'properties' => ['menu' => ['type' => ['string', 'integer'], 'description' => 'Menu ID or slug']]],
]);
$this->register([
'name' => 'update_menu_item',
'description' => 'Update or create a navigation menu item.',
'scope' => 'write',
'handler' => 'AskTamMCP\Tools\MenuTools::updateMenuItem',
'inputSchema' => [
'type' => 'object',
'required' => ['menu', 'title', 'url'],
'properties' => [
'menu' => ['type' => ['string', 'integer']],
'item_id' => ['type' => 'integer', 'description' => 'Omit to create new item'],
'title' => ['type' => 'string'],
'url' => ['type' => 'string'],
'parent' => ['type' => 'integer'],
'position' => ['type' => 'integer'],
],
],
]);
}
// -------------------------------------------------------------------------
// Comments
// -------------------------------------------------------------------------
private function registerCommentTools(): void {
$this->register([
'name' => 'list_comments',
'description' => 'List WordPress comments with optional post and status filters.',
'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' => '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' => '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]]],
]);
}
// -------------------------------------------------------------------------
// SEO
// -------------------------------------------------------------------------
private function registerSeoTools(): void {
$this->register([
'name' => 'get_seo_meta',
'description' => 'Get SEO meta for a post/page (Yoast or RankMath). Returns title, description, focus keyword, robots settings.',
'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 (Yoast or RankMath).',
'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', 'description' => 'e.g. index,follow or noindex,nofollow'],
],
],
]);
}
// -------------------------------------------------------------------------
// Site
// -------------------------------------------------------------------------
private function registerSiteTools(): void {
$this->register([
'name' => 'get_site_info',
'description' => 'Get WordPress site information: name, URL, WP version, PHP version, active theme, active plugins count, language.',
'scope' => 'read',
'handler' => 'AskTamMCP\Tools\SiteTools::getSiteInfo',
'inputSchema' => ['type' => 'object', 'properties' => []],
]);
$this->register([
'name' => 'get_health',
'description' => 'Run WordPress site health checks and return results.',
'scope' => 'read',
'handler' => 'AskTamMCP\Tools\SiteTools::getHealth',
'inputSchema' => ['type' => 'object', 'properties' => []],
]);
$this->register([
'name' => 'run_cron',
'description' => 'Trigger WordPress cron manually and return executed hooks.',
'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],
],
],
]);
}
// -------------------------------------------------------------------------
// WooCommerce
// -------------------------------------------------------------------------
private function registerWooCommerceTools(): void {
$tools = [
['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']]]],
['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']]]],
['name' => 'wc_create_product', 'description' => 'Create a WooCommerce product.', 'handler' => 'AskTamMCP\Tools\WooTools::createProduct', 'scope' => 'woocommerce',
'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']]]],
['name' => 'wc_update_product', 'description' => 'Update a WooCommerce product.', 'handler' => 'AskTamMCP\Tools\WooTools::updateProduct', 'scope' => 'woocommerce',
'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']]]],
['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']]]],
['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']]]],
['name' => 'wc_update_order_status', 'description' => 'Update a WooCommerce order status.', 'handler' => 'AskTamMCP\Tools\WooTools::updateOrderStatus', 'scope' => 'woocommerce',
'inputSchema' => ['type' => 'object', 'required' => ['order_id', 'status'], 'properties' => ['order_id' => ['type' => 'integer'], 'status' => ['type' => 'string', 'enum' => ['pending', 'processing', 'on-hold', 'completed', 'cancelled', 'refunded', 'failed']]]]],
['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']]]],
['name' => 'wc_get_store_stats', 'description' => 'Get WooCommerce store stats: revenue, orders, products count.', 'handler' => 'AskTamMCP\Tools\WooTools::getStoreStats', 'scope' => 'read',
'inputSchema' => ['type' => 'object', 'properties' => ['period' => ['type' => 'string', 'enum' => ['day', 'week', 'month', 'year'], 'default' => 'month']]]],
];
foreach ($tools as $tool) {
$this->register($tool);
}
}
}