> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.basement.chat/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.basement.chat/_mcp/server.

# Connect an agent

An agent connects to the Gateway with the Model Context Protocol (MCP). You create a key for the agent in Basement and paste it into the agent's MCP settings.

### Create a key

In Basement, open **Agents** and click **Connect agent**. Keep **AI agent** selected, give the agent a name, and select its access level.

The access level decides what the agent can read, write and use. If you are not sure, start with **Researcher**: it reads everything in Basement and writes nothing. See [Keys and access levels](/concepts/keys-and-access-levels).

Basement shows the key one time. Copy it now.

### Add the Gateway to your agent

Paste the key into the MCP settings of your agent. Most MCP clients read a JSON file like this one:

```json
{
  "mcpServers": {
    "basement": {
      "url": "https://mcp.basement.chat/mcp",
      "headers": { "Authorization": "Bearer bsmt_your_key" }
    }
  }
}
```

In Claude Code, one command does the same:

```bash
claude mcp add --transport http basement https://mcp.basement.chat/mcp \
  --header "Authorization: Bearer bsmt_your_key"
```

For other clients, and for clients that sign in with OAuth, see [Connect an MCP client](/mcp/connect-an-mcp-client).

### Check the connection

Ask the agent to call the `whoami` tool. The answer names your organization and the key. Then ask it to list your documents.

## What happens next

* The agent sees only the tools its access level allows. See [Tools](/mcp/tools).
* Each call the agent makes is in **Agents**, **Activity**. See [Activity log](/concepts/activity-log).
* To stop an agent, open it in **Agents**, **Connected** and click **Revoke**. The key stops working immediately.