| 153 | } |
| 154 | |
| 155 | func 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. |
| 173 | func wrapToolWithClient(tool *Tool, dag *dagger.Client, singleTenant bool) *Tool { |