Skip to content

Need way to hot-load local MCP changes into existing Codex thread #20605

Open

Description

@devinbost

What version of the Codex App are you using (From “About Codex” dialog)?

Version 26.422.20832 (2025)

What subscription do you have?

Pro

What platform is your computer?

Darwin 25.4.0 arm64 arm

What issue are you seeing?

Whenever my local MCP server has updates to its tools, the existing Codex UI thread can't access any of the updates, requiring a human to create a new thread in the UI. This is a huge blocker becuase if I'm using Codex to automatically update the MCP surface overnight, every other automation is blocked because existing threads cannot access the updated MCP surface. There needs to be a way to hot-load local MCP changes into existing threads.

What steps can reproduce the bug?

Uploaded thread: 019de35b-8816-72d3-b69b-773269fd8e01

The repro is:

  1. Start with a Codex thread that has the local MCP server attached.
    In this repo, portfolio_state is built from tools/prompt_wave_controller.py and launched as:

    python3 -u tools/portfolio_state_mcp_server.py serve
  2. In that existing thread, record what it can see: server version, tool count, and tool names. Current fresh local probe is:

    cd /Users/devin.bost/proj/repos/thespaceplace
    python3 tools/probe_local_orchestrator_mcp_servers.py --server portfolio_state --json

    Right now that reports portfolio_state version 1.31.0 with 107 tools.

  3. Update the MCP surface on disk. For example, add a new portfolio_state tool in tools/portfolio_state_mcp_server.py, add it to the controller allowlist in LOCAL_PORTFOLIO_STATE_MCP_TOOL_NAMES, update shape snapshots/changelog, and bump the MCP server version.

  4. Fresh-probe the local server in a new process:

    python3 tools/probe_local_orchestrator_mcp_servers.py --server portfolio_state --json

    This should show the new version/tool count/tool name, because the probe starts a fresh stdio MCP process.

  5. Return to the already-open Codex thread and try to call or discover the new tool. The existing thread should still fail to see it or be unable to call it, because its MCP attachment/tool surface was captured before the update. Existing long-lived MCP server processes also do not hot-reload Python module changes.

  6. Confirm the mismatch with the repo’s stale-attachment logic: compare the existing thread’s attached observation against the fresh probe. The expected status is attachment_stale_needs_refresh or stop_attachment_stale; the relevant fail-closed guidance is in tools/kappability_multi_codex_portfolio_supervisor.py, and old contracts explicitly say to refresh the Codex MCP attachment before relying on new behavior in tools/portfolio_state_mcp_server.py.

The key observation: a fresh local probe can see the updated MCP surface, but an already-created Codex thread cannot. The fix is to start a new Codex thread/session or otherwise refresh the MCP attachment.

What is the expected behavior?

An already-open Codex thread should automatically refresh its attached local MCP surface after the local MCP server/config changes, without requiring a new thread or manual restart.

Concretely:

  • After a local MCP tool is added, renamed, removed, or its schema/version changes, the existing thread should detect the changed surface.
  • On the next tool-discovery or tool-call opportunity, the thread should use a fresh MCP tools/list result instead of the stale attached snapshot.
  • Newly added tools should become discoverable and callable from the existing thread.
  • Updated tool schemas/output contracts should be reflected in the thread’s callable metadata.
  • Removed tools should disappear or fail with a clear “tool no longer available” error, not linger as stale callable tools.
  • MCP identity/freshness checks should report the refreshed version/tool count/source hashes as current.
  • Repo trust checks such as get_go_loop_mcp_attachment_freshness should return an aligned/usable state rather than attachment_stale_needs_refresh or stop_attachment_stale.
  • If automatic refresh fails, Codex should fail closed with a clear refresh error and recovery hint, not silently keep using stale MCP metadata.

