BotSharp/tests/BotSharp.PizzaBot.MCPServer/Tools/PlaceOrder.cs

32 lines
1 KiB
C#
Raw Normal View History

using ModelContextProtocol.Server;
2025-03-19 03:07:31 +00:00
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace BotSharp.PizzaBot.MCPServer.Tools;
[McpServerToolType]
2025-03-19 03:07:31 +00:00
public static class PlaceOrder
{
[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)
{
throw new McpServerException("Missing required argument 'pizza_type'");
}
if (quantity <= 0)
{
throw new McpServerException("Missing required argument 'quantity'");
}
if (unit_price < 0)
2025-03-19 03:07:31 +00:00
{
throw new McpServerException("Missing required argument 'unit_price'");
}
return "The order number is P123-01: {order_number = \"P123-01\" }";
}
}