feat(mcp) : add Slots, Machine Links, Structure, and Clone tools

- list_slots + update_slots for composant/piece slots
- list/add/update/remove machine links (component, piece, product)
- get_machine_structure with full hierarchy
- clone_machine with all links and custom fields
- 52 MCP tests pass total

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-16 14:49:55 +01:00
parent 2f173e766d
commit bd7259ed05
11 changed files with 1724 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace App\Mcp\Tool\Machine;
use App\Mcp\Tool\McpToolHelper;
use App\Repository\MachineComponentLinkRepository;
use App\Repository\MachinePieceLinkRepository;
use App\Repository\MachineProductLinkRepository;
use App\Repository\MachineRepository;
use Mcp\Capability\Attribute\McpTool;
#[McpTool(
name: 'list_machine_links',
description: 'List all links (component, piece, product) for a given machine, grouped by type.',
)]
class ListMachineLinksTool
{
use McpToolHelper;
public function __construct(
private readonly MachineRepository $machines,
private readonly MachineComponentLinkRepository $componentLinks,
private readonly MachinePieceLinkRepository $pieceLinks,
private readonly MachineProductLinkRepository $productLinks,
) {}
public function __invoke(string $machineId): array
{
$machine = $this->machines->find($machineId);
if (null === $machine) {
$this->mcpError('NotFound', "Machine {$machineId} not found.");
}
$compRows = $this->componentLinks->createQueryBuilder('cl')
->select('cl.id', 'IDENTITY(cl.composant) AS entityId', 'IDENTITY(cl.parentLink) AS parentLinkId', 'cl.nameOverride', 'cl.referenceOverride', 'cl.prixOverride')
->where('cl.machine = :machine')
->setParameter('machine', $machine)
->orderBy('cl.id', 'ASC')
->getQuery()
->getArrayResult()
;
$pieceRows = $this->pieceLinks->createQueryBuilder('pl')
->select('pl.id', 'IDENTITY(pl.piece) AS entityId', 'IDENTITY(pl.parentLink) AS parentLinkId', 'pl.nameOverride', 'pl.referenceOverride', 'pl.prixOverride', 'pl.quantity')
->where('pl.machine = :machine')
->setParameter('machine', $machine)
->orderBy('pl.id', 'ASC')
->getQuery()
->getArrayResult()
;
$productRows = $this->productLinks->createQueryBuilder('prl')
->select('prl.id', 'IDENTITY(prl.product) AS entityId', 'IDENTITY(prl.parentLink) AS parentLinkId', 'IDENTITY(prl.parentComponentLink) AS parentComponentLinkId', 'IDENTITY(prl.parentPieceLink) AS parentPieceLinkId')
->where('prl.machine = :machine')
->setParameter('machine', $machine)
->orderBy('prl.id', 'ASC')
->getQuery()
->getArrayResult()
;
return $this->jsonResponse([
'machineId' => $machineId,
'componentLinks' => $compRows,
'pieceLinks' => $pieceRows,
'productLinks' => $productRows,
]);
}
}