What is The Box MCP Server integrates with the Box API for file operations and AI querying.?
The Box MCP Server is a Python project that integrates with the Box API to perform various operations such as file search, text extraction, AI-based querying, and data extraction. It leverages the box-sdk-gen library and provides a set of tools to interact with Box files and folders. The Model Context Protocol (MCP) is a framework designed to standardize the way models interact with various data sources and services. In this project, MCP is used to facilitate seamless integration with the Box API, enabling efficient and scalable operations on Box files and folders. The Box MCP Server project aims to provide a robust and flexible solution for managing and processing Box data using advanced AI and machine learning techniques.
Documentation
Box MCP Server
Description
The Box MCP Server is a Python project that integrates with the Box API to perform various operations such as file search, text extraction, AI-based querying, and data extraction. It leverages the box-sdk-gen library and provides a set of tools to interact with Box files and folders.
The Model Context Protocol (MCP) is a framework designed to standardize the way models interact with various data sources and services. In this project, MCP is used to facilitate seamless integration with the Box API, enabling efficient and scalable operations on Box files and folders. The Box MCP Server project aims to provide a robust and flexible solution for managing and processing Box data using advanced AI and machine learning techniques.
Tools Implemented# Box API Tools
box_who_am_i
Get your current user information and check connection status.
Returns: User information dictionary
box_authorize_app_tool
Start the Box application authorization process.
Returns: Authorization status message
box_search_tool
Search for files in Box.
Parameters:
query (str): The query to search for.
file_extensions (List[str], optional): File extensions to filter results.
ancestor_folder_ids (List[str], optional): List of folder IDs in which to search.
Returns: The search results as a newline‑separated list of file names and IDs.
box_read_tool
Read the text content of a Box file.
Parameters:
file_id (str): ID of the file to read
Returns: File content
box_ask_ai_tool
Ask Box AI about a file.
Parameters:
file_id (str): ID of the file
prompt (str): Question for the AI
Returns: AI response
box_hubs_ask_ai_tool
Ask Box AI about a hub. There is currently no way via API to discover a hub ID, so you must know the ID to use this tool. We will fix this in the future.
Parameters:
hubs_id (str): ID of the hub
prompt (str): Question for the AI
Returns: AI response
box_search_folder_by_name
Locate a folder by name.
Parameters:
folder_name (str): Name of the folder
Returns: Folder ID
box_ai_extract_data
Extract data from a file using AI.
Parameters:
file_id (str): ID of the file
fields (str): Fields to extract
Returns: Extracted data in JSON format
box_list_folder_content_by_folder_id
List folder contents.
Parameters:
folder_id (str): ID of the folder
is_recursive (bool): Whether to list recursively
Returns: Folder content in JSON format with id, name, type, and description
box_manage_folder_tool
Create, update, or delete folders in Box.
Parameters:
action (str): Action to perform: "create", "delete", or "update"
folder_id (str, optional): ID of the folder (required for delete/update)
name (str, optional): Folder name (required for create, optional for update)
parent_id (str, optional): Parent folder ID (required for create, optional for update)
description (str, optional): Folder description (optional for update)
recursive (bool, optional): Whether to delete recursively (optional for delete)
Returns: Status message with folder details
box_search_folder_by_name_tool
Locate a folder in Box by its name.
Parameters:
folder_name (str): Name of the folder.
Returns: Information (name and ID) about matching folders.
Box AI Tools## box_ai_ask_file_single_tool
Query Box AI regarding a single file.
Parameters:
file_id (str): The file identifier.
prompt (str): Query or instruction for the AI.
ai_agent_id (str, optional): The ID of the AI agent to use.
Returns: AI response based on the file content.
box_ai_ask_file_multi_tool
Query Box AI using multiple files.
Parameters:
file_ids (List[str]): List of file IDs.
prompt (str): Instruction for the AI based on the aggregate content.
ai_agent_id (str, optional): The ID of the AI agent to use.
Returns: AI-generated answer considering all files provided.
box_ai_ask_hub_tool
Ask Box AI about a hub.
Parameters:
hubs_id (str): ID of the hub.
prompt (str): Question for the AI.
ai_agent_id (str, optional): The ID of the AI agent to use.
Returns: AI response based on the hub content.
box_ai_extract_freeform_tool
Extract data from files using AI with a freeform prompt.
Parameters:
file_ids (List[str]): The IDs of the files to read.
prompt (str): The freeform prompt to guide the AI extraction.
ai_agent_id (str, optional): The ID of the AI agent to use.
Returns: Extracted data in JSON format.
box_ai_extract_structured_using_fields_tool
Extract structured data from files using AI with specified fields.
Parameters:
file_ids (List[str]): The IDs of the files to read.
fields (List[dict]): The fields to extract from the files.
ai_agent_id (str, optional): The ID of the AI agent to use.
Returns: Extracted structured data in JSON format.
box_ai_extract_structured_using_template_tool
Extract structured data from files using AI with a specified template.
Parameters:
file_ids (List[str]): The IDs of the files to read.
template_key (str): The ID of the template to use for extraction.
ai_agent_id (str, optional): The ID of the AI agent to use.
Returns: Extracted structured data in JSON format.
Save and close the mcp.json file, and restart if necessary.
Running Tests
The project includes comprehensive test suites for both unit tests and integration tests to verify Box API functionality.
Test Structure
The project includes two types of tests:
Unit Tests - Mock-based tests that don't require Box API access:
test_box_tools_ai.py - Tests for AI functionality tools
test_box_tools_generic.py - Tests for generic Box operations
test_box_tools_metadata.py - Tests for metadata operations
test_box_tools_search.py - Tests for search functionality
test_server_context.py - Tests for server context management
test_mcp_server_box.py - Tests for MCP server functionality
Integration Tests - Tests that require actual Box API access (with _orig suffix):
test_box_tools_files_orig.py
test_box_tools_metadata_orig.py
test_box_tools_search_orig.py
Running Unit Tests
Unit tests use mocks and don't require Box API credentials:
pytest tests/test_box_tools_*.py tests/test_server_context.py tests/test_mcp_server_box.py
# Run specific unit test files
pytest tests/test_box_tools_ai.py
pytest tests/test_box_tools_generic.py
pytest tests/test_box_tools_metadata.py
# Run with coverage
pytest --cov=src tests/
Running Integration Tests
Integration tests require Box API credentials and valid file/folder IDs in your Box account:
Set up Box API credentials in your .env file
Update File and Folder IDs:
Each integration test file (ending with _orig.py) uses hardcoded IDs for Box files and folders
Replace these IDs with valid IDs from your Box account
File ID References:
For example, in tests/test_box_tools_files_orig.py, replace "1728677291168" with a valid file ID
pytest tests/test_*_orig.py
# Run specific integration test
pytest tests/test_box_tools_files_orig.py
# Run all tests (unit + integration)
pytest
# Run with detailed output
pytest -v
# Run with print statements
pytest -v -s
Test Dependencies
The test suite uses:
pytest - Test framework
pytest-asyncio - For async test support
pytest-cov - For coverage reporting
unittest.mock - For mocking external dependencies
Troubleshooting
If you receive the error Error: spawn uv ENOENT on MacOS when running the MCP server with Claude Desktop, you may:
Remove uv and reinstall it with Homebrew: brew install uv
Or provide the full path to the uv executable in your configuration:
/Users/shurrey/.local/bin/uv --directory /Users/shurrey/local/mcp-server-box run src/mcp_server_box.py
[!NOTE]
Make sure your Box API credentials in .env are correctly set.