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

Method executeToolCall

services/tool_executor.go:39–64  ·  view source on GitHub ↗

executeToolCall executes a single tool call

(ctx context.Context, toolCall openai.ChatCompletionMessageToolCall, sessionID string)

Source from the content-addressed store, hash-verified

37
38// executeToolCall executes a single tool call
39func (te *ToolExecutor) executeToolCall(ctx context.Context, toolCall openai.ChatCompletionMessageToolCall, sessionID string) models.ToolCallResult {
40 functionName := toolCall.Function.Name
41 arguments := toolCall.Function.Arguments
42 toolCallID := toolCall.ID
43
44 switch functionName {
45 case "search_products":
46 return te.handleSearchProducts(arguments, toolCallID)
47 case "add_to_cart":
48 return te.handleAddToCart(arguments, sessionID, toolCallID)
49 case "remove_from_cart":
50 return te.handleRemoveFromCart(arguments, sessionID, toolCallID)
51 case "view_cart":
52 return te.handleViewCart(sessionID, toolCallID)
53 case "checkout":
54 return te.handleCheckout(sessionID, toolCallID)
55 default:
56 return models.ToolCallResult{
57 CallID: toolCallID,
58 ToolName: functionName,
59 Success: false,
60 Error: fmt.Sprintf("Unknown tool: %s", functionName),
61 Arguments: arguments,
62 }
63 }
64}
65
66// handleSearchProducts handles product search tool calls
67func (te *ToolExecutor) handleSearchProducts(arguments string, toolCallID string) models.ToolCallResult {

Callers 1

ExecuteToolCallsMethod · 0.95

Calls 5

handleSearchProductsMethod · 0.95
handleAddToCartMethod · 0.95
handleRemoveFromCartMethod · 0.95
handleViewCartMethod · 0.95
handleCheckoutMethod · 0.95

Tested by

no test coverage detected