MCPcopy Create free account
hub / github.com/astercloud/aster / CallTool

Method CallTool

pkg/tools/bridge/bridge.go:63–87  ·  view source on GitHub ↗

CallTool 调用单个工具

(ctx context.Context, name string, input map[string]any, tc *tools.ToolContext)

Source from the content-addressed store, hash-verified

61
62// CallTool 调用单个工具
63func (b *ToolBridge) CallTool(ctx context.Context, name string, input map[string]any, tc *tools.ToolContext) (*CallToolResult, error) {
64 tool, err := b.GetTool(name)
65 if err != nil {
66 return &CallToolResult{
67 Name: name,
68 Success: false,
69 Error: err.Error(),
70 }, nil
71 }
72
73 result, err := tool.Execute(ctx, input, tc)
74 if err != nil {
75 return &CallToolResult{
76 Name: name,
77 Success: false,
78 Error: err.Error(),
79 }, nil
80 }
81
82 return &CallToolResult{
83 Name: name,
84 Success: true,
85 Result: result,
86 }, nil
87}
88
89// CallToolJSON 使用 JSON 字符串调用工具
90func (b *ToolBridge) CallToolJSON(ctx context.Context, name string, inputJSON string, tc *tools.ToolContext) (*CallToolResult, error) {

Callers 9

CallToolJSONMethod · 0.95
CallToolsBatchMethod · 0.95
CallToolsParallelMethod · 0.95
TestToolBridge_CallToolFunction · 0.95
ExecuteMethod · 0.45
handleToolCallMethod · 0.45
ExecuteMethod · 0.45

Calls 3

GetToolMethod · 0.95
ErrorMethod · 0.65
ExecuteMethod · 0.65

Tested by 3

TestToolBridge_CallToolFunction · 0.76