feat: media usage finder and media-get tool
Usage search distinguishes certain (ID referenced) and possible (file URL only) usages, hides titles the user cannot read, and keeps queries bounded. MediaGuard checks per-attachment capabilities and refuses trashed media unless the caller opts in. 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,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\Media;
|
||||
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\Integration;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
use LIT\MCP\Limits;
|
||||
|
||||
/**
|
||||
* Media library tools (spec §6.3). Always available. $log and $limits are used by the
|
||||
* write tools that follow (upload, update, delete).
|
||||
*/
|
||||
final class MediaIntegration implements Integration
|
||||
{
|
||||
public function __construct(private ContentSchema $schema, private ChangeLog $log, private Limits $limits)
|
||||
{
|
||||
}
|
||||
|
||||
public function id(): string
|
||||
{
|
||||
return 'media';
|
||||
}
|
||||
|
||||
public function isAvailable(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function abilities(): array
|
||||
{
|
||||
$presenter = new MediaPresenter();
|
||||
$finder = new MediaUsageFinder(fn (): array => $this->schema->mediaFieldKeys());
|
||||
|
||||
return [
|
||||
new MediaGetAbility($presenter, $finder),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user