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 build
By the end of this tutorial, your agent can read, search, upload, organize, and use Box AI with Box content.Box CLI path
Connect a Client Credentials Grant service account. The agent has its own
Box identity and can access only the folders shared with it.
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
The authentication method determines which Box identity the agent uses and what content it can access:- Personal OAuth: the agent acts as the Box user who completes OAuth. It has the same access as that user.
- Client Credentials Grant: the agent acts as a separate service account. The service account starts without access to your content and can access only the folders shared with it.
- Dedicated managed user: the agent completes OAuth as a user created for the agent. Its access is limited to the folders shared with that user. This option requires an available seat on a paid plan.
Choose the right path
Both paths connect an agent to Box, but they use different identities and access boundaries.
Choose the Box CLI path if your agent runs in a terminal or on a server, or
if you need to scope it to a shared project folder. Choose the Box MCP path
if your agent is MCP-native and you are comfortable authorizing the appropriate
Box user through OAuth.
Prerequisites
1
A Box account you can build on
A free Box developer account is
all you need. It works for both paths and comes with admin access, so you
can enable the MCP integration and authorize apps yourself without waiting on
a separate enterprise admin.
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 and edit one or two small config files.
Set up the connection
- Box CLI (service account)
- 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 as a CCG service account so the agent gets its own Box identity and only sees folders you explicitly share with it.
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
Create a Server app in the Developer Console
Go to the Box Developer Console and click New App. In the dialog:
- Enter an App Name (for example,
agent-service). - Under App Type, choose Server. If the option displays, select Client Credentials Grant.
- Click Create.
3
Authorize the app and copy its credentials
Authorize the app in the Developer Console. For enterprise accounts, follow
the platform app approval guide
or ask an administrator to approve the app.In the app’s App Details sidebar, copy the following values:
- Properties: Enterprise ID
- Access: Client ID and Client Secret
4
Store the credentials securely
Keep credentials outside the agent’s working directory and outside source
control. The JSON file below is only a temporary bootstrap file. Create a
restricted directory for it:Create Restrict the file to your user, then import it into the Box CLI:The CLI stores the imported environment in your operating system’s secure
credential storage, such as macOS Keychain or Windows Credential Manager.
On a shared host, in CI, or in production, retrieve the bootstrap values
from a secret manager at runtime and remove the temporary file immediately.
~/.box-agent/ccg-config.json:5
Verify the service account
Confirm that the active CLI environment uses the service account:
You should see an automation / app user, not your personal account. This
non-human identity is who your agent acts as in Box.
6
Share one project folder
Create a project folder in the Box web app, such as
Agent Workspace. In
the Developer Console, copy the service account email address from App
Details. In the Box web app, open the project folder, select Share,
and invite that address with the Editor role.The service account can access only folders shared with it.7
Connect the agent and verify access
Add instructions for your agent. In Codex, add them to Then enter this prompt in the agent chat to prove the boundary holds:The agent should identify the automation user and list only the folders
shared with that identity. In the background, it executes these CLI commands:
AGENTS.md in the
working directory:8
Put it to work
In the Box web app, open the project folder and note its numeric folder ID
from the URL. For example, the URL might look like this:The folder ID is the number
1234567890 after folder/. Then enter each
prompt in the agent chat in order; each builds on the last.
If the agent struggles to find the Agent Workspace folder, give it the folder
ID noted above:Troubleshoot the CLI path
Troubleshoot the CLI path
- The CLI shows your personal account: activate the
serviceenvironment withbox configure:environments:set-current service. - Authorization error: confirm that the app is approved for the enterprise.
- The agent sees no files: confirm that the service account is a collaborator on the project folder.
- Box AI permission error: confirm that the AI API is enabled and that the service account can access the target folder.
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.
Box MCP server
Hosted server, supported platforms, and available tools.
Client Credentials Grant
Details about service-account authentication for the CLI path.
Box AI with the CLI
Use Box AI commands for Q&A and summaries.
