From 0 to Production AI Agent: A Complete Deployment Guide

July 24, 2026 TormentNexus tutorial

From 0 to Production AI Agent: A Complete Deployment Guide

Deploy your first production AI agent in under an hour. This step-by-step guide walks you through installing TormentNexus, configuring MCP servers, and connecting your LLM provider for self-hosted AI that runs at scale.

Why Most AI Agent Deployments Fail Before They Start

The graveyard of abandoned AI projects is enormous. Studies from Gartner suggest that roughly 85% of AI projects never make it to production. The reasons are painfully familiar: configuration nightmares, brittle tool integrations, vendor lock-in with hosted platforms, and a general inability to move past the "works on my laptop" stage.

The core problem isn't model quality anymore. It's operational infrastructure. You can fine-tune a model, write a brilliant system prompt, and build clever tool-use chains — but the moment you need to handle concurrent requests, manage authentication, orchestrate multiple tool servers, and deploy on your own infrastructure, everything falls apart.

This is precisely the gap TormentNexus was built to fill. It provides a hardened, self-hosted runtime specifically designed for AI agent workloads with full MCP (Model Context Protocol) support. No managed service dependency. No opaque abstraction layers. Just a clean, fast, production-grade platform you can run on a $20/month VPS or your own bare-metal cluster.

In this guide, you'll go from an empty server to a fully deployed, production-ready AI agent system. Every step is concrete. Every command is tested. Let's build.

Step 1: Install TormentNexus on Your Server

TormentNexus is distributed as a single binary with zero external dependencies. You don't need Docker, Node.js, Python, or any runtime pre-installed. On a fresh Ubuntu 22.04 LTS box, the entire installation takes about 90 seconds.

SSH into your target server and run the installer:

curl -fsSL https://install.tormentnexus.site | bash

This downloads the latest stable release (currently v2.4.1) for your architecture, verifies the SHA-256 checksum against the published public key, and installs the tormentx binary to /usr/local/bin/. You'll see output like this:

▸ Detecting platform: linux/amd64
▸ Downloading tormentx v2.4.1 (14.2 MB)
▸ Verifying checksum... OK
▸ Installing to /usr/local/bin/tormentx
▸ Installation complete. Run 'tormentx init' to start.

Verify the installation:

tormentx --version
# tormentx v2.4.1 (built 2025-01-14)

Now initialize your project workspace. The init command scaffolds a complete project directory with sensible defaults:

mkdir ~/my-ai-agent && cd ~/my-ai-agent
tormentx init

This generates the following structure:

my-ai-agent/
├── tormentx.toml          # Main configuration file
├── agents/
│   └── default.toml       # Agent definition
├── mcp-servers/
│   └── example.toml       # MCP server configurations
├── secrets/               # Encrypted secrets (gitignored)
└── logs/                  # Runtime logs

The tormentx.toml file is your central configuration hub. Let's walk through the key sections before we wire anything together.

# tormentx.toml - Core Configuration
[runtime]
workers = 4                  # Number of concurrent agent workers
max_concurrent_requests = 128 # Hard concurrency cap
request_timeout_seconds = 120
log_level = "info"            # Options: debug, info, warn, error

[server]
host = "0.0.0.0"
port = 8420
metrics_port = 8421            # Prometheus-compatible metrics endpoint
enable_cors = false            # Disable in production

[storage]
backend = "sqlite"             # Options: sqlite, postgres
path = "./data/agent.db"       # Only used with sqlite backend

The default SQLite backend is suitable for most workloads handling fewer than 10,000 requests per day. If you're anticipating heavier throughput, switch to PostgreSQL by setting backend = "postgres" and adding a connection string under [storage.connection].

Step 2: Configure Your First MCP Server

The Model Context Protocol (MCP) is the backbone of tool-use in modern AI agents. It defines a standard way for LLMs to discover and invoke external tools, query data sources, and interact with APIs. TormentNexus includes a built-in MCP server runtime, meaning you don't need a separate process for each tool server.

Open mcp-servers/example.toml and replace its contents with a real configuration. We'll set up two tool servers: one for file system operations and one for a custom database query tool.

# mcp-servers/filesystem.toml
[mcp_server]
name = "filesystem"
transport = "stdio"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/home/ubuntu/shared-data"]
env = {}

[mcp_server.resources]
enabled = true
max_resource_size_bytes = 10485760  # 10 MB limit per resource read

The stdio transport means TormentNexus spawns the MCP server as a child process and communicates over stdin/stdout. For remote or network-attached MCP servers, you can use the sse (Server-Sent Events) transport instead:

# mcp-servers/remote-tools.toml
[mcp_server]
name = "remote-database"
transport = "sse"
url = "https://tools.mycompany.internal:9300/mcp"
headers = { "Authorization" = "Bearer {{secret:DB_MCP_TOKEN}}" }
reconnect_interval_ms = 5000
max_reconnect_attempts = 10

