2025-04-15 16:28:37 +00:00
|
|
|
using ModelContextProtocol;
|
2025-03-21 05:14:19 +00:00
|
|
|
using ModelContextProtocol.Server;
|
2025-03-19 03:07:31 +00:00
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.PizzaBot.MCPServer.Tools;
|
|
|
|
|
|
2025-03-28 10:13:08 +00:00
|
|
|
[McpServerToolType]
|
2025-03-19 03:07:31 +00:00
|
|
|
public static class PlaceOrder
|
|
|
|
|
{
|
2025-04-04 02:58:20 +00:00
|
|
|
[McpServerTool(Name = "place_an_order"), Description("Place an order when user has confirmed the pizza type and quantity.")]
|
2025-03-19 03:07:31 +00:00
|
|
|
public static string PlaceAnOrder(
|
|
|
|
|
[Description("The pizza type."), Required] string pizza_type,
|
|
|
|
|
[Description("quantity of pizza"), Required] int quantity,
|
|
|
|
|
[Description("pizza unit price"),Required] double unit_price)
|
|
|
|
|
{
|
|
|
|
|
if (pizza_type is null)
|
|
|
|
|
{
|
2025-04-15 16:28:37 +00:00
|
|
|
throw new McpException("Missing required argument 'pizza_type'");
|
2025-03-19 03:07:31 +00:00
|
|
|
}
|
|
|
|
|
if (quantity <= 0)
|
|
|
|
|
{
|
2025-04-15 16:28:37 +00:00
|
|
|
throw new McpException("Missing required argument 'quantity'");
|
2025-03-19 03:07:31 +00:00
|
|
|
}
|
2025-04-04 02:58:20 +00:00
|
|
|
if (unit_price < 0)
|
2025-03-19 03:07:31 +00:00
|
|
|
{
|
2025-04-15 16:28:37 +00:00
|
|
|
throw new McpException("Missing required argument 'unit_price'");
|
2025-03-19 03:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "The order number is P123-01: {order_number = \"P123-01\" }";
|
|
|
|
|
}
|
|
|
|
|
}
|