Quickstart
Install dependencies
Section titled “Install dependencies”First, install the AgentBox Python SDK:
pip install agentbox-python-sdkCreate a sandbox with MCP Gateway
Section titled “Create a sandbox with MCP Gateway”Create a sandbox with a simple MCP server configuration:
from agentbox import Sandbox
# Create sandbox with DuckDuckGo MCP server
sandbox = Sandbox.create(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxx",
mcp={
"duckduckgo": {}
}
)
# Get MCP connection info
mcp_url = sandbox.get_mcp_url()
mcp_token = sandbox.get_mcp_token()
print(f"MCP URL: {mcp_url}")
print(f"MCP Token: {mcp_token}")from agentbox import AsyncSandbox
# Create sandbox with DuckDuckGo MCP server
sandbox = await AsyncSandbox.create(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxx",
mcp={
"duckduckgo": {}
}
)
# Get MCP connection info
mcp_url = await sandbox.get_mcp_url()
mcp_token = await sandbox.get_mcp_token()
print(f"MCP URL: {mcp_url}")
print(f"MCP Token: {mcp_token}")Connect to MCP Gateway
Section titled “Connect to MCP Gateway”Install the MCP Python client and connect to your gateway:
pip install mcpfrom mcp.client.session import ClientSession
from mcp.client.streamable_http import streamablehttp_client
from datetime import timedelta
async def connect_to_mcp(mcp_url, mcp_token):
async with streamablehttp_client(
url=mcp_url,
headers={"Authorization": f"Bearer {mcp_token}"},
timeout=timedelta(seconds=600)
) as (read_stream, write_stream, _):
async with ClientSession(read_stream, write_stream) as session:
await session.initialize()
# List available tools
tools = await session.list_tools()
print(f"Available tools: {[tool.name for tool in tools.tools]}")
# Use DuckDuckGo search tool
result = await session.call_tool("duckduckgo_search", {
"query": "AgentBox MCP Gateway"
})
print(result)
# Use the function
import asyncio
asyncio.run(connect_to_mcp(mcp_url, mcp_token))