47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Mcp\Tools\Signature;
|
|
|
|
use App\Actions\Signature\UpdateSignature;
|
|
use App\Models\WorkspaceSignature;
|
|
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
|
use Laravel\Mcp\Request;
|
|
use Laravel\Mcp\Response;
|
|
use Laravel\Mcp\ResponseFactory;
|
|
use Laravel\Mcp\Server\Attributes\Description;
|
|
use Laravel\Mcp\Server\Tool;
|
|
|
|
#[Description('Update a signature name or content.')]
|
|
class UpdateSignatureTool extends Tool
|
|
{
|
|
public function handle(Request $request): Response|ResponseFactory
|
|
{
|
|
$validated = $request->validate([
|
|
'signature_id' => ['required', 'string'],
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'content' => ['required', 'string'],
|
|
]);
|
|
|
|
$signature = WorkspaceSignature::where('workspace_id', $request->user()->current_workspace_id)
|
|
->find(data_get($validated, 'signature_id'));
|
|
|
|
if (! $signature) {
|
|
return Response::error('Signature not found.');
|
|
}
|
|
|
|
$signature = UpdateSignature::execute($signature, $validated);
|
|
|
|
return Response::structured($signature->toArray());
|
|
}
|
|
|
|
public function schema(JsonSchema $schema): array
|
|
{
|
|
return [
|
|
'signature_id' => $schema->string()->required()->description('The signature ID.'),
|
|
'name' => $schema->string()->required()->description('The new name.'),
|
|
'content' => $schema->string()->required()->description('The new content (hashtags, links, custom text).'),
|
|
];
|
|
}
|
|
}
|