A demo showcasing how to build a Pydantic AI agent capable of interacting with the Box MCP server and generating a document.
This project provides a command-line interface for interacting with Box's document generation features using an AI agent. It enables users to upload templates, process data files, and generate documents automatically through conversational prompts.
- Box Authentication: Same as the MCP server
- File Upload & Management: Upload local files to Box folders
- Document Template Management: Mark files as document generation templates
- Automated Document Generation: Create documents using templates and data files
- AI-Powered Interactions: Converse naturally with the agent to perform tasks
- Python 3.11 or higher
- Box account with appropriate permissions
- OpenAI API key
-
Clone the repository:
git clone https://github.com/box-community/doc-gen-pydantic-ai-box-mcp-server.git cd doc-gen-pydantic-ai-box-mcp-server
-
Create a virtual environment:
uv lock uv sync
-
Create a
.env
file with your OpenAI API keys:OPENAI_API_KEY = sk-YOUR API KEY
-
In your Box account create a folder named
OpenAI Doc Gen
Run the demo script to see the agent in action:
uv run src/demo.py
This will:
- Authenticate with Box
- Show who you're logged in as
- Upload a template file to a specified Box folder
- Mark the file as a document generation template
- Upload data in JSON format
- Generate a new document based on the template and data
.
├── data/ # Data files and templates
│ ├── nda_template.docx # Example document template
│ └── NDA.json # Example data for document generation
├── src/ # Source code
│ ├── console_utils.py # Utilities for console output
│ └── demo.py # Main demo script
├── .env # Environment variables (create this)
└── README.md # This file
The agent uses:
- OpenAI's GPT models to interpret user instructions
- pydantic_ai to handle the agent framework
- Box MCP Server to communicate with Box's API
The workflow typically involves:
- Initializing the agent with access to Box tools
- Processing user commands in natural language
- Executing appropriate Box operations
- Providing feedback on operations performed
Contributions are welcome! Please feel free to submit a Pull Request.