feat : add 22 MCP tool classes for projects, tasks, and time tracking
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>
This commit is contained in:
63
src/Mcp/Tool/Project/GetProjectTool.php
Normal file
63
src/Mcp/Tool/Project/GetProjectTool.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Mcp\Tool\Project;
|
||||
|
||||
use App\Repository\ProjectRepository;
|
||||
use App\Repository\TaskRepository;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'get-project', description: 'Get project details with task count summary per status')]
|
||||
class GetProjectTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ProjectRepository $projectRepository,
|
||||
private readonly TaskRepository $taskRepository,
|
||||
) {}
|
||||
|
||||
public function __invoke(int $id): string
|
||||
{
|
||||
$project = $this->projectRepository->find($id);
|
||||
|
||||
if (null === $project) {
|
||||
throw new InvalidArgumentException(sprintf('Project with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
// Count tasks per status
|
||||
$qb = $this->taskRepository->createQueryBuilder('t')
|
||||
->select('s.label AS statusLabel, COUNT(t.id) AS taskCount')
|
||||
->leftJoin('t.status', 's')
|
||||
->where('t.project = :project')
|
||||
->setParameter('project', $project)
|
||||
->groupBy('s.id, s.label')
|
||||
;
|
||||
|
||||
$statusCounts = [];
|
||||
$totalTasks = 0;
|
||||
foreach ($qb->getQuery()->getResult() as $row) {
|
||||
$label = $row['statusLabel'] ?? 'No status';
|
||||
$count = (int) $row['taskCount'];
|
||||
$statusCounts[$label] = $count;
|
||||
$totalTasks += $count;
|
||||
}
|
||||
|
||||
return json_encode([
|
||||
'id' => $project->getId(),
|
||||
'code' => $project->getCode(),
|
||||
'name' => $project->getName(),
|
||||
'description' => $project->getDescription(),
|
||||
'color' => $project->getColor(),
|
||||
'client' => $project->getClient() ? [
|
||||
'id' => $project->getClient()->getId(),
|
||||
'name' => $project->getClient()->getName(),
|
||||
] : null,
|
||||
'archived' => $project->isArchived(),
|
||||
'taskSummary' => $statusCounts,
|
||||
'totalTasks' => $totalTasks,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user