# Set up Popcorn in Claude Code or Codex

Connect the current client to Popcorn’s local MCP server. A fresh install starts with a synthetic AWS organization and sample CloudTrail events. The demo works without AWS credentials.

## 1. Get the Popcorn CLI

Use macOS or Linux on arm64 or x86-64. Look for `popcorn` on PATH and at `$HOME/.local/bin/popcorn`. If an existing executable supports both `popcorn mcp --help` and `popcorn kernels list --help`, reuse its absolute path as `bin` and continue to step 2.

For a fresh install, build the source distributed with this guide. You need Go 1.26 or later, a native C/C++ toolchain, and network access to the Go module dependencies. The build includes DuckDB and the Kernel catalog. [Go installation instructions](https://go.dev/doc/install) · [Source archive](./popcorn-source.tar.gz) · [SHA-256 checksum](./popcorn-source.tar.gz.sha256)

Set `guide_url` to the full URL from the pasted prompt. Run the following in a POSIX shell. The default destination is `$HOME/.local/bin/popcorn`. If that path belongs to a different program, set `bin` to a free absolute path before running the block.

```sh
bin=${bin:-"$HOME/.local/bin/popcorn"}
(
  set -eu
  : "${guide_url:?Set guide_url to the install.md URL from the prompt}"
  base=${guide_url%/*}
  mkdir -p "$(dirname "$bin")"
  work=$(mktemp -d "$(dirname "$bin")/.popcorn-build.XXXXXXXX")
  trap 'rm -rf "$work"' EXIT
  cd "$work"
  curl -fsSL "$base/popcorn-source.tar.gz" -o popcorn-source.tar.gz
  curl -fsSL "$base/popcorn-source.tar.gz.sha256" -o popcorn-source.tar.gz.sha256
  if command -v sha256sum >/dev/null 2>&1; then
    sha256sum -c popcorn-source.tar.gz.sha256
  else
    shasum -a 256 -c popcorn-source.tar.gz.sha256
  fi
  tar -xzf popcorn-source.tar.gz
  cd popcorn
  GOWORK=off CGO_ENABLED=1 go build -mod=readonly -trimpath -ldflags="-s -w" -o "$work/popcorn-cli" ./cmd/popcorn
  "$work/popcorn-cli" --version
  test ! -d "$bin"
  ln "$work/popcorn-cli" "$bin"
)
```

Continue after the build and installation succeed. Keep the absolute executable path for the remaining commands, including when the install directory is outside PATH.

## 2. Select a workspace

Run setup from the project where the user opened the client. If it already contains a `popcorn.yaml`, use that file. Otherwise initialize the demo at `~/.popcorn/demo/popcorn.yaml`. This keeps the sample logs available across sessions. Carry the values of `bin` and `config` forward if your shell tool starts a new shell for each command.

```sh
set -e
config="$(pwd -P)/popcorn.yaml"
if [ ! -f "$config" ]; then
  config="$HOME/.popcorn/demo/popcorn.yaml"
  if [ ! -f "$config" ]; then
    "$bin" init --demo --config "$config"
  fi
fi
test -f "$config"
"$bin" kernels list --config "$config"
```

## 3. Register with the current client

Use the section for the client that received the prompt. Check whether it already has a server named `popcorn`. Reuse a matching command and config. If the name points elsewhere, preserve that entry and choose an unused name for this workspace.

**Claude Code** — From the original project directory, check `claude mcp get popcorn`. For a new registration, run the following. Local scope makes it available to this user in this project.

```sh
claude mcp add --scope local --transport stdio popcorn -- "$bin" mcp --config "$config"
claude mcp get popcorn
```

**Codex** — Check `codex mcp get popcorn`. For a new registration, run the following. Codex stores this entry in the user’s MCP configuration, so it will point to the selected workspace across projects.

```sh
codex mcp add popcorn -- "$bin" mcp --config "$config"
codex mcp get popcorn
```

If using Codex without the CLI on PATH, add the equivalent entry to the user’s Codex config (normally `~/.codex/config.toml`). Merge this table into the existing file once, substituting the two actual absolute paths.

```toml
[mcp_servers.popcorn]
command = "/absolute/path/to/popcorn"
args = ["mcp", "--config", "/absolute/path/to/popcorn.yaml"]
```

## 4. Verify the connection

Call the Popcorn MCP tool `popcorn_list_kernels` with `{"pack":"aws-top-25"}`. For a custom catalog, use `{}` to list its Kernels. If the current session hasn’t loaded the new server, open a fresh session in the same project and ask **“Use Popcorn to list the AWS Top 25 Kernels.”** Report the executable path, workspace config, and whether the client has loaded the tools.

For a new demo, try **“Use Popcorn to dry-run `aws-scp-block-default-vpc-creation` and `aws-scp-block-leave-organization`. Which one would affect the sample workload?”** The fresh fixture has one default VPC creation and zero attempts to leave the organization.
