feat: site-status test tool and core integration
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\Core;
|
||||
|
||||
use LIT\MCP\Abilities\Ability;
|
||||
use LIT\MCP\Access;
|
||||
use WP_Error;
|
||||
|
||||
final class SiteStatusAbility implements Ability
|
||||
{
|
||||
public function __construct(private EnvironmentProbe $probe, private Access $access)
|
||||
{
|
||||
}
|
||||
|
||||
public function name(): string
|
||||
{
|
||||
return 'lit/site-status';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Website-Status';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Überblick: Website, WordPress-Version, eigener Benutzer und Rollen, '
|
||||
. 'erkannte Integrationen (Divi, Pods, The Events Calendar).';
|
||||
}
|
||||
|
||||
public function inputSchema(): array
|
||||
{
|
||||
return ['type' => 'object', 'properties' => [], 'additionalProperties' => false];
|
||||
}
|
||||
|
||||
public function outputSchema(): ?array
|
||||
{
|
||||
return [
|
||||
'type' => 'object',
|
||||
'properties' => [
|
||||
'site' => ['type' => 'object'],
|
||||
'wordpress' => ['type' => 'string'],
|
||||
'user' => ['type' => 'object'],
|
||||
'allowed_roles' => ['type' => 'array', 'items' => ['type' => 'string']],
|
||||
'components' => ['type' => 'array'],
|
||||
],
|
||||
'required' => ['site', 'wordpress', 'user', 'allowed_roles', 'components'],
|
||||
];
|
||||
}
|
||||
|
||||
public function annotations(): array
|
||||
{
|
||||
return ['readonly' => true, 'destructive' => false, 'idempotent' => true];
|
||||
}
|
||||
|
||||
public function isDirect(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function permission(array $input): bool|WP_Error
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function execute(array $input): mixed
|
||||
{
|
||||
$user = wp_get_current_user();
|
||||
|
||||
return [
|
||||
'site' => ['name' => get_bloginfo('name'), 'url' => home_url()],
|
||||
'wordpress' => get_bloginfo('version'),
|
||||
'user' => ['id' => $user->ID, 'roles' => array_values($user->roles)],
|
||||
'allowed_roles' => $this->access->allowedRoles(),
|
||||
'components' => $this->probe->components(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user