Skip to content
AI GatewayAI Gateway Manual

Set up MCP

Register an AI Gateway MCP endpoint in Codex CLI and check the first tool call.

This page connects one MCP server to Codex CLI and calls the first tool. If you only use models, you can skip this page. For server authentication, toolsets, and other client setup, see the detailed guides below.

In MCP Catalog, select Client setup in the server or toolset row, then select Copy endpoint.

GitHub server row in MCP Catalog. 1 is the Client setup button

GitHub MCP client setup dialog. 1 is the Copy endpoint button

Select 1 Client setup to open the dialog in the second image. Check the Gateway endpoint, then select 1 Copy endpoint. You will use the copied address for url in the next step.

Add the content below to ~/.codex/config.toml. Keep the existing settings and merge so that entries with the same name are not duplicated. github-123e4567 is an example name, so you can change it.

[mcp_servers.github-123e4567]
url = "<copied Gateway endpoint>"
bearer_token_env_var = "AI_GATEWAY_API_KEY"

bearer_token_env_var takes the name of the environment variable, not the key value.

If you have not set the key yet, run this first in the terminal where you run Codex.

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

If Codex was running, quit it and start it again. Check the server and tool list with /mcp, then ask Codex to use the tool. When a response comes back, the connection is done.

For server authentication, toolsets, and Claude Code or Cursor setup, see Connect MCP servers, MCP toolsets, and Connect MCP clients. If you get an error, see MCP troubleshooting.