Skip to main content

agentvisor serve

Start a long-running server that exposes the HTTP API for the agent.

Synopsis​

agentvisor serve [path] [options]

Description​

The serve command starts the AgentVisor™ runtime with:

  • HTTP API on port 8090 (configurable)
  • Temporal worker for durable execution
  • Guest sandbox management
  • Policy enforcement

Use this for local development and testing.

License required

agentvisor serve requires a valid Manetu license key. On a TTY the CLI prompts interactively on first run; set AGENTVISOR_LICENSE_KEY for automated or headless environments. See the Licensing guide for activation instructions and where to obtain a key.

Arguments​

ArgumentDescription
[path]Path to agent directory. Optional if --image is given (a pre-built guest OCI image reference used instead of a source directory).

Options​

OptionDefaultDescriptionEnv Var
--access-log-pretty-printfalseEnable indented multi-line JSON for access logs-
--api-addr-HTTP API listen addressAGENTVISOR_API_LISTEN_ADDR
--bundle-mcp-toolsfalseBundle MCP tools rootfs into a temporary directory for local-launch (gvisor/docker only)-
--cpu-CPU limit for guest sandbox (e.g., 0.5, 1.0, 2.0)-
--debugfalseEnable Python remote debugging via debugpy (unsandboxed mode only, --sandbox=none)AGENTVISOR_GUEST_DEBUG_ENABLED
--debug-opt-Provider-specific options (can be repeated)AGENTVISOR_GUEST_DEBUG_PROVIDER_OPTIONS
--debug-port5678Debug server port (default: 5678, standard debugpy port)AGENTVISOR_GUEST_DEBUG_PORT
--debug-providerdebugpyDebug provider: debugpy (default), pydevdAGENTVISOR_GUEST_DEBUG_PROVIDER
--env-files-Comma-separated paths to .env files; later files override earlier (auto-discovers .env in source-dir if not specified)AGENTVISOR_GUEST_ENVIRONMENT_FILES
--guest-image-Guest base image (default: ghcr.io/manetu/agentvisor/agentvisor-guest:<version>-<type>)-
--image-Pre-built guest OCI image reference (alternative to source directory)-
--interpreter-Override detected interpreter (e.g., python3.12)-
--mcp-tools-image-MCP tools OCI image for bundling (default: ghcr.io/manetu/agentvisor/agentvisor-mcp-tools:<version>)-
--memory-Memory limit for guest sandbox (e.g., 512Mi, 1Gi)-
--policy-Path to policy domain YAML file(s), comma-separated-
--registry-ca-data-Base64-encoded PEM CA certificate to trust when pulling guest/mcp-tools images (alternative to --registry-ca-file)-
--registry-ca-file-Path to a PEM CA certificate to trust when pulling guest/mcp-tools images from a private registry-
--registry-insecurefalseSkip TLS certificate verification for registry pulls; requires AGENTVISOR_TLS_ALLOW_INSECURE=true-
--rootlesstruegVisor rootless mode; disable with --rootless=false for privileged modeAGENTVISOR_GUEST_ROOTLESS
--sandbox-Sandbox mode: docker, none, gvisor (default: docker)AGENTVISOR_GUEST_SANDBOX
--temporal-api-key-Temporal Cloud API keyAGENTVISOR_TEMPORAL_AUTH_API_KEY
--temporal-auth-type-Temporal auth type: api_key, mtlsAGENTVISOR_TEMPORAL_AUTH_TYPE
--temporal-mtls-ca-Path to custom CA certificateAGENTVISOR_TEMPORAL_AUTH_MTLS_CA_FILE
--temporal-mtls-ca-data-Base64-encoded custom CA certificateAGENTVISOR_TEMPORAL_AUTH_MTLS_CA_DATA
--temporal-mtls-cert-Path to mTLS client certificateAGENTVISOR_TEMPORAL_AUTH_MTLS_CERT_FILE
--temporal-mtls-cert-data-Base64-encoded mTLS client certificateAGENTVISOR_TEMPORAL_AUTH_MTLS_CERT_DATA
--temporal-mtls-key-Path to mTLS client private keyAGENTVISOR_TEMPORAL_AUTH_MTLS_KEY_FILE
--temporal-mtls-key-data-Base64-encoded mTLS client private keyAGENTVISOR_TEMPORAL_AUTH_MTLS_KEY_DATA
--temporal-mtls-server-name-TLS server name overrideAGENTVISOR_TEMPORAL_AUTH_MTLS_SERVER_NAME
--temporal-namespace-Temporal namespaceAGENTVISOR_TEMPORAL_NAMESPACE
--temporal-target-Temporal server addressAGENTVISOR_TEMPORAL_TARGET
--temporal-task-queue-Temporal task queueAGENTVISOR_TEMPORAL_TASK_QUEUE

Examples​

Basic Server (Docker Mode - Default)​

