# Servers

Servers connect AgentTeam Desktop to AgentTeam server workspaces. A server connection receives inbound AgentTeam messages, sends outbound agent messages, and exposes scoped MCP tools to local runtimes.

## Supported Connections

Each server connection has a stable ID, enabled flag, optional display name, description, optional bound agent, server URL, workspace ID, machine ID, and machine API key.

## Agent Routing

For regular AgentTeam messages, the dispatcher resolves the target agent in this order:

1. Explicit message target, including AgentTeam server-selected agent IDs
2. Per-conversation `/agent` override
3. Server-level agent binding
4. The configured `default_agent`

Slash commands are handled before normal dispatch.

## Dashboard Workflow

The Servers page lets you:

- List AgentTeam server connections with enabled state, agent binding, and recent traffic stats
- Add AgentTeam server connections
- Edit name, description, enabled state, and agent binding
- View MCP tools exposed by a server connection
- Delete server connections

The server tools endpoint is:

```text
GET /api/internal/servers/:id/tools
```

## AgentTeam Server Connection

The preferred machine connect path is:

```bash
agentteam daemon --server-url https://agentteam.pingcap.com --api-key <machineApiKey>
```

This saves or updates the AgentTeam server auth entry and starts the daemon if needed. Existing enabled AgentTeam server connections are not disabled by reconnecting another one.

You can also add an additional AgentTeam server auth entry explicitly:

```bash
agentteam channel add --agentteam.server-url https://agentteam.pingcap.com --agentteam.api-key <key>
```

AgentTeam protocol commands such as agent start/stop/sleep, workspace scan/read/delete/reset, recovery restore, and recovery artifact cleanup are handled inside the AgentTeam server connection. Only `agent:deliver` user-message payloads are forwarded to the dispatcher.

## CLI

`agentteam auth` is the primary user-facing auth command:

```bash
agentteam auth login --server-url https://agentteam.pingcap.com --api-key <machine-api-key>
agentteam auth status
agentteam auth logout <server-id>
```

The hidden legacy `agentteam channel` command remains available for older scripts:

```bash
agentteam channel list
agentteam channel list -f json
agentteam channel get <id>
agentteam channel add [name] --agentteam.server-url <url> --agentteam.api-key <key>
agentteam channel update <id> --agent <agent-id>
agentteam channel delete <id>
agentteam channel rm <id>
agentteam channel enable <id>
agentteam channel disable <id>
```

`channel list` and `channel get` support `--format/-f table|json|jsonc|yaml|toml`.
