Skip to main content
An MCP server is a separate program or web service that gives the model extra tools, such as access to an issue tracker, a database, or a docs site. o4 speaks the Model Context Protocol (MCP), so you can connect any MCP server over stdio, Streamable HTTP, or the older SSE transport. Add an MCP server when you want the model to use a system that o4’s built-in tools can’t reach.

Add a server

The quickest way to add a server is the MCP browser. In a session, run:
Choose Add server, paste one of these, and press Enter:
  • The server’s address, such as https://mcp.example.com/mcp.
  • The command that starts it, such as npx -y @modelcontextprotocol/server-filesystem /path/to/folder.
  • The JSON for one server, as a server’s own docs often give it: wrapped in mcpServers, as {"name": {...}}, or only the settings.
o4 shows what it understood on the Review MCP Server screen: the server’s name, where it will be saved, and its transport and program and arguments, or its address. Nothing runs until you choose Confirm. o4 then starts the server and saves it only once it connects, and the model can use its tools in the same session. If it fails to connect, o4 shows the error and saves nothing; choose Retry, Edit to change what you pasted, or Cancel. On the review screen:
  • Name is the name in the pasted JSON, or is suggested from the package, program or host name. Select it to change it; a name you type can use letters, digits, - and _, without __ or a _ at the end. A name suggested from an address keeps the host name’s dots, such as mcp.example.com, so change it: the name starts each of the server’s tool names (see Config format), and model providers accept only letters, digits, - and _ there.
  • Save to starts on global (~/.o4/.mcp.json). Select it to switch to the project’s .o4/.mcp.json.
  • Values that may be secrets stay hidden: the review shows the address without its path, and only counts environment variables and headers.
For an address, o4 tries Streamable HTTP and switches to the older SSE transport once if the server doesn’t support Streamable HTTP. It saves the server with "transport": "auto". For a command, o4 splits the arguments the way a shell does, so quote an argument that contains spaces, but it doesn’t run a shell: pipes, ;, redirects, $VARIABLES and ~ paths are refused. To set environment variables, paste JSON with env. JSON with settings o4 doesn’t know, or with more than one server, is refused. If the JSON leaves out the command or the address, o4 asks for it. In the paste box, Shift+Enter starts a new line and Ctrl+U clears it. On the review, Up and Down move and Enter selects. From the paste box or the review, Esc returns to the browser and keeps your draft, so Add server opens it again. While o4 connects, Esc cancels the connection. From a terminal, o4 mcp add saves a server you run yourself. Put the command that starts it after --, or give a remote server’s address with --url:
Then run o4 mcp list --check to start the server once and see whether it works. See Manage servers from the command line. You can also edit the config file yourself. For a server that runs as a local command, create .o4/.mcp.json in your project:
o4 reads the config files when a session starts. If you edit a file while a session is running, start a new session to pick up the change, or change the server from /mcp with Edit config, which reloads the file when you close your editor.
A project’s servers only start after you trust the workspace and approve each one. See Project servers need trust and your OK.

Where servers are configured

o4 reads MCP servers from these files. They use the same format. The .mcp.json at the repository root is the file Claude Code and other tools use for servers a team shares, so a repository that already has one works in o4 too. If it and .o4/.mcp.json define a server with the same name, .o4/.mcp.json wins, and o4 says so. If a project file and your global file define the same name, the project entry wins once it’s approved; until then your own server keeps running. When you add a server through Add server in /mcp, Save to starts on global. A server you add from the registry, on the Registry tab or with /mcp add <registry-id>, starts on the project file; you can switch either before you confirm. o4 mcp add writes to the project file unless you pass --global. o4 writes these files with owner-only permissions, and refuses to read a config file that is a symlink or larger than 4 MiB. Plugins can also provide MCP servers. Those servers are never written to .mcp.json, and a server with the same name in your own config takes precedence over the plugin’s. See Plugins and marketplaces. o4 doesn’t change the permissions of the repository’s .mcp.json, and won’t read it through a link. A server in it that o4 can’t run is skipped with the reason: a WebSocket server ("type": "ws"), a headersHelper, or an oauth sign-in. Settings only Claude Code reads, such as alwaysLoad, are ignored without a warning.

