Skip to main content
An AI agent is more useful when it can work with the same current content as your team. This tutorial explains how to connect an agent to an isolated Box developer account through either the Box CLI or the hosted Box MCP server.
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.
Use a fresh Box developer account that contains only sample content. Do not use this tutorial to connect an agent to a production Box enterprise, your everyday Box account, or sensitive content.

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.
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

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 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.
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.
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.
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.
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:
  1. Copy the URL and open it in a browser on your local computer.
  2. Sign in with your isolated developer-account user and select Grant Access to Box.
  3. The browser redirects to a localhost URL that contains code and state query parameters. The page fails to load because the callback server is not running on your local computer. This is expected.
  4. Copy the code and state values from the browser’s address bar and enter them in the remote CLI when prompted.
For the complete flow, see Login for headless environments.
In a container, persist the CLI’s authentication state in a protected volume so it survives restarts. Never bake tokens or CLI authentication data into a container image or commit them to source control. If the stored OAuth session is removed or can no longer be refreshed, run box login --code again.
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 AGENTS.md in the working directory:
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:
5

Put it to work

Enter each prompt in the agent chat in order; each builds on the last:
  • No browser opens on the runtime: use box login --code and complete authorization in a browser on another computer.
  • The localhost redirect fails during --code login: this is expected. Copy the code and state values 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 login command 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.
Do not give a shell-capable agent direct access to the parent application’s client secret, private key, or unrestricted Service Account credentials. Keep parent credentials under platform-team control, request only the minimum scopes, keep the application at App Access Only unless broader access is required, and expose narrowly scoped operations or short-lived tokens to the agent through an organization-approved runtime.
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.

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.
Last modified on August 11, 2026