agentvisor serve ./my-agent

Running Without Sandbox Isolation​

agentvisor serve ./my-agent --sandbox=none

Debug Mode (Interactive Debugging)​

Enable remote debugging for IDE attachment (VS Code, PyCharm):

# Debug with default provider (debugpy) and port (5678)
agentvisor serve ./my-agent --sandbox=none --debug

# Debug with custom port
agentvisor serve ./my-agent --sandbox=none --debug --debug-port=5679

# Use PyCharm native debugger (pydevd)
agentvisor serve ./my-agent --sandbox=none --debug --debug-provider=pydevd

# Custom port with pydevd
agentvisor serve ./my-agent --sandbox=none --debug --debug-provider=pydevd --debug-port=5679

Each agent invocation waits for debugger attachment. See Local Development Setup for VS Code and PyCharm debugging configuration.

Single Debug Session

Only one agent can bind to the debug port at a time. In serve mode with concurrent requests, only the first agent will successfully start debugging. For debugging specific scenarios, consider using agentvisor run instead.

Debug Mode Requirements
  • Requires --sandbox=none (debug mode is not supported with container sandboxes)
  • For debugpy (default): pip install debugpy
  • For pydevd: pip install pydevd-pycharm

gVisor Mode (Strongest Isolation)​

# Linux only - rootless mode (default, no --privileged needed)
agentvisor serve ./my-agent --sandbox=gvisor

# Linux only - privileged mode (opt-in, requires --rootless=false)
agentvisor serve ./my-agent --sandbox=gvisor --rootless=false

Custom API Port​

agentvisor serve ./my-agent --api-addr :9000

Multiple Policy Files​

--policy takes a single comma-separated value; repeating the flag makes the last occurrence win, not merge:

agentvisor serve ./my-agent \
--policy ./policies/base.yml,./policies/custom.yml

With Environment Variables (.env file)​

# Auto-discover .env in agent directory
agentvisor serve ./my-agent --sandbox=none

# Specify explicit .env file path
agentvisor serve ./my-agent \
--sandbox=none \
--env-files=/path/to/secrets.env

# Multiple .env files (later files override earlier)
agentvisor serve ./my-agent \
--sandbox=none \
--env-files=base.env,secrets.env

Sandboxing stdio MCP Servers​

When your agent uses stdio MCP servers and --sandbox is gvisor or docker, AgentVisor sandboxes each stdio server inside its own mcp-tools container (providing node/npx and python/uvx). The sandbox image is resolved at startup.

--bundle-mcp-tools (recommended for offline/CI environments): extracts the mcp-tools rootfs into a temporary directory before the runtime starts, so no image pull is needed at agent invocation time:

agentvisor serve ./my-mcp-agent --bundle-mcp-tools

mcp.prepull in mav-agent-config.yaml: declares packages to pre-install into the rootfs before startup. This is honored automatically — no extra flag is needed:

# mav-agent-config.yaml
mcp:
prepull:
- manager: npm
package: "@modelcontextprotocol/server-filesystem"

See MCP Gateway: Pre-installing Packages (prepull) and the Configuration Reference: Stdio Sandbox Image for details.

HTTP API​

When running, the server exposes the full HTTP API on the configured --api-addr (default :8090) — threads, runs, state, agents, store, tracing, and system endpoints (health, readiness, metrics, OpenAPI spec, Swagger UI). See the HTTP API Reference for the complete, authoritative endpoint list.

Stopping​

Press Ctrl+C to stop the server. The server:

  1. Stops accepting new requests
  2. Completes in-flight runs
  3. Shuts down guest sandbox
  4. Closes Temporal connection

Environment Variables​

All options can be set via environment variables (see the Env Var column in Options above):

export AGENTVISOR_TEMPORAL_TARGET=localhost:7233
agentvisor serve ./my-agent --sandbox=none

See the Configuration Reference for the full list of configuration keys, environment variables, and defaults — including Temporal, API, sandbox, policy, and logging settings not exposed as CLI flags.

Troubleshooting​

ModuleNotFoundError: No module named 'agentvisor'​

This error occurs when running with --sandbox=none without the SDK installed. See SDK Installation.

Temporal Connection Failed​

Start the required services (from the scaffolded project's compose.yml):

docker compose up -d

See Troubleshooting Guide: Temporal Connectivity for namespace and Temporal Cloud auth issues.

Policy Denied​

See Troubleshooting Guide: Policy Evaluation Errors for debugging steps and the development-only allowall bypass (never use in production).

Docker Image Not Found​

Pull or build the guest image:

# Pull the Python variant (for LangGraph agents)
docker pull ghcr.io/manetu/agentvisor/agentvisor-guest:latest-python

# Or the minimal variant (for exec mode)
docker pull ghcr.io/manetu/agentvisor/agentvisor-guest:latest-minimal

See Also​