feat: guide tool and server instructions

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:
2026-09-25 15:32:26 +02:00
co-authored by Claude Opus 5.5
parent 3b7fabf17a
commit b54d55e5e1
9 changed files with 348 additions and 0 deletions
+94
View File
@@ -0,0 +1,94 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Integrations\Core;
use LIT\MCP\Abilities\Ability;
use LIT\MCP\Abilities\Errors;
use LIT\MCP\Guides\GuideRepository;
use WP_Error;
final class GuideAbility implements Ability
{
private const DEFAULT_TOPIC = 'overview';
public function __construct(private GuideRepository $guides)
{
}
public function name(): string
{
return 'lit/guide';
}
public function label(): string
{
return 'Anleitung';
}
public function description(): string
{
return 'Liefert Anleitungen zur Bedienung dieses MCP-Servers. Ohne topic: Übersicht und Liste aller Themen.';
}
public function inputSchema(): array
{
return [
'type' => 'object',
'properties' => [
'topic' => [
'type' => 'string',
'description' => 'Thema, z. B. "overview" oder "divi-shortform".',
],
],
'additionalProperties' => false,
];
}
public function outputSchema(): ?array
{
return [
'type' => 'object',
'properties' => [
'topic' => ['type' => 'string'],
'topics' => ['type' => 'array', 'items' => ['type' => 'string']],
'content' => ['type' => 'string'],
],
'required' => ['topic', 'topics', 'content'],
];
}
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
{
$topic = isset($input['topic']) && is_string($input['topic']) && $input['topic'] !== ''
? $input['topic']
: self::DEFAULT_TOPIC;
$topics = $this->guides->topics();
$content = $this->guides->get($topic);
if ($content === null) {
return Errors::notFound(sprintf(
'Unbekanntes Thema. Verfügbar: %s',
implode(', ', $topics)
));
}
return ['topic' => $topic, 'topics' => $topics, 'content' => $content];
}
}