MCPcopy Create free account
hub / github.com/docker/model-test / handleRemoveFromCart

Method handleRemoveFromCart

services/tool_executor.go:156–189  ·  view source on GitHub ↗

handleRemoveFromCart handles remove from cart tool calls

(arguments string, sessionID string, toolCallID string)

Source from the content-addressed store, hash-verified

154
155// handleRemoveFromCart handles remove from cart tool calls
156func (te *ToolExecutor) handleRemoveFromCart(arguments string, sessionID string, toolCallID string) models.ToolCallResult {
157 var args struct {
158 ProductName string `json:"product_name"`
159 }
160
161 if err := json.Unmarshal([]byte(arguments), &args); err != nil {
162 return models.ToolCallResult{
163 CallID: toolCallID,
164 ToolName: "remove_from_cart",
165 Success: false,
166 Error: "Invalid arguments",
167 Arguments: arguments,
168 }
169 }
170
171 cartSummary, err := te.cartService.RemoveFromCart(sessionID, args.ProductName)
172 if err != nil {
173 return models.ToolCallResult{
174 CallID: toolCallID,
175 ToolName: "remove_from_cart",
176 Success: false,
177 Error: err.Error(),
178 Arguments: arguments,
179 }
180 }
181
182 return models.ToolCallResult{
183 CallID: toolCallID,
184 ToolName: "remove_from_cart",
185 Success: true,
186 Result: cartSummary,
187 Arguments: arguments,
188 }
189}
190
191// handleViewCart handles view cart tool calls
192func (te *ToolExecutor) handleViewCart(sessionID string, toolCallID string) models.ToolCallResult {

Callers 1

executeToolCallMethod · 0.95

Calls 1

RemoveFromCartMethod · 0.80

Tested by

no test coverage detected