feat: MCP profile tools; ProfileUpdater/ProfilePresenter shared with /me; docs and Caddy snippet for /mcp

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:14:31 -03:00
parent ed45a1d516
commit 8ee8a30fb5
12 changed files with 220 additions and 50 deletions

View File

@@ -36,5 +36,7 @@ class HadoServer extends Server
Tools\DeleteEvent::class,
Tools\MarkDone::class,
Tools\MarkAck::class,
Tools\GetProfile::class,
Tools\UpdateProfile::class,
];
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Mcp\Tools;
use App\Presenters\ProfilePresenter;
use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly]
class GetProfile extends AgentTool
{
protected string $name = 'get_profile';
protected string $description = 'Профиль пользователя: логин, часовой пояс, тихие часы (quiet_startquiet_end, через полночь) и бейдж — сколько событий в today и overdue.';
public function handle(): ResponseFactory
{
return $this->respond(ProfilePresenter::present($this->user()));
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Mcp\Tools;
use App\Presenters\ProfilePresenter;
use App\Users\ProfileUpdater;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Request;
use Laravel\Mcp\ResponseFactory;
class UpdateProfile extends AgentTool
{
protected string $name = 'update_profile';
protected string $description = 'Поменять часовой пояс и/или тихие часы пользователя — любое подмножество полей. Тихие часы должны переходить через полночь: quiet_end раньше quiet_start.';
public function __construct(private readonly ProfileUpdater $profile) {}
public function schema(JsonSchema $schema): array
{
return [
'tz' => $schema->string()->description('Идентификатор зоны, напр. Europe/Belgrade'),
'quiet_start' => $schema->string()->description('HH:MM, начало тихих часов'),
'quiet_end' => $schema->string()->description('HH:MM, конец тихих часов'),
];
}
public function handle(Request $request): ResponseFactory
{
return $this->respond(ProfilePresenter::present($this->profile->update($this->user(), $request->all())));
}
}