( ctx context.Context, params fantasy.ToolCall, )
| 584 | } |
| 585 | |
| 586 | func (t *mcpToolWrapper) Run( |
| 587 | ctx context.Context, |
| 588 | params fantasy.ToolCall, |
| 589 | ) (fantasy.ToolResponse, error) { |
| 590 | input := params.Input |
| 591 | if t.modelIntent { |
| 592 | input = unwrapModelIntent(input) |
| 593 | } |
| 594 | |
| 595 | var args map[string]any |
| 596 | if input != "" { |
| 597 | if err := json.Unmarshal( |
| 598 | []byte(input), &args, |
| 599 | ); err != nil { |
| 600 | return fantasy.NewTextErrorResponse( |
| 601 | "invalid JSON input: " + err.Error(), |
| 602 | ), nil |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | callCtx, cancel := context.WithTimeout(ctx, toolCallTimeout) |
| 607 | defer cancel() |
| 608 | |
| 609 | result, err := t.client.CallTool( |
| 610 | callCtx, |
| 611 | mcp.CallToolRequest{ |
| 612 | Params: mcp.CallToolParams{ |
| 613 | Name: t.originalName, |
| 614 | Arguments: args, |
| 615 | }, |
| 616 | }, |
| 617 | ) |
| 618 | if err != nil { |
| 619 | return fantasy.NewTextErrorResponse(err.Error()), nil |
| 620 | } |
| 621 | |
| 622 | return convertCallResult(result), nil |
| 623 | } |
| 624 | |
| 625 | func (t *mcpToolWrapper) ProviderOptions() fantasy.ProviderOptions { |
| 626 | return t.providerOptions |
nothing calls this directly
no test coverage detected