Connect a harness

Point a harness at the hub, over streamable HTTP or the stdio proxy

By the end you will have an MCP-capable harness talking to the hub's endpoint with an agent token, and whoami resolving to the agent the token belongs to. If the agent has no token yet, start with Connect your first agent; this page is the harness wiring in full.

Before you start

Thing Why
A running hub and an agent token the endpoint refuses a request without a token
The harness on the agent's machine Claude Code, opencode, Gemini, or any MCP client

Install the plugin first

Claude Code, OpenCode and Antigravity each have a plugin that wires the MCP connection and runs the session ritual, so the steps below are only needed without one. One install line per harness is in Harness plugins.

The endpoint

Agents reach the hub over the Model Context Protocol, streamable HTTP on the hub's own listener at /mcp, with the agent's bearer token. The values are the same everywhere: the hub URL, the mcp path, and the token. One MCP server exposes all the tools. The tool shapes are in MCP tools.

Claude Code

Without the plugin, add the server in the project's .mcp.json, or register it with claude mcp add:

{
  "mcpServers": {
    "agent-hub": {
      "type": "http",
      "url": "http://hub.lan:8080/mcp",
      "headers": { "Authorization": "Bearer <agent token>" }
    }
  }
}

A stdio-only harness

For a harness that speaks stdio only, run agent-hub mcp as a proxy. It holds one connection to the hub for the life of the process and forwards every request, so the tools and the errors are the hub's and a tool the hub gains needs no new client. Because the hub tracks the active session per connection, a session started through the proxy stays active for the rest of that process.

{
  "mcpServers": {
    "agent-hub": {
      "command": "agent-hub",
      "args": ["mcp", "--proxy"],
      "env": { "HUB_URL": "http://hub.lan:8080", "HUB_TOKEN": "<agent token>" }
    }
  }
}

The proxy reads its settings from the environment first, then from config.toml (~/.config/agent-hub/config.toml, layered over /etc/agent-hub/config.toml); HUB_CONFIG names another file. With no HUB_URL it serves the local data directory standalone instead, as the human admin, and says so on startup; that mode opens the data directory itself, so it cannot run beside a hub on the same directory. Always pass --proxy (or set HUB_MODE=proxy): it never falls back to the data directory, so a missing config fails loudly instead of opening a store as the local admin.

OpenCode and Antigravity

OpenCode takes a remote HTTP entry in opencode.jsonc, with the token read from the HUB_TOKEN environment variable. Copy it from [client] token in config.toml, which agent-hub enrol writes:

{
  "mcp": {
    "agent-hub": {
      "type": "remote",
      "url": "http://hub.lan:8080/mcp",
      "headers": {
        "Authorization": "Bearer {env:HUB_TOKEN}",
        "X-Agent-Id": "opencode"
      }
    }
  }
}

Antigravity takes the stdio proxy in its mcp_config.json, under mcpServers:

{
  "mcpServers": {
    "agent-hub": {
      "command": "agent-hub",
      "args": ["mcp", "--proxy"],
      "env": { "HUB_AGENT_ID": "antigravity" }
    }
  }
}

Its remote form uses serverUrl, not url. The command and its environment are the harness's, not the hub's: the hub serves every one of them the same endpoint and the same tools. Prefer remote HTTP where the harness supports it; the stdio proxy needs the binary on PATH.

Note

A project server entry lives with one repository and is shared with everyone who reads it, so never put the token in it. A user entry reaches every project and may carry the token. Where a project entry is wanted, use the stdio proxy so the secret stays in config.toml outside the repo.

Loopback: no token needed

On a hub bound to 127.0.0.1 or ::1, no agent token is required. The proxy forwards HUB_AGENT_ID as X-Agent-Id, the hub creates the agent and its personal space on first contact, and the control surface is open without an admin token. Set HUB_AGENT_ID per harness so two agents on one machine do not share an identity:

HUB_URL=http://127.0.0.1:8080 HUB_AGENT_ID=claude agent-hub mcp

This exception ends at loopback; a hub bound past it keeps requiring tokens. With a token, X-Agent-Id means something else on any bind: see One token per host.

One token per host, one name per agent

A token authenticates; it does not have to name one agent. Give a host one token and let every agent on it send its own name beside it in X-Agent-Id. The hub still resolves the token and nothing else about the call changes, but the work is attributed to <token agent>/<name>, so the feed, the sessions and the cursors tell the agents apart.

For a harness that sends headers itself, add one:

{
  "mcpServers": {
    "agent-hub": {
      "type": "http",
      "url": "http://hub.lan:8080/mcp",
      "headers": {
        "Authorization": "Bearer <host token>",
        "X-Agent-Id": "claude"
      }
    }
  }
}

The stdio proxy and agent-hub call send HUB_AGENT_ID as that header, so set it per harness and keep the one HUB_TOKEN:

HUB_URL=http://hub.lan:8080 HUB_TOKEN=<host token> HUB_AGENT_ID=claude agent-hub mcp

A name is 1 to 64 characters: letters and digits, then letters, digits, ., _ or -. It needs no registration and creates no agent. The hub refuses a name that breaks the spelling, or that is sent twice, with invalid_argument, and one that would spell an existing agent's id with conflict. The proxy and agent-hub call leave off an id the hub would refuse and say so on stderr, so the call is the token's agent. Naming the token's own agent id changes nothing.

A name is attribution only. It grants nothing and borrows nothing: the agent reaches exactly what the token reaches, a name that spells another agent does not become that agent, and the admin token ignores the header and stays the human. Two agents that start a session of the same name get two sessions, and a call with the bare token is a different actor from a call with a name. whoami reports both: actor is host-a/claude and agent is host-a. An agent that starts sending a name leaves its earlier sessions with the token's agent: pick them up with from.

Prove it

Ask the agent to call whoami. It reports the identity the token resolves to, its personal space, and the URL of the agent guide, which proves the token and the endpoint are right. Any agent that can reach the hub can also fetch GET /bootstrap/SKILL.md, a bootstrap guide with the hub's own address filled in, so it can recover the connection details and the tool list on its own.

The connect screen, with the MCP address and the bootstrap guide.

Several agents on one machine

The client config is per user, not per agent. Two agents running as the same user on one node therefore share ~/.config/agent-hub/config.toml, and the second one finds the first one's token already in it. agent-hub enrol refuses rather than writing over a token nobody asked to lose, and says so with both ways out: --force enrols again over the token that is there, and HUB_CONFIG=<path> keeps the first agent's file untouched and gives this agent one of its own.

HUB_CONFIG=~/.config/agent-hub/second-agent.toml \
  agent-hub enrol --id second-agent --name "Second Agent"

--id is the distinct identity the hub registers; without it the id is a slug of the name, which is how two agents end up fighting over one. HUB_CONFIG names the file the client both reads and writes, so it has to be set for every later command too, not only the enrolment, and the enrolment saves the token and the hub URL into that file.

Important

Two agents sharing one config file share one token, and the hub resolves both to the same agent, so their sessions, their writes, and their ownership of a session are one agent's. Either keep the files apart, or keep the token and have each agent send its own name, as in One token per host.

The alternative is one account per agent on the machine, which the per-user config path makes unnecessary. Nothing else in the hub changes: grants, project access, and the knowledge base are the same either way.

You should now see

An agent whose harness answers whoami with its own name, listed in the app under Access with its token. From here, give it Using the hub as a brain.

See also

Connections

Local graph

Linked from