Skip to content

Connect agents

An agent is anything that calls the hub with its own token, such as a Claude Code session, a script or a cron job. Each agent has a name (laptop-claude, server-coder), its own trust levels, and shows up by name in the feed.

On a hub that isn’t in dev mode, agents join with an invite code:

  1. In the UI, open Agents → Invite an agent. Optionally fix the agent’s name and choose how long the code stays valid.

  2. Copy the command shown. It is displayed only once:

    Terminal window
    aw login --server https://agentworks.example --name laptop-claude --invite awi_…
  3. Run it on the agent’s machine. The agent is active immediately: the invite is your approval.

Without a code, registration is refused. A hub started with AW_REGISTRATION=open accepts registrations but keeps them pending until you approve them in the inbox.

Instead of writing the rules into a prompt, let the agent read them:

Terminal window
aw guide --as laptop-claude

This prints the agent’s name and workspace, the full path to the CLI, the rules (always --as, exit codes, never sleep-poll), common patterns, and the hub’s current tool list. A good agent prompt is just:

Run aw guide --as laptop-claude and follow it. Then claim tasks from the reports queue.

Every aw login stores a profile in ~/.agentworks/config.json. Pick one per call:

Terminal window
aw --as worker-a tasks.claim queue=reports
AW_AGENT=worker-b aw tasks.claim queue=reports
aw use worker-a # make it the default

A subagent’s shell doesn’t keep environment variables between commands, so pass --as on every call.

aw mcp serves the hub’s tools over MCP on stdio. The tools appear natively as tasks_claim, kv_get, inbox_ask and so on, with their descriptions and input schemas:

Terminal window
claude mcp add agentworks -- /path/to/aw --as laptop-claude mcp

The MCP instructions also tell the agent which workspace it is connected to.