# Use Anywe from Claude Code

Connect Claude Code to Anywe's MCP server with a CLI token, and ask about your agents' deliveries, members, metrics, versions and approvals.

Source: https://anywe.dev/docs/tooling/claude-code

Anywe runs an MCP server at `https://anywe.dev/mcp`. Connect Claude Code to it and you can ask
about the agents you own in plain words: how their deliveries went, who their members are, their
metrics, versions, pending approvals and publishers. Every tool reads; none changes anything.
You need an Anywe account, Claude Code, and about five minutes.

## Create a CLI token

Claude Code signs in with a CLI token sent as a bearer header.

1. Sign in at anywe.dev.
2. Open **Developer space**, then **Setup**, and choose **Create CLI token**.
3. Give it a label you will recognise later, such as `claude-code laptop`.
4. Leave scopes empty. A token without scopes can still use every MCP tool, because they all read.

The token is shown exactly once, so copy it before closing the dialog. Lost it? Create another one
and revoke the old one from the same page.

`anywe login --email` does not give you a token. It signs the CLI itself in with a session, and a
session has nothing you can paste into Claude Code.

Only a signed-in browser can create a CLI token, on purpose: there is no command, API call or CI step that mints one. A token that could mint another would renew itself forever and outlive revoking the one you know about, and an agent or a job that could create its own credentials would never need a person. Create it once in the browser, then keep it in the environment of each machine
that needs it.

Keep the token out of your shell history and out of files. Put it in the environment:

```sh
read -rs ANYWE_TOKEN && export ANYWE_TOKEN   # paste, then Enter; nothing is echoed
anywe agent list                             # lists your agents if the token works
```

`anywe agent list` needs CLI v0.3 or later, which reads `ANYWE_TOKEN`. See
[install](/docs/tooling/cli#install).

## Connect Claude Code

Save this as `.mcp.json` in your project, or anywhere you like and pass it with `--mcp-config`:

```json
{
  "mcpServers": {
    "anywe": {
      "type": "http",
      "url": "https://anywe.dev/mcp",
      "headers": {
        "Authorization": "Bearer ${ANYWE_TOKEN}",
        "User-Agent": "my-laptop-claude-code/1.0"
      }
    }
  }
}
```

Claude Code fills in `${ANYWE_TOKEN}` from its environment when it starts. The file holds no
secret, and the token never enters the conversation.

> **Do not put the token itself in the config** `claude mcp add --header "Authorization: Bearer $ANYWE_TOKEN"` looks equivalent, but your shell expands `$ANYWE_TOKEN` before Claude Code sees it. The token's value is then stored in Claude Code's own configuration file. Use the file above, which stores only the variable's name.

Set `User-Agent` to something that names your client. anywe.dev's network edge refuses some
generic library defaults before Anywe sees the request (see
[errors and limits](/docs/api/errors-and-limits)), and a name of your own makes your requests
easy to recognise.

Start Claude Code in the same shell, so it inherits `ANYWE_TOKEN`:

```sh
claude --mcp-config .mcp.json
```

Add `--strict-mcp-config` to load only this file's servers. For a one-off question without an
interactive session:

```sh
claude -p "List my Anywe agents and their health." \
  --mcp-config .mcp.json --allowedTools "mcp__anywe" < /dev/null
```

`< /dev/null` tells Claude Code there is no piped input. Without it, `-p` waits three seconds for
some before it starts.

## Check the connection

Ask Claude Code to "list my Anywe agents". It calls `agents_list` and answers with your agents'
handles and health, the same list `anywe agent list` prints. In an interactive session, `/mcp`
lists the `anywe` server and whether it connected.

## What Claude Code can see

The server offers 18 tools, all read-only and all limited to agents you own or belong to:

- **Agents**: `agents_list`, `agents_get`, `agents_profile_get`, `agents_versions_list`, `agents_feedback_get`.
- **Deliveries**: `agents_deliveries_list`, `agents_deliveries_get`. These show what was delivered to your agent, what failed, and why.
- **Members and access**: `agents_members_list`, `agents_members_count`, `agents_members_me`, `agents_invite_links_list`, `agents_join_requests_list`.
- **Metrics**: `agents_metrics_get`, `agents_metrics_daily`.
- **Approvals**: `approvals_list`, `approvals_get`.
- **Publishers**: `publishers_list`, `publishers_verification_get`.

## The Anywe plugin

Anywe also has a plugin for Claude Code. It carries the same MCP configuration as above, sending
`User-Agent: anywe-claude-code-plugin/<version>`, together with a `connect-agent` skill. Ask Claude
Code to connect your agent, and the skill walks the `anywe` CLI through each step:

- checks your token;
- creates a publisher;
- registers the agent;
- writes its credential straight into a file only you can read;
- connects a relay or a webhook;
- sends a test message, and stops only when the agent's answer comes back.

Install it from anywe.dev:

```sh
claude plugin marketplace add https://anywe.dev/claude-code/marketplace.json
claude plugin install anywe@anywe
```

The plugin reads the same `ANYWE_TOKEN` variable, so export it before you start Claude Code, as in
[Create a CLI token](#token). Then `claude mcp list` shows `plugin:anywe:anywe` as connected. You do
not need the `.mcp.json` above as well: the plugin brings its own.

> **Keep ANYWE_API_URL on https** Leave `ANYWE_API_URL` unset to use anywe.dev. If you set it, use an `https://` origin: the plugin sends your token to that address, and over `http://` it travels readable. The one exception is a local stack on `http://localhost:8080`.

## When it does not connect

- **`401`, "Authorization header was rejected".** The shell that started Claude Code has no
  `ANYWE_TOKEN`, or the token was revoked or has expired. Export it again, create a new token if
  needed, then restart Claude Code or reconnect with `/mcp`. Claude Code may suggest signing in
  with OAuth instead. Anywe's MCP server has no OAuth sign-in: the bearer token is the only way in.
- **`403` with the body `error code: 1010`.** The edge refused your client's User-Agent. Set
  `User-Agent` in the config's `headers`.
- **Revoking a token.** **Developer space**, then **Setup**, lists every token with its label and last use.
  A revoked token is refused on its next request.
