get( RouteAccess::class )->setup(); $container->get( AppPasswordHeaderAuth::class )->setup(); $registry = $container->get( ToolRegistry::class ); $proxy = $container->get( AbilitiesApiProxy::class ); $proxy->setup(); // Resolved before the closure so the server's tool list and the abilities the // proxy registers always come from the same source. $tool_ids = $registry->tool_ids(); $draft_service = $container->get( DraftPageService::class ); add_action( 'before_delete_post', array( $draft_service, 'cleanup_draft_meta' ) ); // Initialise own McpAdapter instance. Internally hooks rest_api_init:15 // to fire mcp_adapter_init for REST requests only. $adapter = McpAdapter::instance(); // Create the 'airo-wp' MCP server when OUR adapter fires mcp_adapter_init. // The identity check prevents responding to another plugin's adapter if both // are active: they share the same action name but are separate Strauss-prefixed // instances, so the firing adapter must be verified as ours. add_action( 'mcp_adapter_init', static function ( $fired_adapter ) use ( $adapter, $tool_ids ) { if ( $fired_adapter !== $adapter ) { return; } $adapter->create_server( 'airo-wp', 'airo-wp/v1', 'mcp/streamable', __( 'Airo WP MCP Server', 'airo-wp' ), __( 'MCP server for Airo WP tools.', 'airo-wp' ), AIRO_WP_VERSION, array( HttpTransport::class ), null, // Error handler: NullMcpErrorHandler used by default. null, // Observability handler: NullMcpObservabilityHandler used by default. $tool_ids, array(), // Resources. array(), // Prompts. 'is_user_logged_in' ); } ); } }