MCP Server Box

MCP Server Box

一个 Python 服务器,通过 Box API 实现与 Box 文件和文件夹的交互,允许诸如文件搜索、文本提取以及基于 AI 的查询和数据提取等操作。

Category
访问服务器

Tools

box_who_am_i

Get the current user's information. This is also useful to check the connection status. return: str: The current user's information.

box_authorize_app_tool

Authorize the Box application. Start the Box app authorization process return: str: Message

box_search_tool

Search for files in Box with the given query. Args: query (str): The query to search for. file_extensions (List[str]): The file extensions to search for, for example *.pdf content_types (List[SearchForContentContentTypes]): where to look for the information, possible values are: NAME DESCRIPTION, FILE_CONTENT, COMMENTS, TAG, ancestor_folder_ids (List[str]): The ancestor folder IDs to search in. return: str: The search results.

box_read_tool

Read the text content of a file in Box. Args: file_id (str): The ID of the file to read. return: str: The text content of the file.

box_ask_ai_tool

Ask box ai about a file in Box. Args: file_id (str): The ID of the file to read. prompt (str): The prompt to ask the AI. return: str: The text content of the file.

box_search_folder_by_name

Locate a folder in Box by its name. Args: folder_name (str): The name of the folder to locate. return: str: The folder ID.

box_ai_extract_data

" Extract data from a file in Box using AI. Args: file_id (str): The ID of the file to read. fields (str): The fields to extract from the file. return: str: The extracted data in a json string format.

box_list_folder_content_by_folder_id

List the content of a folder in Box by its ID. Args: folder_id (str): The ID of the folder to list the content of. is_recursive (bool): Whether to list the content recursively. return: str: The content of the folder in a json string format, including the "id", "name", "type", and "description".

README

MCP Server Box

描述

MCP Server Box 是一个 Python 项目,它与 Box API 集成,以执行各种操作,例如文件搜索、文本提取、基于 AI 的查询和数据提取。它利用 box-sdk-gen 库,并提供一组工具来与 Box 文件和文件夹进行交互。

模型上下文协议 (MCP) 是一个框架,旨在标准化模型与各种数据源和服务交互的方式。 在此项目中,MCP 用于促进与 Box API 的无缝集成,从而能够对 Box 文件和文件夹执行高效且可扩展的操作。 MCP Server Box 项目旨在提供一个强大而灵活的解决方案,用于使用先进的 AI 和机器学习技术来管理和处理 Box 数据。

已实现的工具

Box 工具

box_who_am_i

获取您当前的用户信息并检查连接状态。

返回: 用户信息字符串

box_authorize_app_tool

启动 Box 应用程序授权过程。

返回: 授权状态消息

box_search_tool

在 Box 中搜索文件。

参数:

  • query (str):搜索查询
  • file_extensions (List[str], optional):要按其进行过滤的文件扩展名
  • where_to_look_for_query (List[str], optional):搜索位置(NAME、DESCRIPTION、FILE_CONTENT、COMMENTS、TAG)
  • ancestor_folder_ids (List[str], optional):要在其中搜索的文件夹 ID

返回: 搜索结果

box_read_tool

读取 Box 文件的文本内容。

参数:

  • file_id (str):要读取的文件的 ID

返回: 文件内容

box_ask_ai_tool

向 Box AI 询问有关文件的信息。

参数:

  • file_id (str):文件的 ID
  • prompt (str):AI 的问题

返回: AI 响应

box_search_folder_by_name

按名称查找文件夹。

参数:

  • folder_name (str):文件夹的名称

返回: 文件夹 ID

box_ai_extract_data

使用 AI 从文件中提取数据。

参数:

  • file_id (str):文件的 ID
  • fields (str):要提取的字段

返回: JSON 格式的提取数据

box_list_folder_content_by_folder_id

列出文件夹内容。

参数:

  • folder_id (str):文件夹的 ID
  • is_recursive (bool):是否递归列出

返回: JSON 格式的文件夹内容,包含 id、name、type 和 description

box_manage_folder_tool

在 Box 中创建、更新或删除文件夹。

参数:

  • action (str):要执行的操作:“create”、“delete”或“update”
  • folder_id (str, optional):文件夹的 ID(删除/更新时必需)
  • name (str, optional):文件夹名称(创建时必需,更新时可选)
  • parent_id (str, optional):父文件夹 ID(创建时必需,更新时可选)
  • description (str, optional):文件夹描述(更新时可选)
  • recursive (bool, optional):是否递归删除(删除时可选)