Config format

Each entry under mcpServers is keyed by the server name. The name also prefixes the server’s tools: a tool called search on a server named docs reaches the model as docs__search. Because of that, o4 mcp add only accepts names made of letters, numbers, - and _, without __ and without a _ at the end.

Local servers (stdio)

o4 starts the command as a child process and talks to it over standard input and output. transport defaults to stdio, so you can leave it out.
The child process does not inherit your full environment. o4 passes only a small safe set of variables (PATH, HOME, USER, LOGNAME, SHELL, TERM, TMPDIR, TZ, LANG, PWD, and the LC_* locale variables), so API keys in your shell don’t leak to MCP servers. To give a server more, set values in env or name variables to copy from your environment in pass_env. A value in env wins over one from pass_env. LD_PRELOAD and DYLD_* variables are never passed through pass_env.

Remote servers (HTTP and SSE)

For a server reached over the network, set transport and url:
The URL must start with http:// or https://. o4 rejects URLs that point at localhost, loopback, private-network, or link-local addresses, so you can’t use a remote transport for a server running on your own machine. Run local servers with stdio instead. o4 includes a test switch for this: start o4 with O4_ALLOW_LOCALHOST=1 and it accepts loopback and private-network addresses too. Link-local addresses, such as the cloud metadata address 169.254.169.254, stay blocked.

Variables in settings

A server’s settings can use variables from the environment o4 runs in, the same way Claude Code’s .mcp.json does. That way a config can be shared without the tokens or paths that differ between machines:
  • ${NAME} is replaced by the value of NAME.
  • ${NAME:-default} is replaced by the value of NAME, or by default when NAME isn’t set or is empty.
Variables work in command, args, env, url and headers. o4 fills them in each time it starts the server. The config file, /mcp and o4 mcp list keep showing the variable names, never the values. A $ that isn’t followed by {NAME} stays as written. If a variable isn’t set and has no default, o4 doesn’t start that server with the text ${NAME} in place of the value. It skips the server and says which variable to set:
Set the variable in the shell you start o4 from, then start a new session. A remote server’s url and headers can’t use o4’s own API keys, such as ANTHROPIC_API_KEY or OPENAI_API_KEY: the keys o4 already keeps out of every program it runs. The same goes for bearer_token_env_var and env_http_headers. A server whose settings would send one isn’t started, and o4 says which key it is. If you do mean to send that key to the server, copy it into a variable with another name and use that name instead. A local (stdio) server can use any variable. An address built from variables is checked once the variables are filled in, with the same rules as an address written out in full: an address that leads to your own machine or private network is refused, and the server is skipped.

All server fields

string
default:"stdio"
stdio, auto, sse, http, streamable_http, or streamable-http. You can write type instead of transport.
string
The program to run. Required for stdio.
string[]
Arguments for command.
object
Environment variables to set for a stdio server.
string[]
Names of variables to copy from o4’s environment into a stdio server, when they are set.
string
The server endpoint. Required for auto, sse and HTTP transports.
object
HTTP headers to send, written into the config as plain text. You can write httpHeaders instead of headers.
string
The name of an environment variable that holds a token. o4 reads it when it connects and sends Authorization: Bearer with the token. HTTP and SSE only. You can’t combine it with an Authorization entry in headers.
object
Headers whose values come from environment variables, as "Header-Name": "VARIABLE_NAME". HTTP and SSE only. A header can’t appear in both headers and env_http_headers.
boolean
default:"true"
Set to false to keep the entry but not start the server.
integer
Seconds to wait for the server to finish its startup handshake and list its tools. The default is 10 seconds, or 30 seconds for /mcp restart <name> and for servers a subagent starts. /mcp restart without a name gives each server at most 10 seconds, even when you set this higher.
integer
default:"30"
Seconds to wait for a single tool call. Must be more than 0.
string[]
Only these tools are shown to the model. Use the tool names without the server prefix.
string[]
Tools hidden from the model. A tool listed in both enabled_tools and disabled_tools is hidden.
boolean
default:"false"
In print mode, a required server that fails to start stops the run with an error. In an interactive session, the failure is listed on the Errors tab of /mcp as “Required MCP server failed to start” and the session continues.
o4 checks each entry when it loads the file. An invalid entry, such as a stdio server without command or a blocked URL, is skipped and the other servers still load. o4 doesn’t only write the problem to the log: it lists it, with what to do about it, on the Errors tab of /mcp, in o4 mcp list, and on standard error in print mode. The same goes for a config file that isn’t valid JSON (with the line and column), for settings o4 doesn’t recognise, and for project servers skipped in an untrusted workspace. See Find out why a server is missing.

