Skip to content
AI GatewayAI Gateway Manual

Connect MCP Clients

How AI users issue a Gateway Key and register MCP server or toolset endpoints in Claude Code, Codex, Cursor, and other clients.

This guide explains how an AI user issues a Gateway Key and registers an MCP server or toolset endpoint in clients such as Claude Code, Codex, and Cursor, then uses its tools.

In Gateway Keys, select Issue key and enter a Key name. Expiry date (optional) can be left blank. Right after you select Issue key, copy the One-time secret with Copy secret. It cannot be shown again after you close the dialog.

A Gateway Key belongs to the project it was issued in. Issue it in the project that has the servers or toolsets you want to use. A request with another project’s key fails with an error saying the server or toolset was not found.

Set the key as an environment variable in the terminal where you run the client. Example for bash/zsh on macOS or Linux:

Terminal window
export AI_GATEWAY_API_KEY='<your Gateway Key>'

A new terminal may not have this setting. To keep it, put AI_GATEWAY_API_KEY in your shell configuration or secret manager.

In MCP Catalog, select Client setup in a server or toolset row. The dialog shows the Gateway endpoint; copy it with Copy endpoint and open MCP client setup guide for the relevant client. Use the endpoint in the client configuration below. If the configuration file already exists, keep the other settings and merge only the entry.

In the examples below, replace <gateway-host> and <server-name> with the values shown on screen. Choose any client-specific entry name; github-123e4567 is only an example. The endpoint is copied from the setup dialog and never contains the raw key; it refers to the AI_GATEWAY_API_KEY environment variable from step 1.

Add it to .mcp.json in the project directory you work in.

{
"mcpServers": {
"github-123e4567": {
"type": "http",
"url": "https://<gateway-host>/mcp/servers/github",
"headers": {
"Authorization": "Bearer ${AI_GATEWAY_API_KEY}"
}
}
}
}

Run Claude Code in the terminal where AI_GATEWAY_API_KEY is set. When asked whether to use the project’s MCP servers, approve. Until you approve, claude mcp list shows this server as Pending approval. Run /mcp inside Claude Code to check that the server is connected. If the environment variable is missing, Claude Code shows the warning Missing environment variables: AI_GATEWAY_API_KEY.

Add it to ~/.codex/config.toml.

[mcp_servers.github-123e4567]
url = "https://<gateway-host>/mcp/servers/github"
bearer_token_env_var = "AI_GATEWAY_API_KEY"

Run Codex in the terminal where AI_GATEWAY_API_KEY is set and check the server and its tools with /mcp.

Add it to .cursor/mcp.json in the project directory you work in.

{
"mcpServers": {
"github-123e4567": {
"url": "https://<gateway-host>/mcp/servers/github",
"headers": {
"Authorization": "Bearer ${env:AI_GATEWAY_API_KEY}"
}
}
}
}

Cursor reads the environment variables it was started with. Open Cursor from a terminal where AI_GATEWAY_API_KEY is set, or restart Cursor after setting the key. Check under Customize in the sidebar that the server was added and is turned on. Connection errors appear in MCP Logs in the Output panel.

For other clients, move the endpoint values above into that client’s MCP configuration format.

{
"transport": "streamable-http",
"url": "https://<gateway-host>/mcp/servers/github",
"headers": {
"Authorization": "Bearer <GATEWAY_API_KEY>"
}
}
  • The transport is Streamable HTTP. Clients connect with Streamable HTTP even when the upstream server uses Legacy SSE.
  • Send the key only in the Authorization: Bearer <key> header. Other headers such as x-api-key are not accepted.
  • Replace <GATEWAY_API_KEY> with the actual key or an environment variable reference the client supports. If you put the raw key in a file, keep that file out of Git.

When you ask the client to use an MCP tool, the Gateway forwards the call to the upstream server. If you connected through a toolset, tool names appear as <server-name>-<tool-name>.

  • The Gateway forwards only MCP tool features (tools/list, tools/call). Other features such as resources and prompts are not supported.
  • Clients are not notified right away when the administrator changes the allowed tools or you edit a toolset. If the tool list does not change, restart the client.
  • Tool calls are subject to the project’s request rate limit.

If the client shows an error, see MCP troubleshooting.