返回: 包含文件夹详细信息的 Status message

box_upload_file_tool

将内容作为文件上传到 Box。

参数:

  • content (str):要作为文件上传的内容
  • file_name (str):在 Box 中为文件指定的名称
  • folder_id (Any, optional):要上传到的文件夹的 ID

返回: 包含文件 ID 和名称的上传状态

box_download_file_tool

从 Box 下载文件并返回其内容。

参数:

  • file_id (Any):要下载的文件的 ID
  • save_file (bool, optional):是否在本地保存文件
  • save_path (str, optional):保存文件的路径

返回: 文件内容,可以是文本、base64 编码的图像或保存状态消息

要求

  • Python 3.13 或更高版本
  • Box API 凭据(客户端 ID、客户端密钥等)

安装

  1. 克隆存储库:

    git clone https://github.com/box-community/mcp-server-box.git
    cd mcp-server-box
    
  2. 如果尚未安装 uv,请安装它:

    2.1 MacOS+Linux

    curl -LsSf https://astral.sh/uv/install.sh | sh
    

    2.2 Windows

    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
    
  3. 创建并设置我们的项目:

    3.1 MacOS+Linux

    # 创建虚拟环境并激活它
    uv venv
    source .venv/bin/activate
    
    # 锁定依赖项
    uv lock
    

    3.1 Windows

    # 创建虚拟环境并激活它
    uv venv
    .venv\Scripts\activate
    
    # 锁定依赖项
    uv lock
    
  4. 在根目录中创建一个 .env 文件,并添加您的 Box API 凭据:

    BOX_CLIENT_ID=your_client_id
    BOX_CLIENT_SECRET=your_client_secret
    

用法

运行 MCP 服务器

要启动 MCP 服务器,请运行以下命令:

uv --directory /Users/anovotny/Desktop/mcp-server-box run src/mcp_server_box.py

使用 Claude 作为客户端

  1. 编辑您的 claude_desktop_config.json
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
  1. 并添加以下内容:
{
    "mcpServers": {
        "mcp-server-box": {
            "command": "uv",
            "args": [
                "--directory",
                "/Users/anovotny/Desktop/mcp-server-box",
                "run",
                "src/mcp_server_box.py"
            ]
        }
    }
}
  1. 如果 CLaude 正在运行,请重新启动它

## 运行测试

该项目包含一套测试,用于验证 Box API 功能。 在运行测试之前,您需要更新测试文件中的文件和文件夹 ID,以匹配您的 Box 帐户中的文件。

### 设置测试

1. **更新文件和文件夹 ID**:
   - 每个测试文件(在 `tests/` 目录中)都包含 Box 文件和文件夹的硬编码 ID
   - 您需要将这些 ID 替换为您 Box 帐户中的文件和文件夹的 ID
   - 示例:在 `test_box_api_read.py` 中,将 `"1728677291168"` 替换为您 Box 帐户中的文件的 ID

2. **测试文件 ID 引用**:
   - `test_box_api_read.py`:需要一个有效的文档文件 ID(例如,Word 文档)
   - `test_box_api_search.py`:更新搜索查询和文件扩展名以匹配您的内容
   - `test_box_api_ai.py`:需要一个文件 ID 来测试 AI 提取功能
   - 其他测试文件可能需要特定的文件夹 ID 或文件类型

### 运行测试

更新文件 ID 后,您可以使用 pytest 运行测试:

```bash
# 运行所有测试
pytest

# 运行特定的测试文件
pytest tests/test_box_api_file_ops.py

# 运行带有详细输出的测试
pytest -v

# 运行测试并显示打印语句
pytest -v -s

可用测试

  • test_box_auth.py:测试身份验证功能
  • test_box_api_basic.py:基本 Box API 测试
  • test_box_api_read.py:测试文件读取功能
  • test_box_api_search.py:测试搜索功能
  • test_box_api_ai.py:测试基于 AI 的功能
  • test_box_api_file_ops.py:测试文件上传和下载操作

创建新测试

创建新测试时:

  1. 遵循现有测试文件中的模式
  2. 使用 box_client fixture 进行身份验证的 API 访问
  3. 清理测试期间创建的任何测试文件或文件夹
  4. 添加适当的断言以验证功能

故障排除

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选