MCPcopy
hub / github.com/dagger/container-use / createEnvironmentCheckpointTool

Function createEnvironmentCheckpointTool

mcpserver/tools.go:836–868  ·  view source on GitHub ↗
(singleTenant bool)

Source from the content-addressed store, hash-verified

834}
835
836func createEnvironmentCheckpointTool(singleTenant bool) *Tool {
837 return &Tool{
838 Definition: newEnvironmentTool(
839 envToolOptions{
840 name: "environment_checkpoint",
841 description: "Checkpoints an environment in its current state as a container.",
842 useCurrentEnvironment: singleTenant,
843 },
844 mcp.WithString("destination",
845 mcp.Description("Container image destination to checkpoint to (e.g. registry.com/user/image:tag"),
846 mcp.Required(),
847 ),
848 ),
849 Handler: func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
850 _, env, err := openEnvironment(ctx, request)
851 if err != nil {
852 return nil, err
853 }
854
855 destination, err := request.RequireString("destination")
856 if err != nil {
857 return nil, err
858 }
859
860 endpoint, err := env.Checkpoint(ctx, destination)
861 if err != nil {
862 return nil, fmt.Errorf("failed to checkpoint environment: %w", err)
863 }
864
865 return mcp.NewToolResultText(fmt.Sprintf("Checkpoint pushed to %q. You MUST use the full content addressed (@sha256:...) reference in `docker` commands. The entrypoint is set to `sh`, keep that in mind when giving commands to the container.", endpoint)), nil
866 },
867 }
868}
869
870func createEnvironmentAddServiceTool(singleTenant bool) *Tool {
871 return &Tool{

Callers 1

createToolsFunction · 0.85

Calls 3

newEnvironmentToolFunction · 0.85
openEnvironmentFunction · 0.85
CheckpointMethod · 0.80

Tested by

no test coverage detected