One-time set-up
This page prepares the one terminal you keep open for the whole workshop: the box build on your PATH, the three secrets in the macOS keychain and in shell variables, a Box home of its own, telemetry off, and the workspace folder with its first file. After it you will know where each secret lives at every moment, and why the folders are where they are. Part 1 starts from exactly this state.
This page fills the keychain and the developer's terminal. The secrets go from the keychain into the terminal's variables, never onto a command line or into a file.
Text description of the diagram
Stage 1 of 5. No sandbox yet.
Pieces in the picture:
- the macOS keychain, which holds the three secrets; the developer reads them into shell variables
- the developer's terminal
- Claude Code, the agent
- the Anthropic API
- Cloudflare's MCP server
- the Cloudflare API
- the sample app: the Worker box-poc-workshop with its D1 database, KV namespace and Workers Logs; the logs and the database hold attendee names and email addresses
Nothing is new in the picture. This page works on two of its pieces: the macOS keychain (top left) and the developer’s terminal beside it.
Before you start: a clean terminal
Section titled “Before you start: a clean terminal”Open a new terminal window. The set-up below was proven in a fresh shell with nothing inherited. Two variables in particular would change every run if your shell already sets them: ANTHROPIC_BASE_URL changes where Claude Code sends its model calls, and ANTHROPIC_MODEL changes which model it uses.
What this doesPrints the two variables if they are set; prints nothing if they are not.
printenv ANTHROPIC_BASE_URL ANTHROPIC_MODELANTHROPIC_BASE_URL ANTHROPIC_MODELprintenv prints the value of each one that is set.unset and the variable’s name.Build the box CLI from source
Section titled “Build the box CLI from source”Iteration 1 below puts the folder $HOME/box-build on your PATH, so the build must be there first. You need the commands in this section only if you do not already have the workshop’s build in that folder.
The build commands, one at a time
Work in an empty folder in your home (not under /tmp). You need git, mise (for the Rust toolchain) and a network connection for Rust’s packages.
-
What this doesDownloads the Box source with the fix, from the fork's workshop branch.
Terminal window git clone --branch bugfix/mcp-shared-definitions-workshop https://github.com/so0k/box.git box-src--branch bugfix/mcp-shared-definitions-workshopChecks out this branch after the download: upstream commitc70fec5plus the fix.https://github.com/so0k/box.gitThe fork ofstrands-agents/boxthat holds the fix.box-srcThe folder to clone into. -
What this doesMoves into the downloaded source folder. Every command below runs from here.
Terminal window cd box-srcbox-srcThe foldergit clonejust made. -
What this doesBuilds the box CLI and its two helper programs with a pinned Rust toolchain.
Terminal window MACOSX_DEPLOYMENT_TARGET=15.0 CARGO_HTTP_TIMEOUT=300 mise x rust@1.98.1 -- \cargo build --release --locked -p strands-box-cli -p strands-box -p strands-box-containment \--bin box --bin strands-box --bin strands-box-sock-alias --bin strands-box-contain-trampolineMACOSX_DEPLOYMENT_TARGET=15.0The oldest macOS the binaries are built for, as the build record says.CARGO_HTTP_TIMEOUT=300Gives slow package downloads up to 300 seconds.mise x rust@1.98.1 --Runs the build with Rust 1.98.1, the version the build record names. Whether another version builds the same was not checked.--releaseAn optimised build.--lockedRefuses to changeCargo.lock, so the dependencies are exactly the source’s.-p ... --bin ...The packages and programs to build.strands-box(Box Core’s own command) is built too, but the workshop does not use it. -
What this doesMakes the folder the workshop uses for the build.
Terminal window mkdir -p "$HOME/box-build/resources"-pMakesbox-buildandresourcesinside it in one step, and gives no error if they already exist."$HOME/box-build/resources"The build folder, with theresourcesfolder the shipped files go into below. -
What this doesCopies the box binary and its two helpers into the build folder.
Terminal window cp target/release/box target/release/strands-box-sock-alias target/release/strands-box-contain-trampoline "$HOME/box-build/"strands-box-sock-alias, strands-box-contain-trampolineThe two helpers must sit besidebox. The trampoline applies the macOS sandbox and then becomes the program it starts. -
What this doesCopies the shipped packs, starters, policy starters and the agent guide beside the binary.
Terminal window cp -R resources/config.toml resources/editing-box-profile.md resources/packs resources/plugins resources/policies resources/starters "$HOME/box-build/resources/"-RCopies folders with everything in them.$HOME/box-build/resources/The CLI looks for its shipped files in aresources/folder beside the binary, the way a release package lays them out. -
What this doesRuns the new binary and prints its version. It changes nothing.
Terminal window "$HOME/box-build/box" --version--versionPrints the version and exits.It should print
box 0.1.0.
Read moreBuilds and gaps: what this build is, and what a released Box still lacksThis workshop
The set-up, step by step
Section titled “The set-up, step by step”What we add. The folder of the local box build, in front of every other folder the shell searches for commands.
The run.
What this doesPuts the workshop's box build in front of everything else on the PATH, for this terminal.
export PATH="$HOME/box-build:$PATH"export$HOME/box-buildbox binary and its helpers (requirements).:$PATHPATH, after the new one.What we see. Nothing: an export prints nothing. Two checks show which box now answers.
What this doesPrints the path of the box command the shell finds.
command -v box-v<your-home>/box-build/boxWhat this doesPrints the version of the box that answers.
box --version--versionbox 0.1.0What we add. Three items in your login keychain, all under the account name box-exec-proxy-poc, one service name per secret:
| Service name | The secret |
|---|---|
anthropic-api-key |
Your Anthropic API key |
box-poc-mcp-token |
The Cloudflare MCP token (with User Details Read) |
box-poc-agent-token |
The Cloudflare agent token |
You do this once per machine, not once per terminal.
The run. One command per secret. Each one asks you for the value; paste it at the prompt.
What this doesAdds the Anthropic API key to the login keychain, asking for the value instead of taking it on the command line.
security add-generic-password -a box-exec-proxy-poc -s anthropic-api-key -wadd-generic-password-a box-exec-proxy-poc-s anthropic-api-key-wsecurity asks for the value instead of reading it from the command line. That is what keeps the secret out of your shell history and out of the process list.security add-generic-password -a box-exec-proxy-poc -s box-poc-mcp-token -wsecurity add-generic-password -a box-exec-proxy-poc -s box-poc-agent-token -wThe two Cloudflare commands differ only in the service name. If an item already exists, security refuses to add it again; add -U before -w to update it instead.
Their form is from man security, which says of -w: “Put at end of command to be prompted (recommended)”. What exactly the prompt looks like, and whether it hides what you paste, was not checked.
What we see. A check that each item exists, without printing its value:
What this doesShows the keychain item's attributes; without -w it does not print the secret.
security find-generic-password -s anthropic-api-key -a box-exec-proxy-pocfind-generic-password-s anthropic-api-key-a box-exec-proxy-pockeychain: "<your-home>/Library/Keychains/login.keychain-db"class: "genp"attributes: "acct"<blob>="box-exec-proxy-poc" "svce"<blob>="anthropic-api-key"A missing item prints security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain. instead. Repeat the check with the two other service names.
What we add. Three variables in this terminal, each read from its keychain item. You repeat this in every new terminal.
The run.
What this doesReads the Anthropic API key from the keychain into a variable, without showing it.
export ANTHROPIC_API_KEY="$(security find-generic-password -s anthropic-api-key -a box-exec-proxy-poc -w)"ANTHROPIC_API_KEY$( ... )-wfind-generic-password, prints only the secret’s value. Here it goes into the variable, not to the screen.What this doesReads the Cloudflare MCP token into a variable.
export CLOUDFLARE_MCP_TOKEN="$(security find-generic-password -s box-poc-mcp-token -a box-exec-proxy-poc -w)"CLOUDFLARE_MCP_TOKENAuthorization header from the MCP config file you write in step 7.What this doesReads the Cloudflare agent token into a variable.
export CLOUDFLARE_API_TOKEN="$(security find-generic-password -s box-poc-agent-token -a box-exec-proxy-poc -w)"CLOUDFLARE_API_TOKENWhat we see. Nothing on the screen. A check that a variable holds something, without printing it:
What this doesPrints set if the variable is not empty, and nothing otherwise.
[ -n "$ANTHROPIC_API_KEY" ] && echo set[ -n ... ]&& echo setset only if the test was true. The value itself is never printed.setRepeat it with CLOUDFLARE_MCP_TOKEN and CLOUDFLARE_API_TOKEN.
What we add. The Box home: the folder where the box CLI keeps profiles, the agent’s storage and the records of each run.
The run.
What this doesTells the box CLI to keep its profiles, storage and runs in a folder of its own.
export BOX_HOME="$HOME/box-ws"BOX_HOME~/.strands/box.$HOME/box-wsws is short for workshop; the name is short on purpose (see below).What we see. Nothing. A check of the path’s length:
What this doesCounts the bytes in the Box home's path.
echo -n "$BOX_HOME" | wc -cecho -nwc -c 25The number must be 65 or less.
Read moreWhere Box keeps its filesBox docs
Read moreTroubleshooting, including the socket path limitBox docs
What we add. One variable that stops the box CLI from sending usage events.
The run.
What this doesTurns the box CLI's usage telemetry off for every command in this terminal.
export BOX_TELEMETRY=0BOX_TELEMETRY=0BOX_TELEMETRY first, then DO_NOT_TRACK, then a saved choice; if none is set, telemetry is on.What we see.
What this doesPrints whether telemetry is on, and what decided it.
box telemetry statustelemetry statusTelemetry is off (set by BOX_TELEMETRY).Read moreUsage telemetry: what is collected and what is notBox docs
What we add. Two folders: the Box home itself, and the workspace, the team’s operations folder in the story. The workspace holds only the MCP config files you write; the agent starts in it.
The run.
What this doesMakes the Box home and the workspace folder, if they do not exist yet.
mkdir -p "$BOX_HOME" "$HOME/leaderboard-ops"-p$HOME/leaderboard-opsWhat this doesMakes the workspace the current folder.
cd "$HOME/leaderboard-ops"What we see.
What this doesPrints the current folder.
pwd<your-home>/leaderboard-opsWhat we add. One file in the workspace that tells Claude Code where Cloudflare’s MCP server is and how to sign in to it. Open your editor and save this as cloudflare-code-mode.json in the workspace:
{ "mcpServers": { "cloudflare": { "type": "http", "url": "https://mcp.cloudflare.com/mcp", "headers": { "Authorization": "Bearer ${CLOUDFLARE_MCP_TOKEN}" } } }}"cloudflare"is the name Claude Code gives the server. Its tools appear asmcp__cloudflare__<tool>, and Box uses the same name in Part 2."type": "http"says the server is remote and reached over HTTP, not started as a local program."url"is Cloudflare’s server. Without a query string it runs in code mode (Part 1)."headers"adds the token to every request.${CLOUDFLARE_MCP_TOKEN}is a placeholder: Claude Code fills it from its own environment when it connects, so the file holds no secret.
With this file saved, the two folders in your home hold this much:
Directorybox-ws/ the Box home, still empty
- …
Directoryleaderboard-ops/ the workspace, where the agent starts
- cloudflare-code-mode.json you edit this
The run. Nothing to run yet. Act a’s free check is the first command that reads this file.
What we see. Act a’s free check shows the server as connected, which proves both the file and the MCP token.
Read moreConnect Claude Code to tools via MCPClaude Code docs
In every new terminal
Section titled “In every new terminal”The exports last only as long as the terminal. If you open a new one, type steps 1, 3, 4 and 5 again and cd into the workspace. Here are those lines in one place, to copy one at a time:
The lines for a new terminal
export PATH="$HOME/box-build:$PATH"export BOX_HOME="$HOME/box-ws"export BOX_TELEMETRY=0export ANTHROPIC_API_KEY="$(security find-generic-password -s anthropic-api-key -a box-exec-proxy-poc -w)"export CLOUDFLARE_MCP_TOKEN="$(security find-generic-password -s box-poc-mcp-token -a box-exec-proxy-poc -w)"export CLOUDFLARE_API_TOKEN="$(security find-generic-password -s box-poc-agent-token -a box-exec-proxy-poc -w)"cd "$HOME/leaderboard-ops"What to remember
Section titled “What to remember”- The secrets live in the keychain, under account
box-exec-proxy-poc, and reach the terminal only through$(security ... -w). BOX_HOME="$HOME/box-ws": a home of its own, short enough for the 103-byte socket path.BOX_TELEMETRY=0turns usage telemetry off for the terminal without writing anything outside the Box home.- The workspace
~/leaderboard-opsis outside the Box home and not under/tmp. cloudflare-code-mode.jsonholds a placeholder, never the token.
Read more
Section titled “Read more”Read moreThe box command reference, including its environment variablesBox docs
Read moreGet started with the box CLI and Claude CodeBox docs
Read moreClaude Code settings and environment variablesClaude Code docs