Authentication

o4 does not run an OAuth sign-in flow for MCP servers. For a server that needs a token, keep the token in an environment variable and point the config at it with bearer_token_env_var or env_http_headers, or put ${NAME} in a header (see Variables in settings):
o4 reads the variables when it connects to the server and doesn’t write their values to disk or to the log. If a variable is missing or empty, that server fails to start with an error that names the variable. Start o4 from a shell where the variable is set:
For stdio servers, pass credentials with env or pass_env instead.

Manage servers in a session

/mcp opens the MCP browser. It has three tabs:
  • Configured: your servers with their status, scope, transport, and tool count. Select a server to restart it, enable or disable it, remove it, open its config file in your editor ($EDITOR, then $VISUAL, then vi), or view its tools.
  • Registry: search the MCP registry and add a server from the results.
  • Errors: everything that keeps a server from loading, each with what to do about it: problems in the config files, plugins that failed to load, project servers skipped in an untrusted workspace, servers that failed to start, and failed MCP actions such as a restart or a removal. o4 reads the config files again each time the browser opens, so a problem you have fixed drops off the list.
A failed registry search isn’t listed on Errors; it shows as an Error row on the Registry tab. In o4 0.4.23 that tab hides a row whose text doesn’t contain your query, so the Error row, and the No MCP servers found row, usually stay hidden: when a search shows nothing at all, check your network connection, or run o4 mcp search to see the error. The Configured tab also lists servers o4 found but isn’t running, with the reason: a plugin server that failed to start, a project server skipped in an untrusted workspace, or a server waiting for a variable. Each plugin server shows which plugin it comes from. A plugin’s server isn’t in your config files, so its screen only offers Restart server and, while it runs, View tools. When something keeps servers from loading, o4 says so when the session starts, with a suggestion to open /mcp. Disabling a server sets enabled to false in its config file and removes its tools from the session. Edit config opens the file that defines the server; when you close the editor, o4 reloads the config and restarts that server. While the model is working, you can still open the browser and search the registry, but adding, approving, removing, enabling, disabling, restarting or editing a server is refused: o4 closes the browser and shows Wait for the current turn to finish before making this change. A server you pasted into Add server stays on its review screen instead, with Wait for the current turn to finish, then retry. The typed commands that change servers, such as /mcp add <name> and /mcp remove <name>, wait for the turn to finish instead. In the browser, Up and Down move between rows, and Tab and Shift+Tab (or Right and Left) switch tabs. Type to filter the Configured list; Backspace deletes a character and Ctrl+U clears the filter. On the Registry tab, type a query and press Enter on Search registry. Enter opens a server’s details or runs the selected action. On a running server, View tools lists its tools; type to filter them, and press Enter on one to see its description and parameters, then on Show raw schema for the JSON Schema the server reported. Esc goes back one screen. On the list it closes the browser, or returns to /config if you opened the browser there. See Keyboard shortcuts. You can also go straight to an action: The MCP tab in /config (run /config mcp to go straight to it) has one row, Open MCP browser. It opens the same MCP browser as /mcp.

Manage servers from the command line

The o4 mcp commands work outside a session, which is useful in scripts.

Add a server from the command line

o4 mcp add saves the server to the project’s .o4/.mcp.json, or to ~/.o4/.mcp.json with --global:
o4 checks the server before it saves anything. It refuses a name that is already used in the destination file, a name that can’t start a tool name (see Config format), and options that don’t fit the kind of server, such as --env without a command or --header on a local command. Values can use ${NAME} variables; quote them so your shell doesn’t fill them in first:
Without a command or --url, o4 mcp add looks up a full registry ID. See Add a server from the catalog. The custom server options (--env, --pass-env, --header and --bearer-token-env-var) cannot be combined with a registry add.

