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,34 @@
<?php
namespace App\Mcp\Tools;
use App\Delivery\EventActions;
use App\Models\Event;
use App\Presenters\EventPresenter;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Request;
use Laravel\Mcp\Response;
use Laravel\Mcp\ResponseFactory;
class MarkDone extends AgentTool
{
protected string $name = 'mark_done';
protected string $description = '«Сделано»: закрыть событие любого источника — как кнопка в инбоксе. Уже закрытое не трогается.';
public function __construct(private readonly EventActions $actions) {}
public function schema(JsonSchema $schema): array
{
return ['id' => $schema->integer()->required()];
}
public function handle(Request $request): Response|ResponseFactory
{
return $this->withEvent($request, function (Event $event) {
$this->actions->done($event);
return $this->respond(EventPresenter::forUser($event->fresh('source')));
});
}
}