Add tool support for restarting individual MCP servers
Summary
Developers who iterate on custom MCP servers need a way to restart a single server without tearing down the entire Codex CLI session. Today Codex spawns MCP servers once during McpConnectionManager::new and never revisits them, so the only option is to stop and relaunch the whole CLI. Exposing a restart capability would keep feedback loops tight when testing server changes.
Proposed design
- Persist server configs inside the connection manager. Refactor
McpConnectionManagerso it retains the originalMcpServerConfigplus theuse_rmcp_client/OAuthCredentialsStoreModeflags. Wrap internal state in shared mutability (Arc<RwLock<…>>) so new helper methods can rebuild clients. - Add a
restart_serverpathway. Implementrestart_server(&self, name: &str)that drops the existing client, respawns it using the stored config (including bearer-token resolution), re-runslist_tools, and updates the qualified tool cache. Return a result that callers can surface to users. - Expose the restart in session APIs. Add
Session::restart_mcp_serverand surface it through the tool plumbing (e.g., a new handler undercore/src/tools/handlers/restart_mcp.rsplus aToolSpecentry so models can call it). The tool would accept{ "server": "my-mcp" }and return a success/error message. Optionally gate it behind anexperimental_supported_toolsflag. - (Optional) CLI command. If we want manual control, add an
mcp restart <name>subcommand mirroring the existinglist/get/add/removeoperations, calling the same backend helper.
Acceptance criteria
- Restarting a configured MCP server does not require quitting Codex; the tool/API respawns the child process and refreshes tool listings.
- Errors (unknown server, restart failure, etc.) bubble back to the agent so users see what went wrong.
- Documentation calls out the new capability for MCP authors.
Happy to help refine or prototype once we have consensus.
This is a pain point!
Sorry to bug but @gpeal is this a priority now that you've assigned it? Thanks
this is so needed! 🙏
Any update on this?
Any update on this issue?
Even built-in MCP server (codex apps) may not start due to network error or anything else. Having a way to restart a concrete server / all servers seems very useful.
This would directly solve a real operational case for us.
We have long-running debugging sessions with multiple MCP servers. If one remote MCP endpoint is unavailable at Codex startup and later comes back, the current session can remain stuck with stale/offline tool metadata. Restarting the whole Codex session works, but loses valuable context.
A per-server restart / reload / reconnect command that respawns the MCP transport and refreshes tool listings for the current session would be the right recovery path.
Agreed. Claude does it much better with their interactive /mcp command.
Codex CLI currently has no supported in-session command to reload or reconnect configured MCP servers and refresh their tool catalogs. The existing /mcp and /mcp verbose commands only inspect the current state.
Please add a first-class command such as:
/mcp reload <server>
/mcp reload --all
The command should:
- Reinitialize the selected configured MCP server.
- Request its current, complete tool catalog.
- Replace the catalog attached to the active session.
- Preserve the current conversation.
- Report success or an actionable reconnection error without requiring users to exit and relaunch Codex.
This would provide a deterministic recovery mechanism when an MCP connection or tool catalog needs to be refreshed while preserving CLI session continuity.
Adding feedback from Codex CLI 0.157.1 on Windows with PowerShell, matching the latest stable release when checked on 2026-09-27.
The missing in-session control is still a practical problem. If an MCP server is unavailable when I start Codex, starts later, or needs restarting during the conversation, I need a way to connect or reconnect it and refresh its tools without exiting Codex. Having to restart the CLI just to make an MCP available interrupts the session. Compared with my Claude Code workflow, this is much more of a hassle.
I checked whether the user-facing capability had changed before posting:
codex mcp --helpexposeslist,get,add,remove,login, andlogout, with no restart/reconnect command.- In the 0.157.1 TUI dispatcher,
/mcpsupports inspection and/mcp verbose; other arguments showUsage: /mcp [verbose].
Please expose recovery through the /mcp interface, with a clear action for a selected server and optionally all servers:
- Restart a Codex-managed stdio server, or reconnect to an HTTP server.
- Retry a server that failed or was unavailable at session startup.
- Refresh the active session's tool catalog and show the resulting connection status.
- Preserve the current conversation and report an actionable error if recovery fails.
Underlying refresh APIs and automatic recovery paths are useful. What is missing here is a supported, discoverable CLI action that the user can invoke when those paths do not recover the connection.
On Codex CLI 0.160.1, an enterprise Jira MCP tool continued failing after its externally managed Bearer token was refreshed. The refreshed token passed a direct authentication check, but tool calls still returned Dynamic Client Registration rejected (HTTP 404). Restarting Codex restored the tool. An in-session reconnect command for an individual MCP server would allow recovery without restarting the conversation.
Adding a concrete operational case and a request for both user-facing and agent-accessible per-server restart/reconnect controls.
Reproduced: healthy server, stale connection in the active conversation
In a long-running Codex conversation on Linux, a configured zvec-grep MCP tool continued failing with:
tool call error: tool call failed for `zvec_grep/zvec_grep_search`
Caused by:
Transport closed
The setup uses a stdio bootstrap/proxy connected to a shared local HTTP MCP daemon. We independently verified that:
- The daemon was running and reported ready.
- Real hybrid lexical/vector searches succeeded through the CLI.
- A fresh MCP HTTP client successfully completed
initialize, sentnotifications/initialized, and called the samezvec_grep_searchtool against the same index. - The tool attached to the existing Codex conversation still returned
Transport closed, including after restarting the daemon.
This isolates the remaining problem to the existing client connection/lifecycle rather than an unavailable server or broken index. It is similar to #22571. For version reference, the locally installed CLI reports codex-cli 0.162.1; the server is zvec-grep 0.2.2 on Node 22. The exact build of the already-running conversation's frontend was not recorded.
Separate everyday use case: updating MCP server code
This is also needed when nothing has crashed: while developing or patching a local MCP server, Codex or the user updates its source code, fixes a bug, or upgrades a dependency. The already-running server still has the old code loaded. There should be a supported way to restart that individual server, load the updated implementation, and refresh the active conversation's tool catalog without restarting Codex or starting a new conversation.
In our case, we patched the server's embedding backend to add bounded retries/backoff for HTTP 429 responses. Restarting the daemon loaded the new code, but it did not repair the stale MCP connection held by the current conversation. Code reload and client reconnection need to be handled as separate lifecycle steps.
Requested controls
- User command/UI: e.g.
/mcp restart <server>,/mcp reconnect <server>, and a discoverable action beside each server's connection status. An optional all-servers action would also help. - Agent-accessible host capability: allow Codex to request the same action for a named configured server, subject to the applicable approval policy. This must be a host capability, not a tool provided by the failed MCP server itself.
- Correct ownership semantics: restart/reap a Codex-owned stdio child; reconnect/reinitialize a remote or externally managed HTTP server without assuming Codex owns or may kill its daemon. For an external server, report clearly when the operator must restart it to load new code.
- Refresh the active session: recreate the client/proxy transport and MCP session, rerun initialization and
tools/list, replace cached tool definitions (including added/removed tools), and make the result available in the same conversation. - Safe, observable recovery: preserve conversation context and other MCP connections; show restarting/reconnecting/ready/failed status and actionable errors; handle in-flight calls explicitly; never automatically replay potentially mutating tool calls. Preserve credentials and permission boundaries rather than silently reauthorizing anything.
Acceptance checks
- After an MCP server code change and restart, the same conversation uses the updated implementation/tool schema.
- After a transport failure, a reconnect restores calls in that same conversation when a fresh independent MCP client can already call the server.
- A failed server or unavailable restart target returns a useful error without disrupting healthy servers or requiring a full Codex restart.
Additional use case and end-to-end acceptance criteria for per-server recovery and incremental MCP refresh in existing chats.
Variant and use case
I use Codex Desktop on Windows with local and remote integrations, and also use the VS Code extension. On 2026-10-20 I reported that MCPs had become available again shortly before continuing work. The exact recovery transition was not captured; I am not claiming a reproducible reconnect bug from that observation. I want to re-enable, reconnect, or refresh an MCP without restarting the session or interrupting ongoing chats.
The current app-server documentation already documents config/mcpServer/reload, queued refresh for loaded threads, server status and startup notifications. This request builds on that mechanism: make per-server recovery discoverable and verify that a refreshed catalog reaches both the UI and the model/dispatcher in an existing chat. I have not exercised those app-server methods against my production chats.
Requested behavior
- Offer Re-enable, Reconnect, Reload configuration, Refresh tools and redacted Diagnostics for an individual server, showing host/scope, authentication, connection health and catalog revision. Distinguish an on-disk configuration update from actual callable-tool readiness. Package upgrades should remain a separately requested operation.
- Validate the effective configuration before activation and reconcile only affected servers. Use bounded startup/reconnect timeouts and backoff; keep unrelated servers and chats running. Invalid configuration must not overwrite healthy state. A policy revocation must take effect immediately, rather than being undone by rollback to an older authorization.
- Re-initialize when needed, refresh all
tools/listpages and handlenotifications/tools/list_changedwhen supported. Invalidate schemas for changed tools, including a changed schema under the same tool name. Keep a manual refresh path for servers without notifications. - Apply a validated catalog generation atomically to UI discovery, tool search/selection and the actual definitions available to model requests and dispatch. A green connection indicator alone is insufficient.
- Let already-dispatched calls complete on their valid connection/generation when safe; suspend new dependent dispatch during replacement. Apply new definitions at the next safe model/tool boundary without discarding the chat. A model request already sent cannot be retroactively edited: revalidate a tool choice before dispatch and return a controlled unavailable/schema-changed outcome if necessary.
- Never automatically replay a side-effecting call whose outcome is unknown. On failed replacement, retain the previous connection only if it remains healthy and authorized; otherwise expose a recoverable unavailable/auth-required state. Preserve required-server fail-closed behavior, with explicit recovery controls as discussed in #36296.
- Show requested/applied revisions and a compact update notice in each affected chat. Propagate bounded environment deltas rather than repeatedly injecting the complete environment. Preserve drafts/history and avoid restarting unrelated chats or resetting their in-flight work.
Real-time here means event-driven, bounded propagation at a safe boundary, not mutating an in-flight model request. Suggested UX goals, subject to measurement: update ready local catalogs within two seconds when there is no dependent in-flight call; show progress and a configured timeout for slow initialization. These are proposed targets, not benchmark results.
Modern Standby resume: reconnect and refresh without interrupting chats
Please include Windows Modern Standby suspend/resume in this recovery contract. A restored network interface does not prove that a previous HTTP session, stdio channel, authentication state, or tool catalog is still usable.
- Detect system resume and mark affected server connections as requiring validation. Use bounded readiness checks and per-server reconnect backoff, accounting for network/VPN availability. Probe still-running local servers before deciding to respawn them; do not restart every MCP or the entire chat as a recovery shortcut.
- Revalidate the effective host/scope and authorization. Re-initialize transports when necessary, renegotiate capabilities, fetch every tool-list page, and invalidate stale schemas. Apply the validated catalog atomically to the UI, tool search, model-visible definitions and dispatcher at the next safe boundary. Recheck resources/prompts only under their negotiated capabilities.
- Preserve chat identity, history, drafts, pending approvals and valid backend work. Keep independent chats and tools usable while the affected connection recovers. New calls that depend on that server may wait or receive an actionable unavailable/auth-required status; recovery must not cancel or discard the chat. Reconcile late results with their original call and connection generation rather than completing an operation twice.
- Distinguish calls not yet dispatched from calls accepted or possibly executed before connectivity was lost. Never automatically repeat a side-effecting operation with an uncertain outcome. Preserve its correlation/receipt information and reconcile using an available read-only status/result query. If the outcome cannot be determined, expose an explicit unknown-outcome state and require reconciliation or an informed decision before any new attempt. Use idempotency keys only where the server actually guarantees that contract; a timeout or reconnect alone does not make replay safe.
- Show compact recovery state and the applied catalog revision in each affected chat. A connection indicator is insufficient: verify readiness with discovery and an appropriate side-effect-free check where available. Respect revoked permissions and required-server policy throughout recovery; do not treat resume as a reason to weaken either.
This is a proposed resilience requirement. Our observed power-transition sequence does not establish that Modern Standby caused a Codex freeze or an MCP defect.
Regression cases
Re-enable an unavailable server; restart a remote server; add/remove a tool; change its schema under the same name; paginate discovery; refresh during generation; refresh while a write is pending; expire OAuth; revoke permissions; reject invalid config; and update one server used by two chats with different scopes. Verify a synthetic read-only tool actually works in the original chat, that stale schemas are not dispatched, and that no unknown-outcome write is repeated.
Also test Modern Standby resume with delayed network/VPN readiness, surviving local processes, expired HTTP/auth sessions, changed tool schemas, concurrent chats, late responses and a pending side-effecting call. Verify that the original chat remains usable, only the affected integration is gated, stale arguments are not dispatched, and neither the uncertain write nor a late completion is duplicated. These tests are proposed, not executed product validation.
Related existing reports: #19155 (stale schemas), #22571 (transport recovery), #36296 (required-MCP recovery). I am adding concrete UX/consistency criteria to this existing request rather than opening another restart feature issue. The MCP tools specification defines paginated discovery and list-change notification; the catalog-generation and safe-swap design above is a client proposal, not a claim that MCP specifies it.
No raw configuration, diagnostics, credentials, private paths or conversation identifiers are included. This proposal does not establish MCP failure as the cause of any desktop freeze.
Related reports and scope
This proposal concerns MCP transport/catalog recovery and chat continuity. Related, complementary reports are:
-
Windows hang/window recovery field report: Records the observed hang and the Modern Standby/forced-shutdown timeline, with cause explicitly unconfirmed.
-
Keep-awake policy during active local execution: Request idle-sleep protection independently of transient Remote Control health, subject to Windows and administrator limits.
-
Missing MCP registrations and persistence: Records confirmed absence/recovery of configuration entries, with private integration details anonymized. Removal by Desktop has not been established.
These cross-references connect complementary diagnostic and resilience requirements, not an established causal chain. Neither removal of the registrations by the application nor a common root cause has been proven. We have not confirmed that Modern Standby, an MCP failure, or a keep-awake defect caused the reported hang. Keeping the host awake does not replace safe recovery after manual sleep or power loss.