Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
86 lines
2.3 KiB
PHP
86 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Integrations\Core;
|
|
|
|
use LIT\MCP\Abilities\Ability;
|
|
use LIT\MCP\Abilities\Annotations;
|
|
use LIT\MCP\Access;
|
|
use WP_Error;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
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). '
|
|
. 'Bei Divi nennt problems Divi-Stellen, die nach einem Update fehlen oder sich geändert haben, und '
|
|
. 'release, ob LIT MCP mit dieser Divi-Version schreiben darf (released, untested, incompatible).';
|
|
}
|
|
|
|
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 Annotations::read();
|
|
}
|
|
|
|
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(),
|
|
];
|
|
}
|
|
}
|