Skip to main content

Running a CrewAI Agent with Barndoor

This guide walks you through how to run a CrewAI task using the Barndoor SDK to connect to an MCP server (like Notion), fetch connection parameters, and use the MCP tools within a CrewAI agent. Feel free to checkout the repo here and also run the app with Streamlit for a browser UI demo

πŸ“Ή Demo: Running CrewAI with Barndoor MCP

Prerequisites

  • Python 3.10+
  • A Barndoor account
  • An MCP server registered with Barndoor (connected/authenticated)
  • AI agent registered with Barndoor

Source

1. Install Dependencies

uv pip install -r requirements.txt 

2. Create a .env File

This script expects a .env file in the same directory as main.py. Add the following environment variables:
# Replace with your agent's client ID and secret from Barndoor
# See: https://app.barndoor.ai/agents
AGENT_CLIENT_ID={{barndoor-agent-client-id}}
AGENT_CLIENT_SECRET={{barndoor-agent-client-secret}}

# Replace with your tenant hostname
BARNDOOR_API=https://{{your-tenant}}.mcp.barndoor.ai
BARNDOOR_URL=https://{{your-tenant}}.mcp.barndoor.ai

# Valid OpenAI API Key
# see: https://platform.openai.com/api-keys
OPENAI_API_KEY={{your-openapi-key}}}

# Default values, no changes required
AUTH_DOMAIN=auth.barndoor.ai
API_AUDIENCE=https://barndoor.ai/
MODE=production
Replace the placeholders with real values from your Barndoor project.

3. Run either Crew CLI or UI (browser) version:

uv run crew-cli.py

or

uv run streamlit run crew-ui.py
πŸ› οΈ Troubleshooting
  • Missing .env values: Make sure all required keys are present. -using a stale token. try rm ~/.barndoor/token.json from root of project
  • Invalid server slug: Double-check SERVER_SLUG = β€œnotion” matches your Barndoor dashboard.
  • OAuth login doesn’t open: Manually open the URL shown in the terminal.