Skip to content

Custom Templates

You can create custom AgentBox templates that include MCP Gateway pre-installed. This allows you to have a base template with MCP Gateway ready to use, and then add your own customizations.

Start with the mcp-gateway template and customize it:

# Initialize a new template
agentbox template init

# Build from mcp-gateway template
agentbox template build --from mcp-gateway --name my-mcp-template

You can customize the template by modifying the Dockerfile:

FROM agentbox/base:latest

# MCP Gateway is already installed in the base template
# Add your custom packages and configurations

RUN apt-get update && apt-get install -y \
   your-custom-package \
   && rm -rf /var/lib/apt/lists/*

# Install additional Python packages if needed
RUN pip install your-python-package

# Set up your custom environment
ENV CUSTOM_VAR=value

# Copy custom scripts
COPY scripts/ /usr/local/bin/
RUN chmod +x /usr/local/bin/*.sh

Build your custom template:

# Build the template
agentbox template build --name my-mcp-template --platform linux_x86

Use your custom template when creating sandboxes:

from agentbox import Sandbox

# Use your custom template
sandbox = Sandbox.create(
   api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxx",
   template="your-template-id",
   mcp={
       "duckduckgo": {}
   }
)

You can also configure your template using agentbox.toml:

[template]
name = "my-mcp-template"
description = "Custom template with MCP Gateway"

[build]
platform = "linux_x86"
dockerfile = "Dockerfile"

[env]
CUSTOM_VAR = "value"
  1. Start from mcp-gateway: Use mcp-gateway as your base template to ensure MCP Gateway is properly installed
  2. Keep it minimal: Only add what you need to keep build times reasonable
  3. Test thoroughly: Test your template with various MCP server configurations
  4. Document dependencies: Clearly document any additional packages or configurations