Skip to content

Cloud agents

Cloud agents run in temporary containers. To connect one to Mossbear, give the container a CLI token, install Mossbear when the container starts, and allow it to reach your dashboard.

This is the part that differs from setup on your laptop. A cloud container cannot open a browser and complete mossbear login, so it needs a token in an environment variable.

  1. Open Machines in the Mossbear dashboard.
  2. Under Add a machine, enter a name for the environment, such as Claude cloud or Codex cloud.
  3. Select Create token.
  4. Copy the token now. Mossbear will not show it again.
  5. In your cloud agent’s settings, add it as:
Terminal window
MOSSBEAR_TOKEN=your-token

Do not put the token in your repository or setup script. It grants access to your Mossbear account. Use a separate token for each cloud environment so you can revoke one without disconnecting your other machines.

Choose the service you use.

At claude.ai/code, open the environment selector. Create an environment, or open the settings for an existing one.

Add MOSSBEAR_TOKEN to Environment variables. Paste only the token value after =. Do not add quotes.

Claude can read ordinary environment variables. Create a token just for this environment and disconnect it from Machines when you no longer use it.

Set network access to Custom and add:

app.mossbear.io

Keep Also include default list of common package managers enabled so npm remains available.

Paste this into Setup script, including the #!/bin/bash first line:

#!/bin/bash
npm install -g mossbear
mossbear init --no-prompt --platform claude_code --pull-guides || true
mossbear doctor || true

init adds the Claude Code hooks and pulls the guides in your default bundle. Commit the generated .claude/settings.json so the hooks are present in future clones.

The setup script runs when Claude builds the environment. Mossbear’s SessionStart hook updates the CLI and refreshes your guides when a later session reuses that environment.

Start a session and read the setup log. mossbear doctor should report a healthy dashboard connection. You can also ask Claude to run:

Terminal window
mossbear status
mossbear guides active

If the install works but the dashboard connection fails, check the allowed host before replacing the token. Package-manager access and dashboard access are separate settings.

The token lets the CLI pull your Mossbear content and upload session activity. Mossbear reads it from MOSSBEAR_TOKEN; it does not need to save the value in ~/.mossbear/config.json.

Treat the token like a password:

  • keep it in the cloud service’s secret or environment settings;
  • never commit it;
  • use one token per environment;
  • disconnect it from Machines when that environment is retired or exposed.

You do not need an OpenAI, Anthropic, or OpenRouter API key in the container. The Mossbear dashboard performs grading after the CLI uploads the session.

Run this first:

Terminal window
mossbear doctor
  • The token is rejected. Confirm that you copied the full token. Generate a replacement only if the old token is unavailable or revoked.
  • The request is refused or reports a proxy. Add the dashboard host to the cloud environment’s network allowlist.
  • Guides are empty. Check that the guides belong to the default bundle, then run mossbear refresh.
  • Activity stays pending. The hooks are recording activity, but the agent phase cannot upload it. Check that the token is available during that phase and that POST requests to the dashboard are allowed.

For more diagnostic steps, see Troubleshooting.

On Claude Code on the web, once mossbear doctor is clean in the container, run a small task and find its session in your dashboard, as in Run a task and find its result. On Codex cloud the guides are delivered, but a session is not expected to appear until the hooks question under Session grading is settled. Every command and flag used above is in the CLI reference.