Files
OpenNest/OpenNest.Mcp/NestSession.cs
T
aj 89356371db feat(mcp): describe each engine in autonest_plate and default fill tools to Fill
The engine argument's description now names every built-in engine with what
it suits, so a model can choose one; omitting it still means Default. The fill
tools resolve an omitted strategy to Fill directly instead of through the
session's whole-job default. Front-end tests cover the MCP and console
defaults and keep the description in step with the registry's built-ins.
2026-10-06 12:26:19 -04:00

69 lines
1.9 KiB
C#

using System.Collections.Generic;
namespace OpenNest.Mcp
{
public class NestSession
{
public Nest Nest { get; set; }
public List<Plate> Plates { get; } = new();
public List<Drawing> Drawings { get; } = new();
/// <summary>
/// Whole-job engine <c>autonest_plate</c> uses when a call does not pass an explicit
/// <c>engine</c> argument; fill tools default to the Fill strategy instead. Instance state
/// only — the process-global legacy registry is never read or written.
/// </summary>
public string DefaultEngineName { get; set; } = "Default";
public Plate GetPlate(int index)
{
if (Nest != null && index < Nest.Plates.Count)
return Nest.Plates[index];
var adjustedIndex = index - (Nest?.Plates.Count ?? 0);
if (adjustedIndex >= 0 && adjustedIndex < Plates.Count)
return Plates[adjustedIndex];
return null;
}
public Drawing GetDrawing(string name)
{
if (Nest != null)
{
foreach (var d in Nest.Drawings)
{
if (d.Name == name)
return d;
}
}
foreach (var d in Drawings)
{
if (d.Name == name)
return d;
}
return null;
}
public List<Plate> AllPlates()
{
var all = new List<Plate>();
if (Nest != null)
all.AddRange(Nest.Plates);
all.AddRange(Plates);
return all;
}
public List<Drawing> AllDrawings()
{
var all = new List<Drawing>();
if (Nest != null)
all.AddRange(Nest.Drawings);
all.AddRange(Drawings);
return all;
}
}
}