forked from mcp-wp/ai-command
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai-command.php
More file actions
47 lines (37 loc) · 1.1 KB
/
ai-command.php
File metadata and controls
47 lines (37 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace WP_CLI\AiCommand;
use WP_CLI\AiCommand\ToolRepository\CollectionToolRepository;
use WP_CLI\AiCommand\Tools\ImageTools;
use WP_CLI\AiCommand\Tools\MiscTools;
use WP_CLI\AiCommand\Tools\URLTools;
use WP_CLI\AiCommand\Tools\CommunityEvents;
use WP_CLI\AiCommand\Tools\MapRESTtoMCP;
use WP_CLI;
if ( ! class_exists( '\WP_CLI' ) ) {
return;
}
$ai_command_autoloader = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $ai_command_autoloader ) ) {
require_once $ai_command_autoloader;
}
WP_CLI::add_command( 'ai', static function ( $args, $assoc_args ) {
$server = new MCP\Server();
$client = new MCP\Client($server);
$tools = new ToolCollection();
$all_tools = [
...(new ImageTools($client, $server))->get_tools(),
...(new CommunityEvents($client))->get_tools(),
...(new MiscTools($server))->get_tools(),
...(new URLTools($server))->get_tools(),
...(new MapRESTtoMCP())->map_rest_to_mcp(),
];
foreach ($all_tools as $tool) {
$tools->add($tool);
}
$ai_command = new AiCommand(
new CollectionToolRepository( $tools ),
$server,
$client
);
$ai_command( $args, $assoc_args );
} );