Skip to content

FEAT: Add file upload from local path for binary files (.pptx, .xlsx, etc.) #33

@takachaa

Description

@takachaa

Problem

The current box_file_upload_tool accepts content: str | bytes as a parameter, which works well for text-based files. However, when AI agents (e.g., Claude Desktop) attempt to upload binary files such as .pptx, .xlsx, .pdf, or .zip, the upload fails because:

  1. Agents cannot reliably pass raw binary data through the MCP tool's content parameter — binary data gets corrupted when serialized as text
  2. There is no way to specify a local file path to upload directly from the filesystem
  3. The existing tool design assumes content is generated or available in memory, not read from an existing local file

This makes it impossible to upload Office documents or other binary files to Box through the MCP server.

Proposed Solution

Add a new tool box_file_upload_from_path_tool that accepts a local file path instead of inline content:

async def box_file_upload_from_path_tool(
    ctx: Context,
    file_path: str,          # Absolute path to local file
    parent_folder_id: str,   # Box destination folder ID
    file_name: Optional[str] = None,  # Optional rename (defaults to original filename)
) -> dict[str, Any]:

How it works

  • Reads the file in binary mode (rb), preserving the exact bytes
  • Delegates to the existing box_file_upload() function from box_ai_agents_toolkit
  • Validates the path (absolute, exists, is a file) before attempting upload

Benefits

  • Supports all file types including .pptx, .xlsx, .pdf, .zip, images, etc.
  • Simple for agents to use — just provide a file path
  • Reuses existing upload infrastructure (no changes to box_ai_agents_toolkit needed)
  • Non-breaking — the existing box_file_upload_tool remains unchanged

Use Case

A user asks an AI agent:

"Upload /Users/me/Desktop/report.pptx to Box folder 12345"

Currently this fails. With the proposed tool, the agent calls:

{
  "file_path": "/Users/me/Desktop/report.pptx",
  "parent_folder_id": "12345"
}

And the file is uploaded correctly with its binary content intact.

Environment

  • mcp-server-box v0.7.0
  • Transport: stdio
  • Auth: OAuth

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions