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>
39 lines
991 B
PHP
39 lines
991 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Mcp\Tool\TimeEntry;
|
|
|
|
use App\Repository\TimeEntryRepository;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use InvalidArgumentException;
|
|
use Mcp\Capability\Attribute\McpTool;
|
|
|
|
use function sprintf;
|
|
|
|
#[McpTool(name: 'delete-time-entry', description: 'Delete a time entry permanently')]
|
|
class DeleteTimeEntryTool
|
|
{
|
|
public function __construct(
|
|
private readonly TimeEntryRepository $timeEntryRepository,
|
|
private readonly EntityManagerInterface $entityManager,
|
|
) {}
|
|
|
|
public function __invoke(int $id): string
|
|
{
|
|
$entry = $this->timeEntryRepository->find($id);
|
|
|
|
if (null === $entry) {
|
|
throw new InvalidArgumentException(sprintf('TimeEntry with ID %d not found.', $id));
|
|
}
|
|
|
|
$this->entityManager->remove($entry);
|
|
$this->entityManager->flush();
|
|
|
|
return json_encode([
|
|
'success' => true,
|
|
'message' => 'Time entry deleted.',
|
|
]);
|
|
}
|
|
}
|