Check what o4 found

o4 mcp list reads the config files and the installed plugins. It doesn’t start any server, so it’s quick and safe to run:
Each server shows where it comes from (the global file, a project file, or a plugin) and what o4 will do with it: will start, turned off, waits for your OK, or skipped with the reason. In an untrusted workspace, project servers are listed as skipped: this folder isn't trusted. o4 mcp list --check starts each server that would start, the way a session does, and then stops it again. Each one then shows works (N tools) or failed to start with the reason, such as can't find the command 'npx'. Install it, or give its full path. o4 mcp remove removes the server from the project config if it’s there, and otherwise from the global config. o4 mcp restart exists, but servers only run inside a session, so it exits with “Server restart is only available within an interactive session”. Use /mcp restart in a session instead.

Add a server from the catalog

The catalog is the official MCP registry. Search it for a server, then use the server’s full ID from the results, including the publisher prefix:

In a session

Open the Registry tab in /mcp, search, open a result, and choose Add server. Pick the Scope (project or user, which is your global file) and choose Continue. You can also run /mcp add <registry-id> with a full ID from search results; it saves to the project file unless you switch Save to on the review. o4 fetches the metadata, then lets you choose an installation, or goes straight to the review when there is only one. The review shows its command or address, local name, and save location. Nothing runs or is saved until you choose Confirm. Confirm starts the server and saves it only after it connects successfully. Unsupported installations stay in the list with a reason. While metadata is loading, navigation keys do not interrupt the lookup; Esc cancels it. A late result from a cancelled lookup does not replace your current screen.

From the command line

If the entry offers several installations, o4 lists their IDs and saves nothing. Repeat the command with --installation and the ID you want, such as package-1 or remote-1. Use --as to choose a local name; otherwise o4 uses a safe name from the registry ID’s last part. An existing server is never replaced by a catalog add. Project catalog adds also refuse names already defined in the repository’s .mcp.json. The CLI validates the selected settings and saves them without starting the server. Use o4 mcp list --check to test the connection, or start a session.

Supported installations and required settings

Catalog adds support npm and PyPI stdio packages with a specified version, and remote Streamable HTTP or SSE servers. Other package types, custom launchers, and settings that need manual setup show a reason rather than a guessed configuration. When the catalog requires an environment variable but supplies no fixed value or default, set that variable to a non-empty value before adding the server. o4 saves a ${NAME} reference, not the value from your environment. Fixed values and defaults supplied by the catalog are saved as given. Startup errors hide resolved secret values. If an installation needs required headers or arguments that o4 cannot fill in, or has unresolved URL templates, follow the publisher’s setup instructions with Add server or a custom o4 mcp add command instead. Failed or incomplete setup saves nothing.

Find out why a server is missing

Run o4 mcp list in the workspace, or open the Errors tab of /mcp. Both show the same list of problems, each with what to do. These are the common ones: To see whether the servers that load actually start, run o4 mcp list --check.

A plugin says it changed after it was loaded

o4 records a plugin’s files when it loads the plugin. If they change while o4 is running, o4 stops using the plugin’s agents, skills, commands and tools and says which file changed:
Restart o4 to load the plugin again. A plugin’s MCP servers don’t cause this by writing their own files: they run with PYTHONDONTWRITEBYTECODE=1, so Python doesn’t write __pycache__ folders next to their scripts, and they keep their data in a folder outside the plugin. See Plugin MCP servers.

Project servers need trust and your OK

