> For the complete documentation index, see [llms.txt](https://docs.p0.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.p0.dev/integrations/resource-integrations/agentic-gateway/using-mcp-servers.md).

# Use MCP servers with Claude Code

After an admin [configures an MCP server](/integrations/resource-integrations/agentic-gateway/mcp-server.md) behind the [P0 AI Gateway](/readme/agentic-control-plane.md), each developer connects their own [Claude Code](https://docs.claude.com/en/docs/claude-code) client to it with the P0 CLI. Connecting registers a per-user OAuth client and signs you in through P0, so your agent reaches the server through the gateway and every tool call is authenticated and checked against policy.

{% hint style="info" %}
Connecting is per user and per machine. Everyone who wants to use a server must run these steps on their own machine. Configuring a server behind the gateway is an admin task. It doesn't connect anyone's client.
{% endhint %}

## Prerequisites

* The [P0 CLI installed](/p0-cli/installing-p0-cli.md) and logged in (`p0 login`).
* [Claude Code](https://docs.claude.com/en/docs/claude-code) installed, with the `claude` binary on your `PATH`.
* At least one [MCP server configured](/integrations/resource-integrations/agentic-gateway/mcp-server.md) behind the gateway.

## List the available servers

List the MCP servers configured behind the gateway and available to you, and note the key of each one you want:

```bash
p0 claude mcp list
```

The output shows each server's key and gateway URL. See [`p0 claude mcp list`](/p0-cli/p0-commands-and-usage/p0-claude-mcp-list.md) for details.

## Add each server

Connect Claude Code to a server by its key. Run the command once per server you want to use:

```bash
p0 claude mcp add aws
p0 claude mcp add gcs
```

See [`p0 claude mcp add`](/p0-cli/p0-commands-and-usage/p0-claude-mcp-add.md) for all flags and options.

### Choose a scope

The `--scope` flag maps to Claude Code's own configuration scopes, which control **which of your projects** can see the server. When you omit `--scope`, Claude Code applies its default, `local`.

| Scope             | Where the server is available                                                                                                                    |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `local` (default) | Only in the current project directory, and only to you.                                                                                          |
| `user`            | Across all your projects on this machine, and only to you.                                                                                       |
| `project`         | To everyone who works in this project, through a `.mcp.json` committed to the repository. Each user still authenticates through P0 individually. |

To make a server available in every project on your machine, add it with `--scope user`:

```bash
p0 claude mcp add aws --scope user
```

## Connect and authenticate

1. Open Claude Code.
2. Run `/mcp`.
3. Connect and authenticate to the server. You sign in through P0.

From then on, your agent's tool calls are enforced and audited by the gateway.

## Verify

Run `/mcp` in Claude Code and confirm the server shows as connected. Your agent can now call the server's tools; the gateway authenticates and checks each call against policy before it reaches the upstream server.

## Switch to a different P0 user

The P0 CLI stores all your local state under `~/.p0`: your identity and config, the credential cache, and the OAuth client it registered for MCP (`~/.p0/claude/mcp-client.json`). To operate as a different P0 user, delete this directory, then sign in and reconnect:

```bash
rm -rf ~/.p0
p0 login
p0 claude mcp add <server> --scope user
```

{% hint style="info" %}
`p0 logout` clears your credentials but keeps the cached MCP OAuth client, so the next `p0 claude mcp add` reuses the previous client. Delete `~/.p0` to force the CLI to register a fresh client for the new user.
{% endhint %}

## Related

* [`p0 claude mcp list`](/p0-cli/p0-commands-and-usage/p0-claude-mcp-list.md): list the servers available to you.
* [`p0 claude mcp add`](/p0-cli/p0-commands-and-usage/p0-claude-mcp-add.md): connect Claude Code to a server.
* [MCP server](/integrations/resource-integrations/agentic-gateway/mcp-server.md): configure a server behind the gateway (admin).
