MCP Gateway
What is MCP Gateway?
Section titled “What is MCP Gateway?”MCP Gateway is a service that enables you to run and manage multiple Model Context Protocol (MCP) servers within your AgentBox sandbox. It provides a unified gateway interface to access various third-party services and tools through a single endpoint.
Supported MCP Servers
Section titled “Supported MCP Servers”MCP Gateway supports many different MCP servers, including:
- Search & Web: DuckDuckGo, Brave, Exa, ArXiv, Wikipedia
- Databases: PostgreSQL, MySQL, MongoDB, Redis, Chroma, Pinecone
- Cloud Services: AWS, Azure, GCP, Vercel, Heroku
- Development Tools: GitHub, GitLab, Code Interpreter, Filesystem
- AI Services: OpenAI, Anthropic, Hugging Face, ElevenLabs
- Communication: Slack, Discord, Gmail, Notion
- And many more…
Browse all available servers →
Create a sandbox with MCP Gateway
Section titled “Create a sandbox with MCP Gateway”To create a sandbox with MCP Gateway, specify the MCP configuration when creating the sandbox. The mcp-gateway template will be automatically selected.
Basic usage
Section titled “Basic usage”Create a sandbox with a single MCP server:
from agentbox import Sandbox
sandbox = Sandbox.create(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxx",
mcp={
"duckduckgo": {}
}
)from agentbox import AsyncSandbox
sandbox = await AsyncSandbox.create(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxx",
mcp={
"duckduckgo": {}
}
)Multiple MCP servers
Section titled “Multiple MCP servers”You can configure multiple MCP servers in a single sandbox:
from agentbox import Sandbox
sandbox = Sandbox.create(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxx",
mcp={
"duckduckgo": {},
"arxiv": {"storagePath": "/tmp/arxiv"},
"context7": {}
}
)from agentbox import AsyncSandbox
sandbox = await AsyncSandbox.create(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxx",
mcp={
"duckduckgo": {},
"arxiv": {"storagePath": "/tmp/arxiv"},
"context7": {}
}
)Get MCP Gateway URL and Token
Section titled “Get MCP Gateway URL and Token”After creating a sandbox with MCP Gateway, you can retrieve the URL and token to connect to it:
from agentbox import Sandbox
sandbox = Sandbox(api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxx",
sandbox_id="your-sandbox-id")
# 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
sandbox = AsyncSandbox(api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxx",
sandbox_id="your-sandbox-id")
# 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}")The URL format is: https://{sandbox-domain}:50005/mcp
Connect to MCP Gateway
Section titled “Connect to MCP Gateway”Once you have the MCP URL and token, you can connect to it from various MCP clients.
Connect with Python
Section titled “Connect with Python”Using the official MCP Python client:
from 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 a tool
result = await session.call_tool("duckduckgo_search", {
"query": "AgentBox MCP Gateway"
})
print(result)Connect with TypeScript/JavaScript
Section titled “Connect with TypeScript/JavaScript”Using the official MCP TypeScript client:
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
async function connectToMCP(mcpUrl: string, mcpToken: string) {
const transport = new SSEClientTransport(
new URL(mcpUrl),
{
headers: {
Authorization: `Bearer ${mcpToken}`,
},
}
);
const client = new Client(
{
name: "agentbox-mcp-client",
version: "1.0.0",
},
{
capabilities: {},
}
);
await client.connect(transport);
// List available tools
const tools = await client.listTools();
console.log("Available tools:", tools.tools.map(t => t.name));
// Use a tool
const result = await client.callTool({
name: "duckduckgo_search",
arguments: { query: "AgentBox MCP Gateway" },
});
console.log(result);
}Configure Claude Desktop
Section titled “Configure Claude Desktop”To use MCP Gateway with Claude Desktop, add it to your Claude Desktop configuration:
// ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"agentbox-mcp-gateway": {
"transport": {
"type": "sse",
"url": "https://sandbox-abc123.agentbox.cloud:50005/mcp",
"headers": {
"Authorization": "Bearer your-mcp-token"
}
}
}
}
}// %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"agentbox-mcp-gateway": {
"transport": {
"type": "sse",
"url": "https://sandbox-abc123.agentbox.cloud:50005/mcp",
"headers": {
"Authorization": "Bearer your-mcp-token"
}
}
}
}
}Troubleshooting
Section titled “Troubleshooting”Connection timeout: Make sure your sandbox is running and not paused.
Authentication error: Verify that you’re using the correct token and that it hasn’t expired.
Server not found: Ensure the MCP server is properly configured in your sandbox.
Next Steps
Section titled “Next Steps”- Quickstart Guide - Get started with MCP Gateway
- Available Servers - Browse all supported MCP servers
- Custom Templates - Create custom templates with MCP Gateway
- Custom Servers - Build your own MCP servers