refactor: drop QuantityOnHand from CutList.Mcp inventory tools
Matches the REST API's StockItemDto/CreateStockItemDto shape after inventory quantity tracking removal. Republished to ~/.claude/mcp/CutList.Mcp/.
This commit is contained in:
@@ -70,14 +70,13 @@ public class ApiClient
|
|||||||
return await _http.GetFromJsonAsync<List<ApiStockItemDto>>(url) ?? [];
|
return await _http.GetFromJsonAsync<List<ApiStockItemDto>>(url) ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ApiStockItemDto?> CreateStockItemAsync(int materialId, string length, string? name, int quantityOnHand, string? notes)
|
public async Task<ApiStockItemDto?> CreateStockItemAsync(int materialId, string length, string? name, string? notes)
|
||||||
{
|
{
|
||||||
var body = new
|
var body = new
|
||||||
{
|
{
|
||||||
MaterialId = materialId,
|
MaterialId = materialId,
|
||||||
Length = length,
|
Length = length,
|
||||||
Name = name,
|
Name = name,
|
||||||
QuantityOnHand = quantityOnHand,
|
|
||||||
Notes = notes
|
Notes = notes
|
||||||
};
|
};
|
||||||
var response = await _http.PostAsJsonAsync("api/stock-items", body);
|
var response = await _http.PostAsJsonAsync("api/stock-items", body);
|
||||||
@@ -360,7 +359,6 @@ public class ApiStockItemDto
|
|||||||
public decimal LengthInches { get; set; }
|
public decimal LengthInches { get; set; }
|
||||||
public string LengthFormatted { get; set; } = string.Empty;
|
public string LengthFormatted { get; set; } = string.Empty;
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public int QuantityOnHand { get; set; }
|
|
||||||
public string? Notes { get; set; }
|
public string? Notes { get; set; }
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,6 @@ public class InventoryTools
|
|||||||
LengthInches = s.LengthInches,
|
LengthInches = s.LengthInches,
|
||||||
LengthFormatted = s.LengthFormatted,
|
LengthFormatted = s.LengthFormatted,
|
||||||
Name = s.Name,
|
Name = s.Name,
|
||||||
QuantityOnHand = s.QuantityOnHand,
|
|
||||||
Notes = s.Notes,
|
Notes = s.Notes,
|
||||||
IsActive = s.IsActive
|
IsActive = s.IsActive
|
||||||
}).ToList()
|
}).ToList()
|
||||||
@@ -194,14 +193,12 @@ public class InventoryTools
|
|||||||
string length,
|
string length,
|
||||||
[Description("Optional name/label for this stock item")]
|
[Description("Optional name/label for this stock item")]
|
||||||
string? name = null,
|
string? name = null,
|
||||||
[Description("Initial quantity on hand (default 0)")]
|
|
||||||
int quantityOnHand = 0,
|
|
||||||
[Description("Notes")]
|
[Description("Notes")]
|
||||||
string? notes = null)
|
string? notes = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var stockItem = await _api.CreateStockItemAsync(materialId, length, name, quantityOnHand, notes);
|
var stockItem = await _api.CreateStockItemAsync(materialId, length, name, notes);
|
||||||
|
|
||||||
if (stockItem == null)
|
if (stockItem == null)
|
||||||
return new StockItemResult { Success = false, Error = "Failed to create stock item" };
|
return new StockItemResult { Success = false, Error = "Failed to create stock item" };
|
||||||
@@ -217,7 +214,6 @@ public class InventoryTools
|
|||||||
LengthInches = stockItem.LengthInches,
|
LengthInches = stockItem.LengthInches,
|
||||||
LengthFormatted = stockItem.LengthFormatted,
|
LengthFormatted = stockItem.LengthFormatted,
|
||||||
Name = stockItem.Name,
|
Name = stockItem.Name,
|
||||||
QuantityOnHand = stockItem.QuantityOnHand,
|
|
||||||
Notes = stockItem.Notes,
|
Notes = stockItem.Notes,
|
||||||
IsActive = stockItem.IsActive
|
IsActive = stockItem.IsActive
|
||||||
}
|
}
|
||||||
@@ -237,7 +233,7 @@ public class InventoryTools
|
|||||||
|
|
||||||
#region Convenience
|
#region Convenience
|
||||||
|
|
||||||
[McpServerTool(Name = "add_stock"), Description("Convenience method: adds a material (if needed) and a stock item (if needed) with an initial quantity, all in one call.")]
|
[McpServerTool(Name = "add_stock"), Description("Convenience method: adds a material (if needed) and a stock item (if needed), all in one call.")]
|
||||||
public async Task<AddStockResult> AddStock(
|
public async Task<AddStockResult> AddStock(
|
||||||
[Description("Material shape (e.g., 'Angle', 'FlatBar')")]
|
[Description("Material shape (e.g., 'Angle', 'FlatBar')")]
|
||||||
string shape,
|
string shape,
|
||||||
@@ -245,8 +241,6 @@ public class InventoryTools
|
|||||||
string size,
|
string size,
|
||||||
[Description("Stock length (e.g., '20'', '240')")]
|
[Description("Stock length (e.g., '20'', '240')")]
|
||||||
string length,
|
string length,
|
||||||
[Description("Quantity on hand (default 0)")]
|
|
||||||
int quantityOnHand = 0,
|
|
||||||
[Description("Material type: Steel, Aluminum, Stainless, Brass, Copper (default: Steel)")]
|
[Description("Material type: Steel, Aluminum, Stainless, Brass, Copper (default: Steel)")]
|
||||||
string type = "Steel",
|
string type = "Steel",
|
||||||
[Description("Grade or specification (e.g., 'A36', 'Hot Roll', '304', '6061-T6')")]
|
[Description("Grade or specification (e.g., 'A36', 'Hot Roll', '304', '6061-T6')")]
|
||||||
@@ -315,7 +309,7 @@ public class InventoryTools
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
stockItem = await _api.CreateStockItemAsync(material.Id, length, null, quantityOnHand, null);
|
stockItem = await _api.CreateStockItemAsync(material.Id, length, null, null);
|
||||||
stockItemCreated = true;
|
stockItemCreated = true;
|
||||||
}
|
}
|
||||||
catch (ApiConflictException)
|
catch (ApiConflictException)
|
||||||
@@ -351,8 +345,7 @@ public class InventoryTools
|
|||||||
MaterialCreated = materialCreated,
|
MaterialCreated = materialCreated,
|
||||||
StockItemId = stockItem.Id,
|
StockItemId = stockItem.Id,
|
||||||
StockItemCreated = stockItemCreated,
|
StockItemCreated = stockItemCreated,
|
||||||
LengthFormatted = ArchUnits.FormatFromInches(lengthInches),
|
LengthFormatted = ArchUnits.FormatFromInches(lengthInches)
|
||||||
QuantityOnHand = stockItem.QuantityOnHand
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,7 +512,6 @@ public class StockItemDto
|
|||||||
public decimal LengthInches { get; set; }
|
public decimal LengthInches { get; set; }
|
||||||
public string LengthFormatted { get; set; } = string.Empty;
|
public string LengthFormatted { get; set; } = string.Empty;
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public int QuantityOnHand { get; set; }
|
|
||||||
public string? Notes { get; set; }
|
public string? Notes { get; set; }
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
}
|
}
|
||||||
@@ -548,7 +540,6 @@ public class AddStockResult
|
|||||||
public int StockItemId { get; set; }
|
public int StockItemId { get; set; }
|
||||||
public bool StockItemCreated { get; set; }
|
public bool StockItemCreated { get; set; }
|
||||||
public string LengthFormatted { get; set; } = string.Empty;
|
public string LengthFormatted { get; set; } = string.Empty;
|
||||||
public int QuantityOnHand { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user