An MCP server entry can run any program on your machine, or send data to an address, with your access. So a project’s servers, from .o4/.mcp.json, the repository’s .mcp.json, or a plugin in the project’s .o4/plugins, need two things before they start. First, trust the workspace. o4 ignores a project’s MCP files until you do. When you start o4 in a folder that isn’t trusted, o4 asks “Trust this folder?” first. If you answer Not now and the workspace has project servers, o4 offers again to trust it and load them. To trust it from the command line, review the checkout and run this from the workspace root:
Trust also covers the folders inside the trusted one. o4 untrust revokes it. Then, approve each server. A folder you trusted can change: a git pull, another branch, or a tool can add a server to it. So each project server also waits for your OK for exactly what it runs: its command, arguments, environment and the variables it gets from yours, or its address and headers. When any of those changes, it waits again. Turning a server off and on, changing a timeout or a tool filter doesn’t ask again. At startup o4 names the servers that wait. To review them, open /mcp: each one shows what it would run, and Approve and start starts it in the session. The first row of the list, such as Approve 2 servers that wait for your OK, approves them all at once, with what each runs in its side panel. From the command line:
${NAME} placeholders are shown as written; o4 never shows their values. A server you approve with o4 mcp approve starts in your next session. In a folder you haven’t trusted, o4 mcp approve refuses and tells you to run o4 trust first. Your approvals are kept in ~/.o4/mcp_server_approvals.json, never in the project, so a repository can’t approve its own servers. A server you add to the project yourself, with o4 mcp add or Add server in /mcp, counts as approved. Servers in your global ~/.o4/.mcp.json, and from plugins you installed globally, are your own and never need approving. Setting O4_TRUST_WORKSPACE=1 trusts every workspace for that o4 process and approves every server, so use it only for automation that already vets the repository. In print mode without it, a server that waits isn’t started, and o4 says so on standard error. o4 mcp add without --global refuses to write to an untrusted workspace. See Workspace trust for everything trust controls.

How the model uses MCP tools

Each MCP tool reaches the model as <server>__<tool>, with the description and input schema the server reports. If your built-in and MCP tools together come to more than 64, o4 doesn’t send the MCP tools up front. The model finds them with the tool_search tool and loads the ones it needs. MCP tool calls go through the same checks as built-in tools:
  • In the default ask permission mode, the first call to a server’s tools asks for approval. After you approve, other calls to that server’s tools don’t ask again for the rest of the session.
  • Permission rules that match the tool name, such as docs__search, can allow, deny, or always ask for a tool. See Permissions.
  • PreToolUse hooks run before each call and can block it. See Hooks.
  • Plan mode blocks MCP tools. See Plan mode.
MCP tool calls the model makes in the same turn run at the same time, also when they go to the same server. When a call fails, o4 cleans the error text before the model sees it: it removes terminal escape codes and hidden characters, and masks credentials such as API keys, tokens and KEY=value settings as [redacted]. A successful result reaches the model unchanged.

Resources

Some MCP servers also expose resources, such as files or records the model can read. The model has two built-in tools for them:
  • list_mcp_resources lists a server’s resources. It doesn’t ask for approval.
  • read_mcp_resource reads one resource by its URI. It asks for approval each time.
You can point the model at a resource yourself. Type @ in the prompt and open the MCP tab, or type @ and part of the resource’s name. Picking a resource inserts @, the server’s name, : and the resource’s URI, for example @github:issue://123. That is a reference only: o4 doesn’t fetch the resource. The model can read it with read_mcp_resource. See Reference files with @. Once your servers have answered, the MCP tab is there only if one of them offers a resource. Many servers offer tools only. To fill the tab, o4:
  • Asks every running server that says it has resources, all at the same time and in the background. Until the first answer, the tab shows Loading MCP resources….
  • Asks again when you open /mcp or add, remove or restart a server, and when you open the picker with a list more than 30 seconds old.
  • Takes up to 1,000 resources from each server, reading a long list page by page.
  • Waits up to 10 seconds. A server that hasn’t answered by then keeps the rows it had, and the other servers are listed after that wait.
  • Leaves out pages meant for an app to display (ui:// addresses), and any resource whose URI contains a space, a line break or a hidden character, because the reference goes into your prompt as one word.
  • Shows each resource’s name as one line of plain text. A resource with no name is shown by its URI.

MCP in print mode and evals

Print mode (o4 -p) loads the same MCP servers as an interactive session, including project servers when the workspace is trusted. Before it starts them, it prints each problem that keeps a server from loading to standard error as an [mcp warning] line, followed by what to do. If a server fails to start, o4 prints an [mcp error] line and the run continues, unless the server is marked "required": true, in which case the run stops with an error. See Print mode and scripting. o4 eval runs don’t load MCP servers unless you pass --enable-mcp. See Evaluations.