Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 0 additions & 109 deletions src/AiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,44 +90,6 @@ private function register_tools( $server, $client ) {
$map_rest_to_mcp = new MapRESTtoMCP();
$map_rest_to_mcp->map_rest_to_mcp( $server );

$server->register_tool(
[
'name' => 'create_post',
'description' => 'Creates a post.',
'inputSchema' => [
'type' => 'object',
'properties' => [
'title' => [
'type' => 'string',
'description' => 'The title of the post.',
],
'content' => [
'type' => 'string',
'description' => 'The content of the post.',
],
'category' => [
'type' => 'string',
'description' => 'The category of the post.',
],
],
'required' => [ 'title', 'content' ],
],
'callable' => function ( $params ) {
$request = new \WP_REST_Request( 'POST', '/wp/v2/posts' );
$request->set_body_params( [
'title' => $params['title'],
'content' => $params['content'],
'categories' => [ $params['category'] ],
'status' => 'publish',
] );
$controller = new \WP_REST_Posts_Controller( 'post' );
$response = $controller->create_item( $request );
$data = $response->get_data();
return $data;
},
]
);

$server->register_tool(
[
'name' => 'calculate_total',
Expand Down Expand Up @@ -155,77 +117,6 @@ private function register_tools( $server, $client ) {
]
);



// Register tool to retrieve last N posts in JSON format.
$server->register_tool([
'name' => 'list_posts',
'description' => 'Retrieves the last N posts.',
'inputSchema' => [
'type' => 'object',
'properties' => [
'count' => [
'type' => 'integer',
'description' => 'The number of posts to retrieve.',
],
],
'required' => ['count'],
],
'callable' => function ($params) {
$query = new \WP_Query([
'posts_per_page' => $params['count'],
'post_status' => 'publish',
]);
$posts = [];
while ($query->have_posts()) {
$query->the_post();
$posts[] = ['title' => get_the_title(), 'content' => get_the_content()];
}
wp_reset_postdata();
return $posts;
},
]);

$server->register_tool(
[
'name' => 'greet',
'description' => 'Greets the user.',
'inputSchema' => [
'type' => 'object',
'properties' => [
'name' => [
'type' => 'string',
'description' => 'The name of the user.',
],
],
'required' => [ 'name' ],
],
'callable' => function ( $params ) {
return 'Hello, ' . $params['name'] . '!';
},
]
);

// $server->register_tool(
// [
// 'name' => 'generate_image',
// 'description' => 'Generates an image.',
// 'inputSchema' => [
// 'type' => 'object',
// 'properties' => [
// 'prompt' => [
// 'type' => 'string',
// 'description' => 'The prompt for generating the image.',
// ],
// ],
// 'required' => [ 'prompt' ],
// ],
// 'callable' => function ( $params ) use ( $client ) {
// return $client->get_image_from_ai_service( $params['prompt'] );
// },
// ]
// );

$server->register_tool(
[
'name' => 'fetch_wp_community_events',
Expand Down