MCPcopy Create free account
hub / github.com/dagger/container-use / wrapTool

Function wrapTool

mcpserver/tools.go:155–170  ·  view source on GitHub ↗
(tool *Tool)

Source from the content-addressed store, hash-verified

153}
154
155func wrapTool(tool *Tool) *Tool {
156 return &Tool{
157 Definition: tool.Definition,
158 Handler: func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
159 slog.Info("Tool called", "tool", tool.Definition.Name)
160 defer func() {
161 slog.Info("Tool finished", "tool", tool.Definition.Name)
162 }()
163 response, err := tool.Handler(ctx, request)
164 if err != nil {
165 return mcp.NewToolResultError(err.Error()), nil
166 }
167 return response, nil
168 },
169 }
170}
171
172// keeping this modular for now. we could move tool registration to RunStdioServer and collapse the 2 wrapTool functions.
173func wrapToolWithClient(tool *Tool, dag *dagger.Client, singleTenant bool) *Tool {

Callers 1

createToolsFunction · 0.85

Calls 1

InfoMethod · 0.80

Tested by

no test coverage detected