Notice the {{secret:DB_MCP_TOKEN}} syntax. TormentNexus has a built-in secrets manager. Store your token with:

tormentx secrets set DB_MCP_TOKEN "eyJhbGciOiJIUzI1NiIs..."

Secrets are encrypted at rest using AES-256-GCM with a machine-derived key. They never appear in configuration files in plaintext, and they're excluded from any backup or export operations.

Now register your MCP servers in the main configuration:

# Add to tormentx.toml
[mcp_servers]
config_dir = "./mcp-servers"
auto_discover = false          # Set true to auto-load all .toml files in dir
enabled = ["filesystem", "remote-database"]

Start TormentNexus in development mode to verify your MCP servers launch correctly:

tormentx dev --verbose

You'll see startup logs confirming each MCP server process was spawned and its tool registry was loaded:

[INFO] MCP server 'filesystem' started (pid 44021, transport: stdio)
[INFO]   └─ 4 tools registered: read_file, write_file, list_directory, search_files
[INFO]   └─ 1 resources registered: filesystem:///
[INFO] MCP server 'remote-database' connected (transport: sse, url: https://tools.mycompany.internal:9300/mcp)
[INFO]   └─ 3 tools registered: query_table, describe_schema, execute_migration

Seven tools across two servers are now available to your agents. Let's wire them up to an LLM.

Step 3: Connect Your LLM Provider

TormentNexus supports any OpenAI-compatible API endpoint, which covers OpenAI, Anthropic (via their OpenAI-compatible relay), local models through Ollama, vLLM, LM Studio, and dozens of other providers. The configuration is provider-agnostic.

Create or edit your agent definition at agents/default.toml:

# agents/default.toml

[agent]
name = "data-assistant"
description = "Production data assistant with file system and database access"
version = "1.0.0"

[agent.llm]
provider = "openai"
model = "gpt-4o"
api_base = "https://api.openai.com/v1"  # Override for local/proxy endpoints
api_key = "{{secret:OPENAI_API_KEY}}"
temperature = 0.1
max_tokens = 4096
context_window = 128000

[agent.llm.retry]
max_attempts = 3
backoff_base_ms = 1000
backoff_max_ms = 10000

[agent.system_prompt]
file = "./prompts/system.md"
max_prompt_tokens = 8000

[agent.tools]
allowed_servers = ["filesystem", "remote-database"]
allowed_tools = []                  # Empty = all tools allowed
tool_timeout_seconds = 30
max_tool_calls_per_turn = 10

Store your API key securely:

tormentx secrets set OPENAI_API_KEY "sk-proj-xxxxxxxxxxxx"

If you're running a local model instead, the configuration looks nearly identical:

[agent.llm]
provider = "ollama"
model = "llama3.1:70b"
api_base = "http://localhost:11434/v1"
api_key = "not-needed"
temperature = 0.3
max_tokens = 8192
context_window = 131072

Write a system prompt that tells the agent what it can do and how it should behave. Create prompts/system.md:

You are a data assistant with access to the company file system and PostgreSQL database.

## Available Capabilities
- Read and write files in /home/ubuntu/shared-data/
- Query the company database for sales, inventory, and customer data
- Describe database schemas on demand

## Rules
1. Always confirm destructive operations (write_file, execute_migration) with the user before executing.
2. For database queries, prefer read-only SELECT statements. Never run DROP or TRUNCATE.
3. When results exceed 50 rows, summarize them instead of returning raw data.
4. Cite file paths and query results inline when referencing them in responses.

TormentNexus templates the system prompt at runtime, meaning you can use Jinja2-style syntax if you need dynamic content injection (current date, user context, etc.).

Step 4: Deploy to Production

Development mode is great for testing, but production requires a hardened setup. TormentNexus provides a serve command specifically designed for always-on deployments with proper signal handling, graceful shutdown, and automatic log rotation.

Switch your configuration to production settings:

# Update tormentx.toml for production
[runtime]
workers = 8
max_concurrent_requests = 256
request_timeout_seconds = 180
log_level = "warn"

[server]
host = "0.0.0.0"
port = 8420
metrics_port = 8421
enable_cors = false

[server.tls]
enabled = true
cert_path = "/etc/letsencrypt/live/agent.yourdomain.com/fullchain.pem"
key_path = "/etc/letsencrypt/live/agent.yourdomain.com/privkey.pem"

Launch with the production command:

tormentx serve --config ./tormentx.toml

For automatic restarts and process supervision, create a systemd service:

# /etc/systemd/system/agent.service
[Unit]
Description=TormentNexus AI Agent
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/my-ai-agent
ExecStart=/usr/local/bin/tormentx serve --config ./tormentx.toml
Restart=always
RestartSec=5
Environment=TORMENTX_ENV=production

# Security hardening
NoNewPrivileges=yes
ProtectSystem=strict
ReadWritePaths=/home/ubuntu/my-ai-agent/data /home/ubuntu/my-ai-agent/logs

[Install]
WantedBy=multi-user