A crisp acceptance-test version:

  1. Open Codex thread with portfolio_state attached.
  2. Add a new MCP tool locally and update the server allowlist/version.
  3. Fresh local probe sees the new tool.
  4. Without starting a new Codex thread, ask the existing thread to discover/call that new tool.
  5. Expected fixed behavior: the existing thread sees and can call the new tool automatically.

Additional information

No response

Activity

  1. added
    app
    on May 1, 2026
  2. added
    enhancement
    mcp
    session
    on May 1, 2026
  3. github-actions commented on May 1, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  4. devinbost commented on May 1, 2026

    @devinbost
    Author

    Hi @etraut-openai, I think #19155 may be in the MCP refresh/tool-list area you recently touched.

    I put together a small demonstration branch here:
    https://github.com/openai/codex/compare/main...devinbost:feat/mcp-tool-list-refresh?expand=1

    The change wires MCP notifications/tools/list_changed through codex-rmcp-client into codex-mcp, marks the cached tools stale, and refreshes tools/list the next time an existing thread reads its tool surface. It passes:

    • cargo build -p codex-cli
    • cargo test -p codex-rmcp-client
    • cargo test -p codex-mcp
    • cargo clippy --fix --tests --allow-dirty -p codex-rmcp-client -p codex-mcp

    I know external PRs are invitation-only, so I’m not trying to bypass that process. Would you be the right person to say whether this is the intended direction, or to invite/open an internal PR if it looks right?

    CC @aibrahim-oai since the patch also touches the codex-mcp ManagedClient tool cache path from #19725.

  5. devinbost commented on May 1, 2026

    @devinbost
    Author

    @etraut-openai, I updated the demonstration branch to cover the local-stdio hot-load part of #20605 in addition to #19155:

    https://github.com/openai/codex/compare/main...devinbost:feat/mcp-tool-list-refresh?expand=1

    The branch now has two pieces:

    1. For Stale MCP Tool Schema After Server Restart #19155, it wires MCP notifications/tools/list_changed through codex-rmcp-client into codex-mcp, marks the cached tool list stale, and refreshes tools/list the next time the existing session reads MCP tools.

    2. For Need way to hot-load local MCP changes into existing Codex thread #20605, it adds a core watcher for local stdio MCP surfaces. Existing sessions watch the user MCP config plus path-like stdio command/args, reload MCP config when those files change, and queue a deferred MCP server refresh so the stdio server is restarted and the tool surface is rebuilt on the next turn/tool-list request.

    The implementation is intentionally conservative: for local stdio MCP servers, it watches files referenced directly by the configured command/args, plus the immediate parent directory of those files. For example, if the MCP config launches a server as python3 -u tools/portfolio_state_mcp_server.py serve, Codex watches tools/portfolio_state_mcp_server.py and tools/. That covers common Python/Node script-based MCP servers without recursively watching the whole repo.

    It should work for things like:

    node tools/server.mjs
    bun tools/server.ts
    deno run tools/server.ts
    ruby tools/server.rb
    go run ./cmd/mcp-server
    cargo run --manifest-path tools/mcp/Cargo.toml
    ./target/debug/my-mcp-server
    

    Caveats:

    • It watches files/directories referenced directly in command or args.
    • It also watches the immediate parent directory of referenced files.
    • It will not reliably catch deeper dependency changes outside those watched paths.
    • It will not catch changes hidden behind a package script like npm run mcp unless the watched config/entrypoint also changes.

    You (or another maintainer) may want to decide whether broader project config watching, dependency-root watching, or an explicit MCP watch_roots config would be the preferred product shape.

    I ran:

    • cargo fmt -- --config imports_granularity=Item
    • cargo test -p codex-rmcp-client
    • cargo test -p codex-mcp
    • cargo test -p codex-core mcp_server_watcher --lib
    • cargo test -p codex-core reload_user_config_layer_updates_mcp_servers --lib
    • cargo test -p codex-core queue_current_mcp_server_refresh_uses_reloaded_config --lib
    • cargo test -p codex-core refresh_mcp_servers_is_deferred_until_next_turn --lib
    • cargo clippy --fix --tests --allow-dirty -p codex-rmcp-client -p codex-mcp
    • cargo clippy --fix --tests --allow-dirty -p codex-core

    Would you be the right person to advise whether this is close to the intended architecture, or should I ping someone else for the MCP/session refresh path?

  6. removed
    app
    session
    on May 1, 2026
  7. Kaexburli commented on Jun 24, 2026

    @Kaexburli

    Same need here from a slightly different runtime shape.

    We can verify out-of-band that the MCP server has the updated/real tool catalog available, and the server logs a Codex MCP client connection. But the already-open Codex thread still has the stale MCP tool attachment captured earlier and cannot call the real tools until the session/thread is restarted.

    So the missing capability is exactly a hot refresh of the thread-attached MCP tool surface after the underlying server/catalog changes or recovers.

  8. 100yenadmin commented on Jul 16, 2026

    @100yenadmin

    Additional exact reproduction from Codex Desktop on macOS arm64 with codex-cli 0.144.0 and a local stdio MCP server:

    • The already-open long-running task did not expose the configured gitnexus MCP namespace after the server/config was repaired.
    • codex mcp list and codex mcp get gitnexus both reported the server enabled.
    • A direct fresh stdio initialize followed by tools/list succeeded and returned 13 read-only tools.
    • A fresh ephemeral codex exec task then called the same server's list_repos tool successfully and received 34 repositories.
    • The original task still could not acquire the namespace dynamically.

    This isolates the failure to the existing task's attached tool surface rather than server startup, config parsing, or MCP protocol behavior. A full Desktop restart was not required for a newly created task; creating a new task was sufficient. The missing capability is a current-task MCP reconnect/reload exactly as described here.

    No credentials or private configuration values are included in this report.

  9. TeaShaman-cyber commented on Aug 8, 2026

    @TeaShaman-cyber

    Windows/AppX reproduction and operational impact

    This is also reproducible on current Windows Codex Desktop 26.803.5235.0.

    Our live control comparison shows:

    • after a full Desktop restart, an external Gramps MCP server exposes 57 mcp__family_gramps__* tools and a read-only get_metadata call succeeds;
    • an authenticated remote GitHub MCP server remains unavailable and no mcp__github__* tools appear;
    • the GitHub discovery/exposure details are tracked in #19425.

    The missing capability is an in-process/live MCP manifest refresh. When an external server is started, repaired, re-authenticated, or its tools change, the current task should be able to request a bounded refresh of its attached MCP catalog without restarting the whole Desktop app.

    A full restart is not a cheap workaround for this problem. On Windows, restarting Codex can require reopening and reconstructing historical tasks, while existing reports also describe eager history hydration, UI stalls, repeated history replay, and MCP process startup during task navigation:

    • #29590 — slow or unresponsive previous-conversation loading and eager history hydration;
    • #32154 — MCP process generation and history replay while navigating existing Windows/WSL2 chats.

    This makes MCP diagnosis and configuration disproportionately expensive for users, especially when working with remote or authenticated MCP servers.

    Suggested acceptance criteria:

    • from an existing task, invoke an explicit “Refresh MCP tools” action or equivalent;
    • refresh only the selected server or current task attachment;
    • report success/failure and the resulting tool count or server version;
    • keep the current task alive without a full app restart and history hydration.
  10. 497429018 commented on Sep 3, 2026

    @497429018

    Additional exact reproduction from Codex Desktop on macOS with a remote authenticated MCP server.

    Environment:

    • Codex Desktop bundle: com.openai.codex
    • App version: 26.901.20858
    • macOS
    • Long-running existing task with a remote MCP server attached

    Reproduction:

    1. Open a Codex task while the remote MCP server exposes 9 tools.
    2. Deploy a new server version that adds one read-only tool. The server-side catalog and the gateway/admin inventory both show 10 tools, and the new server workload is healthy.
    3. Continue the existing task across multiple turns.
    4. Inspect the task-attached MCP surface: it remains frozen at 9 tools and the new tool is not callable.
    5. Fully restart Codex Desktop and reopen the same task.
    6. The task now exposes exactly 10 tools, the added tool is callable, and its real read-only positive and fail-closed negative calls succeed.

    Observed:

    • Server and gateway state changed from 9 to 10 tools.
    • The existing task did not refresh after multiple new turns.
    • A full Desktop restart refreshed the same task attachment.
    • This blocked deployment acceptance because Codex could verify the new workload identity but could not call the newly deployed MCP tool.

    Expected:

    • Existing tasks should react to notifications/tools/list_changed when available, or Codex Desktop should provide an explicit per-server or per-task Refresh MCP tools action.
    • The refresh should report the resulting tool count and keep the current task alive without a full application restart.

    No credentials, private URLs, API keys, or business payloads are included.

  11. 497429018 commented on Sep 20, 2026

    @497429018

    macOS Codex Desktop: full restart disrupts unrelated active tasks

    Additional reproduction and product impact:

    • Component: Codex Desktop on macOS
    • Desktop version: 26.915.31945
    • Codex CLI: 0.145.0
    • Multiple Codex tasks were actively running in parallel.
    • I added or fixed two authenticated Streamable HTTP MCP server entries in ~/.codex/config.toml.
    • codex mcp list immediately parsed the updated configuration and reported both servers as enabled.
    • The already-open task retained its old attached tool catalog and could not see either MCP namespace.
    • The documented recovery is restarting Codex, but restarting the entire app interrupts unrelated tasks that are still making progress.

    This makes routine MCP configuration and credential repair operationally disruptive. A change needed by one task forces an application-wide restart even when other long-running tasks are healthy.

    Suggested behavior:

    1. Add an explicit Refresh MCP tools action scoped to one server or one task.
    2. Re-read the current MCP configuration and reconnect only the selected server.
    3. Rebuild the current task's attached tool catalog without restarting Codex or interrupting other tasks.
    4. Report refresh success or failure and the resulting tool count.
    5. Preserve fail-closed behavior for invalid configuration or authentication failures.

    No credentials, server URLs, repository details, or private payloads are included.

  12. rexsacrorum commented on Sep 21, 2026

    @rexsacrorum

    Reproduced on Windows with Codex Desktop 26.915.31945; codex --version reports codex-cli 0.153.4.

    This also affects a newly added project-scoped MCP server, not only changes to an existing server's tool list:

    1. Start a Codex Desktop thread in a repository.
    2. Add an MCP server to the trusted repository's .codex/config.toml.
    3. Confirm from the same repository directory that codex mcp list and codex mcp get <server> show the server as enabled.
    4. Confirm the executable is available on PATH.
    5. Return to the existing thread.

    The thread still cannot discover or call the server's tools. The agent-visible tool inventory remains the one created before the project MCP configuration existed.

    The installed CLI exposes list, get, add, remove, login, and logout under codex mcp. It has no reload or reconnect command. The agent also has no callable action that refreshes the current thread's MCP attachment.

    Starting a new thread is the current workaround. An agent-callable refresh operation would be particularly useful because the agent can diagnose that codex mcp list is current while its own tool inventory is stale, but it cannot repair that state.

  13. qianyizhang commented on Oct 13, 2026

    @qianyizhang

    MCP App discovery and server lifetime: diagnosis and resolution

    Observed on macOS 26.6.2 arm64, Codex desktop 26.1007.30912 (20156), bundled CLI 0.162.0-alpha.17.2.

    Two distinct failures occurred:

    • Stale chat registration: the app menu offered Repo Canvas, but the existing chat returned -32603 unknown MCP server 'repo_canvas' for both mcpServer/tool/call and mcpServer/resource/read. A fresh SDK connection to the same running server succeeded. This supports a stale per-chat registry diagnosis; the internal cause was not established.
    • Our server-lifetime bug: later, the menu entry disappeared because our manually started HTTP server had stopped. Desktop discovery correctly failed to connect. We replaced it with a Codex-managed stdio server so it starts automatically.

    Resolution: after loading the revised registration, the native MCP App sent a user message into the existing conversation through ui/message; that conversation successfully called canvas_read and delivered a reply through canvas_reply. No separate agent was involved. We did not isolate whether reconnecting alone would resolve the first failure.

    Requested improvement: expose an actionable per-chat MCP reconnect/error state, and document that registration, app-menu discovery, server availability, and current-chat readiness are separate checks. A successful SDK probe does not refresh an existing chat, and a generic “Couldn't display” screen obscures failures that happen before HTML delivery.

    No private repository contents, credentials, or session identifiers are included.

  14. hyeonbungi commented on Nov 23, 2026

    @hyeonbungi

    Windows 재현 — MCP 다시 시작 직후 진행 중인 응답이 표시 없이 중단됩니다

    환경
    Windows 11 Home x64 (빌드 26300), Microsoft Store 데스크톱 패키지 26.1117.4957.0, 번들 런타임 codex-cli 0.171.0-alpha.13입니다. Codex 모드의 로컬 채팅에서 Unity CLI 1.0.1을 로컬 stdio MCP 서버로 등록한 상태였습니다.

    재현 절차

    1. Codex 데스크톱의 기존 채팅에서 도구를 쓰는 작업을 시작합니다.
    2. 응답이 진행 중일 때 Settings → Plugins → MCP → Servers → Restart를 누릅니다. 재현 시 Unity MCP 항목을 껐다 켜서 서버 목록 위의 Restart 버튼을 표시했고, Unity MCP는 활성 상태로 돌려놓았습니다. 버튼을 누르는 작업도 같은 응답에서 수행했습니다.
    3. 재시작 후 같은 채팅에서 이전 응답의 상태를 확인합니다.

    실제 결과
    재시작 버튼을 누른 도구 호출이 aborted로 종료됐습니다. 이후 화면에는 직전의 접을 수 있는 활동 기록인 “명령을 실행했습니다”만 남았습니다. 최종 답변, 중단·오류 안내, 진행 중 표시가 나오지 않았고 응답도 자동으로 재개되지 않았습니다. 같은 채팅에 새 메시지를 보낸 뒤에야 남은 검증을 이어갈 수 있었습니다. 같은 채팅에서 이 동작이 여러 번 반복됐습니다.

    기대 결과
    서버 목록 갱신이 현재 응답을 끊지 않으면 좋겠습니다. 응답 중단이 필요한 경우에는 재시작 전에 알려주시고, 복귀 후에는 해당 응답을 명시적으로 중단 상태로 표시해 남은 작업을 이어갈 방법을 제공해 주세요.

    참고로 Unity 도구 목록의 자동 갱신은 별도로 확인했습니다. mcp_tool_list_changed를 켠 뒤 같은 채팅에서 Unity를 나중에 열었을 때, 도구 목록이 1개에서 208개로 갱신됐고 scene_list_open이 응답했습니다. 이 댓글은 데스크톱의 Restart 버튼을 누른 순간 진행 중인 응답의 상태가 화면에서 사라지는 동작을 기록합니다.

  15. otmanm commented on Nov 25, 2026

    @otmanm

    A related old-thread versus fresh-thread result on macOS 27.2.1, Desktop 26.1120.41243 (0.171.0-alpha.13.2). Here the local MCP server was newly installed rather than an existing tool schema being changed. The original thread still reported an unknown server. In an app-server comparison, reloading the configuration did not fix an older test thread. Restarting the app server and reopening that same test thread restored the panel resource and card data; a thread created after installation also loaded them. This verifies the server-side difference, not that a panel rendered in the original desktop window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions