feat: core plugin bootstrap
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AskTamMCP\Core;
|
||||||
|
|
||||||
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main plugin bootstrap. Singleton.
|
||||||
|
*/
|
||||||
|
final class Plugin {
|
||||||
|
|
||||||
|
private static ?self $instance = null;
|
||||||
|
|
||||||
|
public static function instance(): self {
|
||||||
|
if (null === self::$instance) {
|
||||||
|
self::$instance = new self();
|
||||||
|
}
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function __construct() {}
|
||||||
|
|
||||||
|
public function boot(): void {
|
||||||
|
// Load text domain
|
||||||
|
load_plugin_textdomain('advanced-mcp-plugin', false, dirname(plugin_basename(ASKTAM_MCP_FILE)) . '/languages');
|
||||||
|
|
||||||
|
// Register REST routes (MCP endpoint + admin API)
|
||||||
|
add_action('rest_api_init', [$this, 'registerRoutes']);
|
||||||
|
|
||||||
|
// Admin UI
|
||||||
|
if (is_admin()) {
|
||||||
|
new AdminMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerRoutes(): void {
|
||||||
|
// MCP SSE endpoint — AI clients connect here
|
||||||
|
$mcpServer = new \AskTamMCP\MCP\Server();
|
||||||
|
$mcpServer->registerRoutes();
|
||||||
|
|
||||||
|
// Internal admin REST routes (API key management)
|
||||||
|
$apiKeyController = new \AskTamMCP\Admin\ApiKeyController();
|
||||||
|
$apiKeyController->registerRoutes();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user