Skip to content
Open
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@
],
"type": "wordpress-plugin",
"license": "GPLv2",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/WordPress/mcp-adapter"
}
],
"require": {
"php": ">=7.4",
"yahnis-elsts/plugin-update-checker": "5.1",
"aws/aws-sdk-php": "^3.300",
"woocommerce/action-scheduler": "3.8.1",
"wordpress/abilities-api": "^0.1"
"wordpress/abilities-api": "^0.1",
"wordpress/mcp-adapter": "dev-trunk"
},
"autoload": {
"psr-4": {
Expand Down
99 changes: 97 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions includes/Classifai/Plugin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php
namespace Classifai;

use WP\MCP\Core\McpAdapter;
use WP\MCP\Transport\Http\RestTransport;
use WP\MCP\Infrastructure\ErrorHandling\ErrorLogMcpErrorHandler;
use WP\MCP\Infrastructure\Observability\NullMcpObservabilityHandler;

class Plugin {

/**
Expand Down Expand Up @@ -42,6 +47,10 @@ public function enable() {
add_filter( 'plugin_action_links_' . CLASSIFAI_PLUGIN_BASENAME, [ $this, 'filter_plugin_action_links' ] );
add_filter( 'robots_txt', [ $this, 'maybe_block_ai_crawlers' ] );
add_action( 'after_classifai_init', [ $this, 'load_action_scheduler' ] );

// Initialize the MCP adapter so the hooks are loaded.
McpAdapter::instance();
add_action( 'mcp_adapter_init', [ $this, 'mcp_adapter_init' ] );
}

/**
Expand Down Expand Up @@ -341,6 +350,31 @@ public function load_action_scheduler() {
}
}

/**
* Initialize the MCP adapter.
*
* @param McpAdapter $adapter The MCP adapter.
*/
public function mcp_adapter_init( McpAdapter $adapter ) {
$adapter->create_server(
'classifai',
'classifai',
'mcp',
'ClassifAI MCP Server',
'Custom MCP Server for ClassifAI Features',
'1.0.0',
[
RestTransport::class,
],
ErrorLogMcpErrorHandler::class,
NullMcpObservabilityHandler::class,
[
'classifai/generate-image',
'classifai/generate-title',
],
);
}

/**
* Migrate the existing settings to v3 if necessary.
*
Expand Down