The examples use Codex, but the
connection patterns apply to other agents. Use the Box CLI path when an
agent can run shell commands. Use the Box MCP path when an agent supports
the Model Context Protocol.
What you are building
By the end of this tutorial, your agent can read, search, upload, organize, and use Box AI with Box content.Box CLI path
Sign in with OAuth on the agent’s local computer, a remote host, or a
headless container.
Box MCP path
Connect the hosted Box MCP server with OAuth. The Box user you authorize
determines the content available to the agent.
Authentication and access boundaries
Both paths in this tutorial use OAuth. The agent acts as the Box user who completes the OAuth flow and can access the content available to that user, subject to the integration’s scopes and Box security policies. The Box CLI’s built-in OAuth application supports files and folders, Box AI, and Box Sign. Box MCP uses the scopes configured for the integration. Neither path restricts the agent to a single folder when you authorize your own user.Choose the right path
Both paths use the same developer-account user but expose Box through different interfaces.
Choose the Box CLI path if your agent runs in a terminal or on a server, or
inside a container. Choose the Box MCP path if your agent is MCP-native.
Prerequisites
1
An isolated Box developer account
Create a free Box developer account
specifically for testing. Add only sample content that you are comfortable
making available to the agent. The account works for both paths and gives
you the admin access needed to enable the MCP integration yourself.
2
Your agent, installed and working
Use any coding or autonomous agent. Confirm it runs and responds before you
connect Box.
Swap these for your own agent’s install steps. Claude Code, Cursor, Hermes, Pi, and OpenClaw each have their own.
Example: installing Codex
Example: installing Codex
3
Basic terminal familiarity
You’ll run a handful of commands. For a remote login, you also need access
to a browser on another computer.
Set up the connection
- Box CLI (OAuth)
- Box MCP (hosted server)
The Box CLI turns Box into a headless, scriptable surface. Any agent that can
run shell commands can then read, upload, search, and organize Box content by
calling a You’ll authenticate the CLI with OAuth as your developer-account user. The
correct login command depends on whether a browser is available on the machine
where the agent and CLI run.
box command.The CLI can also call Box AI. The box ai:ask, box ai:text-gen, and
box ai:extract commands send requests to the Box AI API for content stored in
Box.A free developer account includes 1,000 AI Units each month for testing Box AI
capabilities. Higher-tier Enterprise plans offer increased AI query limits and
advanced capabilities. Enable the AI API for your account before using these
commands.
1
Install the Box CLI
Install the CLI on the machine where the agent runs:
2
Log in with OAuth
Choose the instructions that match where the Box CLI and agent run.
Local computer with a browser
Local computer with a browser
Run the standard login command on the same computer as the agent:At the authentication-method prompt, choose the official Box CLI
application. The CLI opens your browser and starts a local callback
server. Sign in with your isolated developer-account user and select
Grant Access to Box. The browser returns the authorization response
directly to the CLI.
VPS, remote host, or headless container
VPS, remote host, or headless container
Start a manual-code login on the remote runtime:The runtime does not need a browser, but a person must still complete
the OAuth authorization in a browser on another computer.At the authentication-method prompt, choose the official Box CLI
application. The CLI prints an authorization URL and waits for input:
- Copy the URL and open it in a browser on your local computer.
- Sign in with your isolated developer-account user and select Grant Access to Box.
- The browser redirects to a
localhostURL that containscodeandstatequery parameters. The page fails to load because the callback server is not running on your local computer. This is expected. - Copy the
codeandstatevalues from the browser’s address bar and enter them in the remote CLI when prompted.
3
Verify the Box user
Confirm that the active CLI session uses your developer-account user:
The response should show the name and login of the Box user that completed
OAuth. This is the identity your agent uses for every Box CLI command.
4
Connect the agent and inspect access
Add instructions for your agent. In Codex, add them to Then enter this prompt in the agent chat to confirm the identity and content
available to it:The agent should identify your developer-account user and list the sample
content in the account. In the background, it executes these CLI commands:
AGENTS.md in the
working directory:5
Put it to work
Enter each prompt in the agent chat in order; each builds on the last:
Troubleshoot the CLI path
Troubleshoot the CLI path
- No browser opens on the runtime: use
box login --codeand complete authorization in a browser on another computer. - The localhost redirect fails during
--codelogin: this is expected. Copy thecodeandstatevalues from the URL into the CLI. - The CLI shows the wrong user: start a new login and authorize with the isolated developer-account user.
- The OAuth session is no longer valid: run the appropriate
box logincommand again. - Box AI permission error: confirm that the AI API is enabled for your developer account.
Plan a production agent identity
This tutorial uses user OAuth in an isolated developer account so that you can evaluate the connection without creating a server-authentication app. Do not copy this authentication design into a production workflow without reviewing the identity, scopes, credentials, and content boundary with your Box Admin and security team. The Box user types relevant to an agent integration are:
For a production agent, an organization may choose to have its Admin or platform
team authorize a server app and provision an App User for the agent. An App User
does not remove the Service Account or the parent CCG or JWT application from
the architecture. The Service Account creates the App User, and the authorized
application obtains tokens for it.
CCG and JWT apps always require explicit Admin authorization in a managed
enterprise because their Service Accounts can receive elevated permissions.
App User provisioning, credential brokering, monitoring, and revocation are
production architecture concerns and are outside this tutorial. To design that
flow, see Box user types,
create an App User,
select an authentication method, and
Platform App approval.
Use cases
- Content and launch work: create captions, descriptions, and review notes from the current project files.
- Living documents: assemble a release checklist from the current specification, mockups, and quality-assurance notes.
- Engineering context: give an agent access to current design documents, incident notes, and other maintained technical content.
- Legal and contracts: compare the current redline with a previous version and flag changed clauses for human review.
Related resources
Box CLI docs
Command reference and authentication options.
Headless CLI login
Complete OAuth when the CLI runs on a VPS or in a container.
Box MCP server
Hosted server, supported platforms, and available tools.
Box user types
Compare Managed Users, Service Accounts, and App Users.
