feat: MCP tools for events (list/get/create/update/delete/done/ack); EventRules shared by /api and manual

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
nikita.hohlov
2026-09-05 06:10:41 -03:00
parent 450c165fce
commit ed45a1d516
18 changed files with 711 additions and 56 deletions

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Mcp\Tools;
use App\Ingest\ManualEvents;
use App\Models\Event;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Request;
use Laravel\Mcp\Response;
use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Tools\Annotations\IsDestructive;
#[IsDestructive]
class DeleteEvent extends AgentTool
{
protected string $name = 'delete_event';
protected string $description = 'Снять своё событие (editable: true): оно уходит в withdrawn и больше не напоминает. Это не «Сделано» — для закрытия любого события есть mark_done.';
public function __construct(private readonly ManualEvents $manual) {}
public function schema(JsonSchema $schema): array
{
return ['id' => $schema->integer()->required()];
}
public function handle(Request $request): Response|ResponseFactory
{
return $this->withOwnEvent($request, function (Event $event) {
$this->manual->withdraw($event);
return $this->respond(['id' => $event->id, 'state' => $event->fresh()->state->value]);
});
}
}