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:
20
core/app/Mcp/Tools/GetProfile.php
Normal file
20
core/app/Mcp/Tools/GetProfile.php
Normal 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_start–quiet_end, через полночь) и бейдж — сколько событий в today и overdue.';
|
||||
|
||||
public function handle(): ResponseFactory
|
||||
{
|
||||
return $this->respond(ProfilePresenter::present($this->user()));
|
||||
}
|
||||
}
|
||||
32
core/app/Mcp/Tools/UpdateProfile.php
Normal file
32
core/app/Mcp/Tools/UpdateProfile.php
Normal 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())));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user