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:
32
core/app/Mcp/Tools/UpdateEvent.php
Normal file
32
core/app/Mcp/Tools/UpdateEvent.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Tools;
|
||||
|
||||
use App\Ingest\ManualEvents;
|
||||
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 UpdateEvent extends AgentTool
|
||||
{
|
||||
protected string $name = 'update_event';
|
||||
|
||||
protected string $description = 'Поправить своё событие (editable: true) — любое подмножество полей create_event, остальное не меняется. Новый `due_at` — это перенос: состояние пересчитывается от новой даты даже у закрытого события, «Помню» сбрасывается, `fire_at` без явного значения считается заново (за 30 дней до нового срока). События других источников не правятся — их закрывают через mark_done.';
|
||||
|
||||
public function __construct(private readonly ManualEvents $manual) {}
|
||||
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return ['id' => $schema->integer()->required()] + CreateEvent::fields($schema, required: false);
|
||||
}
|
||||
|
||||
public function handle(Request $request): Response|ResponseFactory
|
||||
{
|
||||
$fields = $request->validate(CreateEvent::shape(required: false));
|
||||
|
||||
return $this->withOwnEvent($request, fn (Event $event) => $this->respond(EventPresenter::forUser($this->manual->update($event, $fields))));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user