p0 claude mcp add
Connect a Claude Code client to an MCP server gated by the P0 AI Gateway.
Overview
p0 claude mcp add connects a Claude Code client to an MCP server that is gated by the AI gateway, part of P0 Runtime Access for AI. 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
Logged into the P0 CLI (
p0 login).Claude Code installed, with the
claudebinary on yourPATH.The MCP server configured behind the gateway and available to you. See the AI gateway, and run
p0 claude mcp listto see the servers you can add.
Syntax & Flags
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). Runp0 claude mcp listto see the available keys.-s,--scope <local|user|project>: the Claude Code configuration scope to write the server into. Defaults tolocal(Claude Code's default) when omitted.--callbackPort <port>: local port for the OAuth authentication callback. Default52566.--debug: emit debug logs.
What it does
Authenticates you to P0.
Registers a P0 OAuth client for this machine, or reuses the one cached under
~/.p0/claude/mcp-client.json.Resolves the server's gateway URL from your P0 tenant.
Invokes Claude Code's own
claude mcp addto 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, fully quit and reopen Claude Code so it reloads the MCP configuration. Then run /mcp, and connect and authenticate to the server. Starting a new conversation does not reload the configuration. You sign in through P0, and from then on your agent's tool calls are enforced and audited by the gateway.
Examples
Add the aws MCP server to your user configuration:
Add a server using a custom OAuth callback port:
Related commands
p0 claude mcp list: list the MCP servers available to you behind the gateway.
Last updated