feat: content-types tool and WordPress 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:
2026-09-25 22:21:29 +02:00
co-authored by Claude Opus 5.5
parent 4a652240a3
commit 98a910f056
7 changed files with 296 additions and 7 deletions
@@ -0,0 +1,94 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Integrations\WordPress\Content;
use LIT\MCP\Abilities\Ability;
use LIT\MCP\Abilities\Errors;
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
use WP_Error;
final class ContentTypesAbility implements Ability
{
public function __construct(private ContentSchema $schema)
{
}
public function name(): string
{
return 'lit/content-types';
}
public function label(): string
{
return 'Inhaltstypen';
}
public function description(): string
{
return 'Listet die Inhaltstypen (Post-Typen) dieser Website mit Taxonomien, Anzahl und Divi-Fähigkeit. '
. 'Mit post_type zusätzlich alle Felder (Pods, WordPress-Meta) mit Typ, Pflicht, Auswahlwerten, '
. 'Beziehungsziel und Schreibstatus (writable/readonly/unknown).';
}
public function inputSchema(): array
{
return [
'type' => 'object',
'properties' => [
'post_type' => [
'type' => 'string',
'description' => 'Optional: nur diesen Inhaltstyp, dafür mit allen Feldern.',
],
],
'additionalProperties' => false,
];
}
public function outputSchema(): ?array
{
return [
'type' => 'object',
'properties' => [
'post_types' => ['type' => 'array', 'items' => ['type' => 'object']],
],
'required' => ['post_types'],
];
}
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 current_user_can('edit_posts')
? true
: Errors::forbidden('Keine Berechtigung, Inhalte zu bearbeiten.');
}
public function execute(array $input): mixed
{
$postType = isset($input['post_type']) && is_string($input['post_type']) ? $input['post_type'] : '';
if ($postType === '') {
return ['post_types' => $this->schema->describePostTypes()];
}
$description = $this->schema->describe($postType, true);
if ($description === null) {
return Errors::notFound(
sprintf('Inhaltstyp "%s" ist nicht verfügbar.', $postType),
'Verfügbare Inhaltstypen: ' . implode(', ', $this->schema->postTypeNames()) . '.'
);
}
return ['post_types' => [$description]];
}
}