Skip to main content

CLI basics

The MagicMtn CLI is called magic.

Install​

curl -fsSL https://magicmtn.ai/install.sh | sh

The installer sets up magic in ~/.local/bin and offers to configure your shell. Restart your terminal when it finishes.

Authenticate Git with a GitHub account that has access to the MagicMtn tap before installing with Homebrew.

brew install UseMagicMtn/tap/magic

Run locally​

To run sandboxes on your computer without a Cloud account, follow the local server setup. It uses bundled SQLite and providers installed on your machine. After starting the server, add --local to magic computer commands:

magic --local computer list

The examples below use MagicMtn Cloud. See server selection for connection options.

Login​

magic login

The command opens your browser. Sign in to MagicMtn and approve CLI access, then return to your terminal. If the browser does not open automatically, open the URL printed in the terminal.

If you belong to an organization, the CLI uses it automatically. Otherwise, it uses your personal account.

Logout​

magic logout

This revokes your CLI session and removes its saved credentials from this computer.

MCP​

Connect an MCP client to MagicMtn's sandbox tools with magic mcp serve. Sign in with magic login first. See the MCP command reference for client setup.

Sandbox​

Create a sandbox​

Create a managed sandbox using your configured backend:

magic computer new

Copy a file​

Use the sandbox ID returned when you created it:

magic computer scp <sandbox-id> ./report.csv

The file is copied to the sandbox's working directory, /computer on current MagicMtn Canonical images. An existing file with the same name is replaced.

Open a shell​

List your sandboxes, then connect using a full ID or unique prefix:

magic computer list
magic computer ssh <id>

Press Ctrl+] to disconnect and leave the shell running. Run the same command to reconnect. Type exit to close the shell without stopping the sandbox.

Terminate a sandbox​

Terminate a sandbox and end its attached sessions:

magic computer terminate <id>

Enter y to confirm or press Enter to cancel. Save any files you need before terminating the sandbox.

See the computer command reference for custom images, sandbox requirements, and scripting options.

Completion​

Install tab completion for your shell:

ShellCommand
Bashmagic completion bash
Zshmagic completion zsh
Fishmagic completion fish

The command asks before changing your shell configuration. Restart your shell when it finishes.

For Zsh, ensure autoload -Uz compinit followed by compinit runs after the fpath line added to ~/.zshrc.

See the completion reference for manual setup and PATH configuration.

Providers​

Providers run local sandboxes. Follow Local sandbox setup to prepare the host runtime and runner.

List installed providers:

magic provider list

Install the Apple Container provider on macOS:

magic provider install apple-container

On Linux, install Firecracker:

magic provider install firecracker

To remove a provider, clean up its local sandboxes and stop its runner first:

magic provider uninstall apple-container

See the provider command reference for package installation and other options.