> 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/p0-cli/p0-commands-and-usage/p0-claude-mcp-add.md).

# p0 claude mcp add

### **Overview** <a href="#overview" id="overview"></a>

`p0 claude mcp add` connects a [Claude Code](https://docs.claude.com/en/docs/claude-code) client to an MCP server that is gated by the [P0 AI Gateway](/readme/agentic-control-plane.md). It registers (or reuses) a P0 OAuth client for this machine, resolves the server's gateway URL from your P0 tenant, and writes the server into your Claude Code MCP configuration, so Claude Code authenticates through P0, and every tool call it makes is governed by policy and recorded.

***

### **Prerequisites** <a href="#prerequisites" id="prerequisites"></a>

* Logged into the P0 CLI (`p0 login`).
* [Claude Code](https://docs.claude.com/en/docs/claude-code) installed, with the `claude` binary on your `PATH`.
* The MCP server configured behind the gateway and available to you. See the [Agentic Gateway integration](/integrations/resource-integrations/agentic-gateway.md), and run `p0 claude mcp list` to see the servers you can add.

***

### **Syntax & Flags** <a href="#syntax-and-flags" id="syntax-and-flags"></a>

```bash
p0 claude mcp add <server> [-s|--scope <local|user|project>] [--callbackPort <port>]
```

* **`<server>`** (required): the MCP server key, as configured behind the gateway (for example, `aws`). Run `p0 claude mcp list` to see the available keys.
* **`-s`, `--scope <local|user|project>`**: the Claude Code configuration scope to write the server into. Defaults to `local` (Claude Code's default) when omitted.
* **`--callbackPort <port>`**: local port for the OAuth authentication callback. Default `52566`.
* **`--debug`**: emit debug logs.

***

### **What it does** <a href="#what-it-does" id="what-it-does"></a>

1. Authenticates you to P0.
2. Registers a P0 OAuth client for this machine, or reuses the one cached under `~/.p0/claude/mcp-client.json`.
3. Resolves the server's gateway URL from your P0 tenant.
4. Invokes Claude Code's own `claude mcp add` to write an HTTP MCP server entry (with OAuth) into your Claude configuration (`~/.claude.json`). The client secret is passed to Claude Code in memory. It is never written to that file.

After adding the server, open Claude Code, run `/mcp`, and connect and authenticate to the server. You sign in through P0, and from then on your agent's tool calls are enforced and audited by the gateway.

***

### **Examples** <a href="#examples" id="examples"></a>

```bash
# Add the "aws" MCP server to your user configuration
p0 claude mcp add aws --scope user

# Add a server using a custom OAuth callback port
p0 claude mcp add gcs -s user --callbackPort 8100
```

***

### **Related commands** <a href="#related-commands" id="related-commands"></a>

* [**`p0 claude mcp list`**](/p0-cli/p0-commands-and-usage/p0-claude-mcp-list.md): list the MCP servers available to you behind the gateway.
