📦box
- プラグイン
- box
- ソース
- GitHub で見る ↗
説明
アップロード、フォルダ操作、フォルダ一覧取得、ダウンロードとプレビュー、共有リンク、コラボレーション、検索、メタデータ、イベント駆動型の自動化、Box AI による検索フローなど、Box インテグレーションの構築とトラブルシューティングを行います。 また、Box MCP サーバーを通じた Box コンテンツの操作(検索、読み取り、アップロード、ファイルの整理、Box AI クエリの実行、構造化メタデータの抽出)もカバーしています。 次のような場合に使用: - Box API や SDK をアプリに追加する必要がある - Box を基盤としたドキュメントワークフローを構築・連携する - コンテンツの整理や共有を行う - 新しいファイルのイベントに対して処理を実行する - 検索、要約、抽出、または質問応答のために Box コンテンツを取得する - MCP ツールを通じて Box コンテンツを操作する
原文を表示
Build and troubleshoot Box integrations for uploads, folders, folder listings, downloads and previews, shared links, collaborations, search, metadata, event-driven automations, and Box AI retrieval flows. Also covers working with Box content via the Box MCP server — search, read, upload, organize files, run Box AI queries, and extract structured metadata. Use when the agent needs to add Box APIs or SDKs to an app, wire Box-backed document workflows, organize or share content, react to new files, fetch Box content for search, summarization, extraction, or question-answering, or operate on Box content through MCP tools.
ユースケース
- ✓Box APIやSDKをアプリに追加する
- ✓Boxベースのドキュメントワークフローを構築する
- ✓コンテンツの整理や共有を行う
- ✓ファイルのイベント駆動型処理を実行する
- ✓Boxコンテンツから検索・抽出・要約する
本文(日本語訳)
Box
概要
アプリケーションコードにBoxのコンテンツワークフローを実装します。 可能な限りリポジトリ既存の認証・HTTP・SDKスタックを再利用し、コーディング前に操作主体となるBoxのアイデンティティを確認してから、共有・メタデータ・webhook・AIなどの機能を重ねる前に、最小限のエンドツーエンドのパスを機能させてください。
リクエストのルーティング
ツールの選択
ステップ0(ツールのインベントリ確認)完了後、以下の表を参照して操作に適したツールを選択してください:
| 操作の種類 | 優先ツール | 理由 |
|---|---|---|
| 主要なagentワークフロー(検索・AI・コンテンツ管理・メタデータ・ハブ) | MCP | 構造化I/O、並行処理安全、一般的なケースに対応 |
| 大規模操作(バッチ移動・フォルダツリー・バッチメタデータ) | CLI | コンパクトな出力、--fieldsフィルタリング、手動REST認証不要でフルAPIを利用可能 |
| 確認・スモークテスト | CLI | 再現性が高く、コマンドのコピー&ペーストが容易 |
| MCPスコープ外の操作 | CLI | フルAPIカバレッジ |
| MCPが利用不可かつCLIが利用不可または使用できない場合の最終手段 | Direct REST | ユーザーの明示的な確認とREST認証セットアップの案内を経た後のみ |
| アプリケーションコードのビルド(SDK/RESTエンドポイント、webhookハンドラ) | コード内のSDKまたはREST | agentツールではなく、ユーザーが実際にデプロイするコードを記述する |
MCPは一般的なagentワークフローの大部分をカバーしており、対応するツールが存在する場合のデフォルトです。 操作がMCPのスコープ外の場合、コンパクトかつフィールドフィルタリングされた出力が必要な場合、または再現性のある確認コマンドが必要な場合はCLIを使用してください。 MCPが利用不可の場合はまずMCPセットアップをユーザーに案内し、CLIが利用不可の場合は次にCLIセットアップを案内してください。 Direct RESTは最終手段としてのみ使用し、RESTフォールバックが許容できるかユーザーに明示的に確認してから実施してください。
ドメインルーティング
ユーザーのニーズに応じて、参照すべきファイルを以下の表から選択してください:
| ユーザーが必要としている内容 | 最初に参照 | 合わせて参照 | 最小限の検証 |
|---|---|---|---|
| アップロード・フォルダ・一覧・ダウンロード・共有リンク・コラボレーション・メタデータ | references/content-workflows.md |
references/auth-and-setup.md |
同じアクターによる書き込み後の読み取り |
| ファイルの整理・再編成・フォルダ間のバッチ移動・バッチメタデータタグ付け・フォルダ構造の移行 | references/bulk-operations.md |
references/content-workflows.md、references/auth-and-setup.md、references/ai-and-retrieval.md |
ソースのインベントリ確認、移動件数が計画と一致することを検証 |
| イベント駆動の取り込み・新規ファイルトリガー・webhookデバッグ | references/webhooks-and-events.md |
references/auth-and-setup.md、references/troubleshooting.md |
署名チェックと重複配信テスト |
| 検索・ドキュメント検索・要約・抽出・Box AI | references/ai-and-retrieval.md |
references/auth-and-setup.md |
回答フォーマット前の検索品質チェック |
| 401・403・404・409・429エラー・コンテンツの欠如・アクター不一致のバグ | references/troubleshooting.md |
references/auth-and-setup.md |
正確なアクター・オブジェクトID・エンドポイントで再現 |
| どのワークフローが適用されるか不明な場合 | references/workflows.md |
references/auth-and-setup.md |
最小のBoxオブジェクト/アクションのペアを先に選択 |
ワークフロー
Boxに対してコーディングを行う際は、以下のステップを順番に実行してください。
0. 利用可能なBoxツールのインベントリ確認:
- MCP:
who_am_iを呼び出します。失敗した場合はmcp_authを試みます。それでも認証が失敗する場合は、references/auth-and-setup.mdでMCPセットアップ手順を確認してください。MCPが利用可能かどうかを記録します。 - CLI:
box users:get me --jsonを実行します。CLIが利用可能かどうかを記録します。 - MCPが利用不可の場合は、他のツールを検討する前にユーザーにMCPセットアップを案内してMCP認証を再試行してください。
- CLIが利用不可の場合は、ユーザーにCLIセットアップを案内して
box users:get me --jsonを再試行してください。 - MCPが依然として利用不可で、CLIも利用不可またはユーザーがCLIを使用しない場合は、Direct RESTフォールバックの使用前にユーザーから明示的な確認を得てください。承認された場合は、
references/rest-calls.mdを参照して認証とリクエストのパターンを確認してください。 - タスクがアプリケーションコードのビルド(SDKエンドポイントの追加、webhookハンドラの実装)の場合、ツールの利用可否は二次的な問題となります — ステップ1に進んでください。
1. リポジトリ内の既存のBox認証・SDK・HTTPクライアント・環境変数・webhookハンドラ・Box IDの永続化・テストを調査します。
2. エンドポイント選択前に操作主体のアイデンティティを特定します: 接続ユーザー・エンタープライズサービスアカウント・appユーザー・プラットフォーム提供トークンのいずれかです。
3. ツール選択表を使用してツールを選択し、ドメインルーティング表を使用してドメイン参照を特定します。
4. タスクがアクセス権限またはデータの公開範囲を変更するかどうかを確認します。共有リンク・コラボレーション・認証変更・大規模ダウンロード・広範なAI検索は、アクセス範囲を拡大する前にユーザーの明示的な確認が必要です。
5. 選択したツールの参照ファイル(MCPの場合は references/mcp-tool-patterns.md、CLIの場合は references/box-cli.md、Direct RESTフォールバックの場合は references/rest-calls.md)とルーティング表のドメイン参照を確認します:
- Box MCPツールの使用パターン:
references/mcp-tool-patterns.md - Box CLIによるローカル確認:
references/box-cli.md - Direct RESTフォールバックパターン:
references/rest-calls.md - 認証セットアップ・アクター選択・SDK vs REST:
references/auth-and-setup.md - ワークフロールーター:
references/workflows.md - コンテンツ操作:
references/content-workflows.md - ファイルの大規模整理・バッチ移動・フォルダ再構築:
references/bulk-operations.md - webhookとイベント:
references/webhooks-and-events.md - AIと検索:
references/ai-and-retrieval.md - デバッグと障害モード:
references/troubleshooting.md
6. インテグレーションの動作を証明する最小限のエンドツーエンドフローを実装します。
7. 実行可能な検証ステップを追加します。まずリポジトリのテストを優先し、なければCLIが利用可能かつ認証済みの場合にネイティブのBox CLIコマンドを使用します。Direct BOX REST検証は、ユーザーの明示的な確認を得た後の最終手段としてのみ使用します。
8. 認証コンテキスト・Box ID・環境変数または設定・正確な検証コマンドまたはテストとともに成果物を要約します。
ガードレール
- ユーザーが明示的に変更を求めない限り、既存のBox認証モデルを維持してください。
- 新しい認証パスの導入・認証スコープの変更・Box AIの動作変更を行う前に、最新の公式BoxドキュメントをVUしてください。
- コードベースが既に公式Box SDKを使用しているか、対象言語にメンテナンスされたSDKがある場合は、公式Box SDKを優先してください。そうでない場合は、明示的なリクエスト・レスポンス処理を伴うDirect REST呼び出しを使用してください。
- agentワークフローでは、MCPまたはCLIがセットアップ可能な場合に直接Direct RESTへ飛ばないでください。RESTフォールバックを提案する前に、まずMCPのセットアップガイダンスを、次にCLIのセットアップガイダンスを提供してください。
- Direct RESTフォールバックをユーザーへの通知なしに使用しないでください。REST呼び出しを行う前にユーザーから明示的な確認を得てください。
- アクセストークン・クライアントシークレット・秘密鍵・webhookシークレットは環境変数またはプロジェクトのシークレットマネージャに保管してください。
- ファイルID・フォルダID・共有リンク・メタデータテンプレート識別子・コラボレーションIDを区別してください。
- 共有リンク・コラボレーション・メタデータの書き込みは権限に影響する変更として扱い、コーディングや適用の前に対象者・スコープ・最小権限の原則を確認してください。
- 外部アクセスの拡大・操作主体アイデンティティの切り替え・タスクに実際に必要な量を超えるドキュメントコンテンツの取得を行う前には、明示的な確認を求めてください。
- ドキュメントの内容理解(分類・抽出・カテゴリ化)が必要なタスクでは、Box AI(Q&A・extract)を最初の手段として使用してください。Box AIはサーバーサイドで動作するため、ファイル本体のダウンロードは不要です。Box AIが利用不可・認証されていない・初回試行でエラーが発生した場合にのみ、メタデータ検査・プレビュー・ローカル分析へフォールバックしてください。
- Box AI呼び出しは最低1〜2秒の間隔を空けてください。多数のファイルのコンテンツベース分類を行う場合は、まず小さなサンプルを分類してプロンプトを検証し、残りのファイルを追加のAI呼び出しなしに分類できるより安価なシグナル(ファイル名・拡張子・メタデータ)で対応できるかどうかを確認してください。
- Boxネイティブの方法(Box AI・検索・メタデータ・プレビュー)でサーバーサイドから回答できる場合は、ファイル本体のダウンロードや外部AIパイプラインへのコンテンツルーティングを避けてください。
- アプリケーションが実際に必要とするフィールドのみをリクエストし、後でパスを再構築するのではなく返却されたBox IDを永続化してください。
- Box CLIコマンドは必ず1つずつ順番に実行してください。CLIは並行呼び出しをサポートしておらず、並列実行すると認証の競合や操作の欠落が発生します。agent主導のセッションでの大規模処理では、デフォルトでCLIを使用し、MCP/CLIセットアップの試みが失敗するかCLIが使用できずユーザーがRESTフォールバックを明示的に承認した場合にのみRESTを使用してください。
- webhookおよびイベントコンシューマは冪等性を持たせてください。Boxの配信・リトライ経路では重複が発生する可能性があります。
- 検索およびQ&Aタスクでは、AI検索の範囲を絞り込んでください。まず検索・フィルタリングを行い、回答に必要なファイルのみを取得してください。これはBox AIによる分類には適用されません — ドキュメントを分類する場合は、上記のコンテンツ理解ガードレールに従いBox AIを最初に試みてください
原文(English)を表示
Box
Overview
Implement Box content workflows in application code. Reuse the repository's existing auth and HTTP or SDK stack whenever possible, identify the acting Box identity before coding, and make the smallest end-to-end path work before layering on sharing, metadata, webhooks, or AI.
Route The Request
Tool selection
After completing step 0 (tool inventory), use this table to pick the right tool for the operation:
| Operation type | Prefer | Rationale |
|---|---|---|
| Most agent workflows (search, AI, content management, metadata, hubs) | MCP | Structured I/O, concurrent-safe, covers the common cases |
| Bulk operations (batch moves, folder trees, batch metadata) | CLI | Compact output, --fields filtering, full API surface without requiring manual REST auth |
| Verification and smoke tests | CLI | Reproducible, user can copy-paste commands |
| Operations outside MCP scope | CLI | Full API coverage |
| Last-resort fallback when MCP is unavailable and CLI is unavailable or not an option | Direct REST | Only after explicit user confirmation and REST auth setup guidance |
| Building application code (SDK/REST endpoints, webhook handlers) | SDK or REST in code | Not agent tooling — write code the user ships |
MCP covers the majority of common agent workflows and is the default when it has a matching tool. Use CLI when the operation falls outside MCP's scope, when compact and field-filtered output matters, or for reproducible verification commands. If MCP is unavailable, guide the user through MCP setup first; if CLI is unavailable, guide the user through CLI setup next. Use direct REST only as a last resort after explicitly asking the user to confirm that REST fallback is acceptable.
Domain routing
Choose which reference files to read based on what the user needs:
| If the user needs... | Read first | Pair with | Minimal verification |
|---|---|---|---|
| Uploads, folders, listings, downloads, shared links, collaborations, or metadata | references/content-workflows.md |
references/auth-and-setup.md |
Read-after-write call using the same actor |
| Organizing, reorganizing, or batch-moving files across folders; bulk metadata tagging; migrating folder structures | references/bulk-operations.md |
references/content-workflows.md, references/auth-and-setup.md, references/ai-and-retrieval.md |
Inventory source, verify move count matches plan |
| Event-driven ingestion, new-file triggers, or webhook debugging | references/webhooks-and-events.md |
references/auth-and-setup.md, references/troubleshooting.md |
Signature check plus duplicate-delivery test |
| Search, document retrieval, summarization, extraction, or Box AI | references/ai-and-retrieval.md |
references/auth-and-setup.md |
Retrieval-quality check before answer formatting |
| 401, 403, 404, 409, 429, missing content, or wrong-actor bugs | references/troubleshooting.md |
references/auth-and-setup.md |
Reproduce with the exact actor, object ID, and endpoint |
| Unsure which workflow applies | references/workflows.md |
references/auth-and-setup.md |
Choose the smallest Box object/action pair first |
Workflow
Follow these steps in order when coding against Box.
- Inventory available Box tooling:
- MCP: Call
who_am_i. If it fails, trymcp_auth. If auth still fails, readreferences/auth-and-setup.mdfor MCP setup steps. Record whether MCP is available. - CLI: Run
box users:get me --json. Record whether CLI is available. - If MCP is unavailable, walk the user through MCP setup and retry MCP auth before considering other tooling.
- If CLI is unavailable, walk the user through CLI setup and retry
box users:get me --json. - If MCP remains unavailable and CLI remains unavailable or the user declines CLI, ask for explicit confirmation before using direct REST fallback. If approved, use
references/rest-calls.mdfor auth and request patterns. - If the task is building application code (adding SDK endpoints, webhook handlers), tooling availability is secondary — proceed to step 1.
- MCP: Call
- Inspect the repository for existing Box auth, SDK or HTTP client, env vars, webhook handlers, Box ID persistence, and tests.
- Determine the acting identity before choosing endpoints: connected user, enterprise service account, app user, or platform-provided token.
- Select the tool using the tool selection table and identify the domain reference using the domain routing table above.
- Confirm whether the task changes access or data exposure. Shared links, collaborations, auth changes, large-scale downloads, and broad AI retrieval all need explicit user confirmation before widening access or scope.
- Read the reference for the selected tool (
references/mcp-tool-patterns.mdfor MCP,references/box-cli.mdfor CLI,references/rest-calls.mdfor direct REST fallback) and the domain reference from the routing table:- Box MCP tool usage patterns:
references/mcp-tool-patterns.md - Box CLI local verification:
references/box-cli.md - Direct REST fallback patterns:
references/rest-calls.md - Auth setup, actor selection, SDK vs REST:
references/auth-and-setup.md - Workflow router:
references/workflows.md - Content operations:
references/content-workflows.md - Bulk file organization, batch moves, folder restructuring:
references/bulk-operations.md - Webhooks and events:
references/webhooks-and-events.md - AI and retrieval:
references/ai-and-retrieval.md - Debugging and failure modes:
references/troubleshooting.md
- Box MCP tool usage patterns:
- Implement the smallest end-to-end flow that proves the integration works.
- Add a runnable verification step. Prefer the repository's tests first; otherwise use native Box CLI commands when CLI is available and authenticated. Use direct Box REST verification only as a last resort after explicit user confirmation.
- Summarize the deliverable with auth context, Box IDs, env vars or config, and the exact verification command or test.
Guardrails
- Preserve the existing Box auth model unless the user explicitly asks to change it.
- Check the current official Box docs before introducing a new auth path, changing auth scope, or changing Box AI behavior.
- Prefer an official Box SDK when the codebase already uses one or the target language has a maintained SDK. Otherwise use direct REST calls with explicit request and response handling.
- In agent workflows, do not jump straight to direct REST when MCP or CLI can be set up. Offer setup guidance for MCP first and CLI second before proposing REST fallback.
- Never use direct REST fallback silently. Ask the user for explicit confirmation before proceeding with REST calls.
- Keep access tokens, client secrets, private keys, and webhook secrets in env vars or the project's secret manager.
- Distinguish file IDs, folder IDs, shared links, metadata template identifiers, and collaboration IDs.
- Treat shared links, collaborations, and metadata writes as permission-sensitive changes. Confirm audience, scope, and least privilege before coding or applying them.
- Require explicit confirmation before widening external access, switching the acting identity, or retrieving more document content than the task truly needs.
- When a task requires understanding document content — classification, extraction, categorization — use Box AI (Q&A, extract) as the first method attempted. Box AI operates server-side and does not require downloading file bodies. Fall back to metadata inspection, previews, or local analysis only if Box AI is unavailable, not authorized, or returns an error on the first attempt.
- Pace Box AI calls at least 1–2 seconds apart. For content-based classification of many files, classify a small sample first to validate the prompt and discover whether cheaper signals (filename, extension, metadata) can sort the remaining files without additional AI calls.
- Avoid downloading file bodies or routing content through external AI pipelines when Box-native methods (Box AI, search, metadata, previews) can answer the question server-side.
- Request only the fields the application actually needs, and persist returned Box IDs instead of reconstructing paths later.
- Run Box CLI commands strictly one at a time. The CLI does not support concurrent invocations and parallel calls cause auth conflicts and dropped operations. For bulk work in agent-driven sessions, default to CLI and use REST only after MCP/CLI setup attempts fail or CLI is not an option and the user explicitly confirms REST fallback.
- Make webhook and event consumers idempotent. Box delivery and retry paths can produce duplicates.
- Keep AI retrieval narrow for search and Q&A tasks. Search and filter first, then retrieve only the files needed for the answer. This does not apply to Box AI classification — when classifying documents, Box AI should be tried first per the content-understanding guardrail above.
- Do not use
box configure:environments:get --currentas a routine auth check because it can print sensitive environment details.
Verification
- Prefer the repository's existing tests or app flows when they already cover the changed Box behavior.
- If no better verification path exists, prefer native
boxCLI commands whenboxis installed and authenticated. - Use direct REST verification only after confirming MCP and CLI are unavailable or not an option and after the user explicitly approves REST fallback.
- For REST fallback, guide the user through token setup (
BOX_ACCESS_TOKEN) and safe auth handling before issuing requests. - Confirm CLI auth with
box users:get me --json. - Verify mutations with a read-after-write call using the same actor, and record the object ID.
- For webhooks, test the minimal happy path, duplicate delivery, and signature failure handling.
- For AI flows, test retrieval quality separately from answer formatting.
Example smoke checks:
box users:get me --json
box folders:get 0 --json --fields id,name,item_collection
box folders:items 0 --json --max-items 20
box search "invoice" --json --limit 10
curl -sS -H "Authorization: Bearer $BOX_ACCESS_TOKEN" -H "Accept: application/json" "https://api.box.com/2.0/folders/0?fields=id,name,item_collection"
Deliverable
The final answer should include:
- Acting auth context used for the change
- Box object type and IDs touched
- Env vars, secrets, or config expected by the integration
- Files or endpoints added or changed
- Exact verification command, script, or test path
- Any permission-sensitive assumptions that still need confirmation
References
references/mcp-tool-patterns.md: best-practice patterns for working with Box content via the Box MCP server — search, file writes, metadata extraction, Box AI tool selection, and general guidelinesreferences/auth-and-setup.md: auth path selection, SDK vs REST choice, existing-codebase inspection, and current Box doc anchorsreferences/box-cli.md: CLI-first local auth, smoke-test commands, and safe verification patternsreferences/rest-calls.md: direct REST fallback patterns, auth setup, and safe request templatesreferences/workflows.md: quick workflow router when the task is ambiguousreferences/content-workflows.md: uploads, folders, listings, downloads, shared links, collaborations, metadata, and file movesreferences/bulk-operations.md: organizing files at scale, batch moves, folder hierarchy creation, serial execution, and rate-limit handlingreferences/webhooks-and-events.md: webhook setup, event-feed usage, idempotency, and verificationreferences/ai-and-retrieval.md: search-first retrieval, Box AI usage, and external AI guardrailsreferences/troubleshooting.md: common failure modes and a debugging checklistexamples/box-prompts.md: example prompts for realistic use cases
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。