Tools: list-users, list-clients, list/get/create/update-project, list/get/create/update/delete-task, list-statuses/priorities/efforts/tags, list/create/update-group, list/create/update/delete-time-entry. Attribute moved to class level for SDK discovery compatibility. Install nyholm/psr7 for HTTP transport PSR-17 support. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Mcp\Tool\TaskMeta;
|
|
|
|
use App\Entity\TaskGroup;
|
|
use App\Repository\ProjectRepository;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use InvalidArgumentException;
|
|
use Mcp\Capability\Attribute\McpTool;
|
|
|
|
use function sprintf;
|
|
|
|
#[McpTool(name: 'create-group', description: 'Create a new task group for a project')]
|
|
class CreateGroupTool
|
|
{
|
|
public function __construct(
|
|
private readonly EntityManagerInterface $entityManager,
|
|
private readonly ProjectRepository $projectRepository,
|
|
) {}
|
|
|
|
public function __invoke(
|
|
int $projectId,
|
|
string $title,
|
|
?string $description = null,
|
|
?string $color = null,
|
|
): string {
|
|
$project = $this->projectRepository->find($projectId);
|
|
if (null === $project) {
|
|
throw new InvalidArgumentException(sprintf('Project with ID %d not found.', $projectId));
|
|
}
|
|
|
|
$group = new TaskGroup();
|
|
$group->setProject($project);
|
|
$group->setTitle($title);
|
|
|
|
if (null !== $description) {
|
|
$group->setDescription($description);
|
|
}
|
|
if (null !== $color) {
|
|
$group->setColor($color);
|
|
}
|
|
|
|
$this->entityManager->persist($group);
|
|
$this->entityManager->flush();
|
|
|
|
return json_encode([
|
|
'id' => $group->getId(),
|
|
'title' => $group->getTitle(),
|
|
'description' => $group->getDescription(),
|
|
'color' => $group->getColor(),
|
|
'project' => [
|
|
'id' => $project->getId(),
|
|
'code' => $project->getCode(),
|
|
'name' => $project->getName(),
|
|
],
|
|
'archived' => $group->isArchived(),
|
|
]);
|
|
}
|
|
}
|