KAN-73: document and validate MCP ticket description format
This commit is contained in:
@@ -2,10 +2,14 @@
|
||||
|
||||
namespace App\Mcp\Tools;
|
||||
|
||||
use App\Actions\Tickets\Support\TicketDescriptionFormat;
|
||||
use App\Actions\Tickets\UpdateProjectTicket;
|
||||
use App\Mcp\Support\DescribesTicketWriting;
|
||||
use App\Mcp\Support\KanbanGitMcp;
|
||||
use App\Rules\VisualTicketDescription;
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Illuminate\JsonSchema\Types\Type;
|
||||
use Illuminate\Support\Arr;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\ResponseFactory;
|
||||
@@ -19,6 +23,8 @@ use Laravel\Mcp\Server\Tools\Annotations\IsDestructive;
|
||||
#[IsDestructive(false)]
|
||||
class UpdateTicketDescription extends Tool
|
||||
{
|
||||
use DescribesTicketWriting;
|
||||
|
||||
public function __construct(
|
||||
private readonly KanbanGitMcp $kanbanGitMcp,
|
||||
private readonly UpdateProjectTicket $updateProjectTicket,
|
||||
@@ -27,7 +33,7 @@ class UpdateTicketDescription extends Tool
|
||||
public function handle(Request $request): Response|ResponseFactory
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'description' => ['nullable', 'string'],
|
||||
'description' => ['nullable', 'string', new VisualTicketDescription],
|
||||
'ticket_id' => ['required', 'integer'],
|
||||
]);
|
||||
|
||||
@@ -35,7 +41,7 @@ class UpdateTicketDescription extends Tool
|
||||
$ticket = $this->kanbanGitMcp->ticketForWrite($user, (int) $validated['ticket_id']);
|
||||
$payload = [
|
||||
...$this->kanbanGitMcp->updatePayload($ticket),
|
||||
'description' => $validated['description'] ?? null,
|
||||
...(Arr::exists($validated, 'description') ? ['description' => Arr::get($validated, 'description')] : []),
|
||||
];
|
||||
|
||||
$wasUpdated = $this->updateProjectTicket->handle($ticket, $user, $payload);
|
||||
@@ -58,7 +64,7 @@ class UpdateTicketDescription extends Tool
|
||||
return [
|
||||
'description' => $schema->string()
|
||||
->nullable()
|
||||
->description('New ticket description. Pass null to clear it.'),
|
||||
->description('New ticket description. Omit to preserve; pass null to clear it. '.TicketDescriptionFormat::instructions()),
|
||||
'ticket_id' => $schema->integer()
|
||||
->description('Ticket ID.')
|
||||
->required(),
|
||||
|
||||
Reference in New Issue
Block a user