> ## Documentation Index
> Fetch the complete documentation index at: https://ngrok.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Gateway

> Put your team's MCP servers behind one AI Gateway URL and key, choose which tools each key can call, and see every MCP call in Activity.

MCP Gateway puts the MCP servers your team uses behind one URL, `https://mcp.ngrok.ai`, and the same AI Gateway access key your agents already send for models.
The gateway holds each server's upstream credentials, hides tools a key is not allowed to call, and records every MCP call in **Activity**.
It is available on every AI Gateway account and bills per operation.

> [!NOTE]
>
> This page covers MCP servers that AI Gateway fronts for your agents.
> To give one MCP server of your own a public HTTPS URL with an ngrok endpoint and Traffic Policy, see [Use ngrok as an MCP Gateway](https://ngrok.com/docs/gateway/api-gateway/mcp-gateway.md).

## How it works

1. You register each upstream MCP server with a **label**, such as `docs`, its HTTPS URL, and how the gateway authenticates to it.
2. The gateway syncs each server's tool catalog.
3. Your agent connects to `https://mcp.ngrok.ai` with an access key.
   It sees the tools of every server the key may reach, named `<label>__<tool>`, such as `docs__search`.
4. On each `tools/call`, the gateway checks the key's access configuration, removes the client's ngrok key, adds the upstream credential, and forwards the call.

Every server also has its own URL, `https://mcp.ngrok.ai/<route>`, shown on the server in the dashboard and in the API `url` field.
Use it when a client should see only that server's tools, without the `<label>__` prefix.

## Set up an MCP gateway

You need an MCP server with a public HTTPS URL.

### 1. Register a server

1. Open [app.ngrok.ai](https://app.ngrok.ai) → **MCP Gateway** → **Servers** and click **Register server**.
2. Set a **Label**, such as `docs`.
   A label is 1 to 64 lowercase letters, digits, `-`, or `_`, starts with a letter or digit, and can't contain `__`.
   `ngrok-gateway` is reserved.
3. Set the **Upstream URL**.
4. Choose an upstream auth **Mode**.
   See [Upstream authentication](#upstream-authentication).
5. Save the server and turn it on.
   The server's status shows `ready` once its catalog syncs.

### 2. Choose the tools a key can call

1. Open [**Keys**](https://app.ngrok.ai/keys) → **Configurations** and create an [access key configuration](https://ngrok.com/docs/ai-gateway/guides/access-key-configurations.md).
2. Under **MCP tools**, allow `docs/search`.
3. Create an access key that uses the configuration.

### 3. Connect your agent

Export the key, then add the gateway to your client.
For Claude Code:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
export MCP_GATEWAY_API_KEY="<your access key>"
claude mcp add --transport http ngrok-mcp-gateway https://mcp.ngrok.ai \
  --header "Authorization: Bearer $MCP_GATEWAY_API_KEY"
```

The **MCP Gateway** page in the dashboard has the same step for Codex, Cursor, VS Code, Windsurf, Amp, and more clients.

Run `/mcp` in Claude Code.
The tool list shows `docs__search` and `ngrok-gateway__list_servers`, and no other tools from `docs`.

### 4. Confirm the call

Ask your agent to search the docs.
Open **Activity**, select **MCP calls**, and find the request.
It shows the key, the server, the tool, and the outcome.

## Control tool access

An access key configuration has two optional MCP lists:

| List | Entries | Example |
| - | - | - |
| **MCP servers** | Server labels | `docs` |
| **MCP tools** | `<label>/<tool>`, or `<label>/*` for every tool on a server | `docs/search`, `deploy/*` |

* A key with no access configuration, or a configuration with no MCP lists, reaches every server and tool on the account.
* An empty list denies everything in that list.
* When both lists are set, a call must pass both.
* MCP lists are separate from the provider and model lists.
  A key restricted to one model is not restricted for MCP.
* A server can also have its own **allowed tools** list.
  A tool outside it is hidden from every key.

The gateway removes tools a key can't call from `tools/list`.
A call to one returns JSON-RPC error `-32003` with the message `tool not allowed for this key`, and the gateway never contacts the upstream.
A call to a server the key can't reach returns `-32003` with `mcp server not allowed for this key`.

## Built-in tools

The gateway adds its own tools under the `ngrok-gateway` label:

| Tool | What it does | Needs search on |
| - | - | - |
| `ngrok-gateway__list_servers` | Lists the servers the key can reach and the tools it may call on each | No |
| `ngrok-gateway__search_tools` | Searches tool names and descriptions across those servers | Yes |
| `ngrok-gateway__describe_tools` | Returns the full input schema of tools found through search | Yes |

Search is off by default.
Turn it on in the access key configuration, or set `mcpSearchEnabled` with the API.

## Upstream authentication

Your agent never sends upstream credentials.
The gateway strips the client's ngrok key before it calls the upstream, and it refuses an ngrok key or personal access token as an upstream credential.

| Mode | Use it when | What the gateway sends |
| - | - | - |
| `none` | The upstream needs no credential | Nothing |
| `static` | The upstream takes one shared API key or token | A [provider key](https://ngrok.com/docs/ai-gateway/guides/attaching-provider-keys.md) named `mcp:<label>`, in the header or query parameter you set, with an optional prefix such as `Bearer ` |
| `forward_header` | Each client sends its own upstream credential | Up to 16 named client headers, copied to the upstream headers you set |
| `oauth_passthrough` | The upstream uses OAuth and each user signs in | The client's `Authorization` header, unchanged. Send the access key in `X-Api-Key` instead. Use the server's own URL; the aggregate URL refuses this mode. |

## Captures

Each server has a **capture level**: `off`, `metadata`, or `full`.
At `full`, the gateway stores request and response bodies when captures are on for the account, except for tools in the server's exclusion list.
Read captures from the request in **Activity**.

## Pricing

MCP Gateway costs \*\*$10 per 1 million billable operations** ($0.00001 each), paid from [credits](https://ngrok.com/docs/ai-gateway/concepts/credits.md).

* A completed `tools/call` is one operation, including a result with `isError`, because the upstream answered.
* A successful `ngrok-gateway__search_tools` call is one operation.
* `initialize`, `tools/list`, `list_servers`, and `describe_tools` are free.
* A denied call, an upstream failure, a timeout, or a call the client cancels is not billed.

An account with no credits can still list its tools.
A billable call is refused before it reaches the upstream, and **Activity** shows it as **No credits**.

## Limits

| Limit | Value |
| - | - |
| Servers per account | 100 |
| Allowed tools per server | 2,000 |
| Call timeout | Up to 900 seconds per server |
| Tool name length | 128 bytes |
| Transport | Streamable HTTP. SSE-only and stdio servers are not supported. |
| Upstream URL | `https://`, with no credentials, query, or fragment, on a public host or an [ngrok internal endpoint](https://ngrok.com/docs/gateway/endpoints/internal-endpoints.md) (`.internal`, where `http://` also works) |

## Manage servers with the API

The [AI Gateway API](https://ngrok.com/docs/ai-gateway/api-reference/overview.md) at `https://api.ngrok.ai` manages servers:

| Method | Path | Scope |
| - | - | - |
| `GET` | `/mcp-servers` | `ai-gateway:mcp:read` |
| `POST` | `/mcp-servers` | `ai-gateway:mcp:write` |
| `GET` | `/mcp-servers/{id}` | `ai-gateway:mcp:read` |
| `PATCH` | `/mcp-servers/{id}` | `ai-gateway:mcp:write` |
| `DELETE` | `/mcp-servers/{id}` | `ai-gateway:mcp:write` |
| `GET` | `/mcp-servers/{id}/status` | `ai-gateway:mcp:read` |
| `GET` | `/mcp-servers/{id}/tools` | `ai-gateway:mcp:read` |
| `POST` | `/mcp-servers/{id}/sync` | `ai-gateway:mcp:write` |

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl https://api.ngrok.ai/mcp-servers \
  -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "docs",
    "upstreamUrl": "https://docs.example.com/mcp",
    "enabled": true,
    "auth": { "mode": "none" }
  }'
```

An update sends the server's current `revision` and fails if the server changed since you read it.
A personal access token calls `https://mcp.ngrok.ai` only when it has the `ai-gateway:mcp:request` scope.
A server binding a provider key also needs `ai-gateway:providers:read`.

The [ngrok MCP server](https://ngrok.com/docs/mcp-server.md) has AI Gateway tools that manage MCP servers and access key configurations from your agent.

## Related

* [Access key configurations](https://ngrok.com/docs/ai-gateway/guides/access-key-configurations.md)
* [Credits](https://ngrok.com/docs/ai-gateway/concepts/credits.md)
* [Use ngrok as an MCP Gateway](https://ngrok.com/docs/gateway/api-gateway/mcp-gateway.md), for one MCP server behind an ngrok endpoint
* [ngrok MCP server](https://ngrok.com/docs/mcp-server.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.