Guides
Programmatic control for agents

Programmatic control for agents

TrueTick is built to be driven by software, not just clicked in a panel. AI agents, Discord bots, and automation scripts get the same surface: full server lifecycle, RCON, files, backups, and — the part that matters for autonomous decisions — honest live metrics you can actually trust.

Why it fits agents

  • Metered + scale-to-zero means an agent can create servers liberally and only pay for the minutes they run. Spin one up, do the work, tear it down — see Ephemeral test server.
  • Real TPS/MSPT means an agent can make data-driven decisions (restart? scale? alert?) instead of trusting a fabricated green dashboard.
  • Scoped keys let you give an agent exactly the capabilities it needs and nothing more — e.g. a read-only monitoring bot gets servers:read only. See Authentication.

Two ways to connect

Direct API / SDK

Give the agent a scoped ttk_ key and let it call the API (directly or via the SDK). A minimal autonomous loop:

import { TrueTickClient } from "@truetick/sdk";
const client = new TrueTickClient(); // TRUETICK_API_KEY (scoped to what the agent may do)
 
async function ensureHealthy(id: string) {
  const s = await client.servers.get(id);
  if (s.state !== "running") {
    await client.servers.start(id);              // wake it
    return;
  }
  const m = await client.servers.metrics(id);
  if (m.live && m.tps < 18) {
    await client.console.run(id, "say performance degraded — restarting");
    await client.servers.restart(id);             // act on a *real* signal
  }
}

MCP (Model Context Protocol)

For LLM agents, the @truetick/mcp server exposes the API as tools an assistant can call directly — create_server, start_server, run_command, get_server_metrics, and more. Point the MCP server at a scoped key and your agent can manage servers in natural language. See the MCP library page for the tool catalog and setup.

Patterns that work well

  • Provision-test-destroy — create an ephemeral server, run a task, delete it in a finally.
  • Health-gated actions — read metrics and only act when live is true and TPS crosses a real threshold. Don't act on stale/empty metrics (honest empty states exist precisely so you don't).
  • RCON for structured controlconsole.run(id, "...") for arbitrary commands; structured player management (whitelist/op/ban/kick) has dedicated servers:write endpoints in the API Reference.
  • Event push over polling — configure a Discord alert webhook per server so the platform notifies you on TPS drops instead of you polling.

Offline-friendly behavior

Because servers are scale-to-zero, a hibernated server still responds to a server-list ping (with a MOTD + sleep line) and wakes automatically when a player joins — no agent needs to be online to bring it up for players. Your agent can stay offline and let wake-on-join handle the player path, then reconcile state on its next run. When the agent does need a server up on its own schedule, an explicit start triggers the same boot.

⚠️

Keys are barred from account/billing/admin operations (signup, top-ups, key management, admin RPCs) — see what keys can't do. Design your agent around the per-account surface; do account-level actions in a human dashboard session.