{"slug": "codex-mcp-lazy-startup-diagnose-slow-first-calls-and-missing-tools", "title": "Codex MCP Lazy Startup: Diagnose Slow First Calls and Missing Tools", "summary": "Codex CLI 0.172.0 enabled lazy startup by default for eligible optional stdio MCP servers with cached tool lists, so the first tool call starts the server and can stall while the process boots, according to the Codex CLI release notes and pull request 62366. The guide distinguishes three states — cold catalog, warm catalog with cold process, and warm process — and notes that a running server may still spend extra time loading its own index on the first query. It recommends checking configuration with codex mcp list and /mcp before raising timeouts, and warns that optional servers needing live discovery can miss Codex's shared grace period during initial catalog assembly, a symptom documented for codex exec in GitHub issue 38689.", "body_md": "Codex opens quickly. Your MCP tool is listed. Then the first call stalls. That sequence can be a side effect of lazy startup: Codex had the tool’s description on hand, and the process that runs it still had to start.\n\nNow change one detail. On a clean machine, that same tool never appears in the first task. The two symptoms need different fixes. Before you raise a timeout, find out whether Codex was waiting for discovery, a live connection, or the tool’s actual work.\n\nThis guide gives you a test you can run with one read-only tool, four observations you can ask teammates to collect, and a way to decide which MCP servers should be ready before a task starts. We’ll use a local package index as the example. The same method works for a documentation search service or a test-catalog lookup.\n\nModel Context Protocol (MCP) gives Codex a way to discover and call tools provided by another program. A local server configured with a command can use standard input and output, often called stdio, to exchange protocol messages with Codex. Codex can learn the server’s tools and store their descriptions in a tool catalog. The catalog includes enough information to present the tools before the program is ready to answer.\n\nCodex CLI 0.172.0 enabled lazy startup by default for eligible optional stdio servers with cached tool lists. On that path, the first call starts the server. An optional server without a usable catalog starts when the thread starts, so its tools can be discovered. An HTTP server uses a different transport and is outside this particular default for local stdio startup. [Codex CLI release notes](https://github.com/openai/codex/releases/tag/rust-v0.172.0) · [Implementation and tests](https://github.com/openai/codex/pull/62366)\n\n*When a tool appears in the catalog, Codex knows how to ask for it. The first real result tells you whether the server could answer.*\n\nThink of a package-index tool called lookup_package. Codex can know the tool takes a package name even if the server process has yet to open its database. A task that only edits a README may never need that process. A task that asks for a package owner will wait for the server if the process is still dormant. A second lookup in the same thread may reuse a live process, provided the connection stays up.\n\nKeep three states in your notes. **Cold catalog** means Codex lacks a usable saved tool list. **Warm catalog, cold process** means it has that list and the server still needs to start. **Warm process** means the server is already up. A fourth detail can also matter: the tool’s own index or data cache might still be cold, even after the process starts. A running process can spend another few moments loading its first real query.\n\nStart with codex mcp list to check that the server is configured. In an interactive session, use /mcp to inspect server and tool visibility. Check the server name, effective configuration, enabled status, and tool filters before treating this as a performance problem. A tool can be absent simply because its name changed or because a deny list filters it out. If you suspect the lookup itself changes startup behavior, inspect it in a separate diagnostic session and keep the timed run free of extra commands.\n\nFor an optional server that must discover its tools live, check the first tool list as well as the server’s eventual status. Codex has a shared grace period for optional servers when assembling the initial catalog. A slow server may miss that window even when it has time to complete its own startup. A later turn in an interactive chat can give you another chance to see a ready server. A one-shot job might finish before that chance arrives. An issue in the Codex repository documents reports of this symptom in codex exec. [Codex MCP configuration](https://learn.chatgpt.com/docs/extend/mcp?surface=cli) · [Headless discovery report](https://github.com/openai/codex/issues/38689)\n\nLook for evidence that the tool call triggered the server process. If you own the server, add timestamps for process entry, the end of initialization, and entry into the tool handler. Keep diagnostics on standard error or in a test log. Messages written to standard output can disrupt the stdio protocol. With an off-the-shelf server, check the client’s visible status and available server logs. An approval prompt can also account for some of the gap, so record approval time separately.\n\nWhen the process starts late and the handler runs quickly, focus on launch and initialization. If the process comes up quickly and the handler takes most of the time, investigate work the tool delays until its first query. A package index might load metadata on its first lookup. A browser-based service might start its browser only when a task asks for a page. In both cases, measuring the handler helps you see where the time went.\n\nTry the same read-only lookup twice within one thread. If both calls reach the handler and take similar time, look at the lookup, the backend, or contention. tool_timeout_sec applies to tool execution. startup_timeout_sec applies to getting the server started. A larger execution timeout can be sensible for work you expect to take longer. A fast failure with an invalid response, missing executable, or bad permission needs a fix where that error occurs. [Codex MCP timeout settings](https://learn.chatgpt.com/docs/extend/mcp?surface=cli)\n\nPick a read-only tool with one stable answer. For the package index, use a synthetic entry such as demo-widget, with the owner set to Developer Tools. The returned value should be hard to infer from the prompt. That way, a confident guess cannot pass your test. Write down the expected answer in your test notes and confirm the call in client or server evidence.\n\n*Use the package index’s lookup_package tool for demo-widget. Return the owner from the tool result. If the tool is unavailable or fails, report that outcome.*\n\nUse the same client build, model, workspace, server version, fixture, and approval policy for each run. Record how the local binary is launched and which machine or executor runs it. A terminal shell and an editor may pick up different paths or environment variables. If the server is critical in CI, repeat the test there using the real invocation. A healthy interactive session tells you only about that session.\n\nCompare the first and repeat calls with the time from submitting the no-tool task to the first useful output. Those are different measurements. A model can take longer to select a tool even when its server starts at the same speed. If you only have wall-clock values, record them as end-to-end observations. Use handshake and handler timestamps to make narrower claims about startup or execution.\n\nFor example, suppose server logs in your test show four seconds before the first handler starts, followed by 90 milliseconds in the handler. The same process serves the next call in about 90 milliseconds. Those illustrative values point toward startup. If both handlers take four seconds, the query deserves your attention. If no process starts and no tool call appears, review discovery and selection first. These are diagnostic patterns, and your own logs supply the actual numbers.\n\nUse a few repetitions at first. Keep first-call success next to call time. A fast result that came from a fallback belongs in a different bucket from a fast result that used the intended tool. For a larger rollout, record the median and slower observations for each lane, plus counts of missing tools, timeouts, and failures. Report a percentile only when you have enough samples to make it meaningful.\n\nA design-preview tool or a package index used in only a few interactive tasks is a good candidate. Its first call can spend a little extra time while other tasks avoid that cost. Check the cold catalog path before rollout, especially if teammates frequently switch machines or start from disposable environments. A separate no-tool test catches a regression where every new thread spins up a process that it rarely uses.\n\nSuppose a release job requires a read-only package-owner lookup before it produces a release note. Put that lookup on the job’s critical path. In current Codex documentation, a required server uses connection readiness by default. Catalog readiness can satisfy the startup requirement using a valid saved tool list, with a live connection still needed for a call. Confirm support for the settings in your deployed build. Keep the job’s own check for the expected tool response, since connection readiness alone cannot prove the backend returned the right record. [Codex readiness options](https://learn.chatgpt.com/docs/extend/mcp?surface=cli)\n\n```\n[mcp_servers.package_index]command = \"/path/to/your/package-index-server\"args = [\"--stdio\"]required = truestartup_timeout_sec = 20tool_timeout_sec = 15\n```\n\nUse this as a template for a server you own. Replace the binary path and confirm the arguments your server expects. The values are examples. Pick budgets that fit the job and leave space for ordinary variance. Keep this requirement scoped to the workflow that depends on the package index. Requiring every team tool can turn a trouble spot in an unrelated integration into a failed coding session.\n\nTry the same test with lazy stdio startup disabled. Keep the other settings fixed and use a fresh thread for each comparison. If the process begins earlier and the first tool call improves, check whether the wait moved to thread startup. That matters for people who use the tool in nearly every task. If the first tool call takes the same time and the slow part is inside the handler, early process startup may have little effect.\n\n```\n[features]mcp_lazy_stdio_startup = false\n```\n\nIf a cold catalog is your issue, test the optional startup grace as its own change. The docs describe mcp_optional_startup_grace_ms as a top-level option. A value of 0 waits on each server’s own startup timeout instead of applying the shared grace. That setting can make more tools available in the initial catalog while increasing how long a turn waits for slow optional servers. Test the effect with the full set of servers your client normally loads. [Optional startup grace and lazy startup](https://learn.chatgpt.com/docs/extend/mcp?surface=cli)\n\nStart with one server and one workflow. Give the team the exact tool name, fixture, expected response, client version, and config change. For each test lane, ask them to note the stage that failed and one piece of evidence. For example, “fixture returned the correct owner, process started on the first call” is useful. “MCP worked” leaves the next person guessing when a problem only affects fresh threads.\n\nWatch for two different shifts after an upgrade: no-tool work may get faster, while an MCP-heavy workflow may wait longer for its first real result. Track both before you make a default change. A team that mostly uses lightweight coding tasks might choose lazy startup for optional helpers. A release job with a required dependency will care more about a dependable first result and an explicit failure. Use the same fixture after changing a server version, launch method, or startup setting.\n\nFor a server your team owns, fix repeated setup costs close to the source. Use a preinstalled, pinned package if a launcher downloads code during startup. Logging progress to standard error can distinguish a slow initialization from a process that died early. Keep expensive work off the startup path when it belongs to a specific operation, and time that operation separately. A clear error for a missing local index saves more debugging time than another silent retry.\n\nTry a second fixture in a disposable test setup. Make the index server report a missing local data file, then run the same job with an empty catalog and with a populated catalog. The job should report a failed lookup or failed startup in either case. It should also give a maintainer enough evidence to find the missing file. Restore the fixture and require a clean run with the correct owner before you call the change ready.\n\nKeep the receipt short. Record the client build, server version, cache state, and whether the thread required a live connection. Add timestamps for initialization and the tool result when those events are available. Keep fixture names and error classes in team reports. Omit request bodies, credentials, and private package information from shared logs.\n\nKeep three questions in the runbook. Was the tool visible? Did the server come up? Did the tool return the expected result? Put each answer next to its measured wait. That gives the team a repeatable way to tell whether to tune discovery, fix startup, or work on the tool itself.\n\nFor an eligible stdio server, Codex can show a usable saved tool catalog before the server process starts. Check a real read-only call and its result to verify that a connection and tool execution both work.\n\nThe headless job may use a different configuration, launch environment, or cache. An optional server with no usable catalog can also miss the initial discovery window. Reproduce the issue in the headless invocation, and compare the resolved server and first task’s tool visibility.\n\nIt helps when the server exceeds its own startup timeout. If the optional server finishes within that budget but misses the shared discovery window, inspect the grace setting and whether this workflow needs a required server. Verify the first task after the change.\n\nOn supporting releases, set mcp_lazy_stdio_startup = false under [features] and start a new thread. Compare no-tool startup and the first real tool result to see where the wait lands.\n\nThe default covered here applies to eligible stdio servers. For Streamable HTTP, inspect the remote service, network, credentials, and connection behavior. Test on the same client and environment from which the failing request comes.\n\nVerify that the tool was called again and check the process or instance identity in the logs. A new connection may start a fresh process, while a reused process may still query a cold backend. The two observations help explain the timing.\n\n[Codex MCP Lazy Startup: Diagnose Slow First Calls and Missing Tools](https://pub.towardsai.net/codex-mcp-lazy-startup-diagnose-slow-first-calls-and-missing-tools-5189122a6f03) was originally published in [Towards AI](https://pub.towardsai.net) on Medium, where people are continuing the conversation by highlighting and responding to this story.", "url": "https://wpnews.pro/news/codex-mcp-lazy-startup-diagnose-slow-first-calls-and-missing-tools", "canonical_source": "https://pub.towardsai.net/codex-mcp-lazy-startup-diagnose-slow-first-calls-and-missing-tools-5189122a6f03?source=rss----98111c9905da---4", "published_at": "2026-11-25 15:31:02+00:00", "updated_at": "2026-11-25 15:42:37.106223+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "agent-protocols", "ai-tools"], "entities": ["Codex CLI", "Model Context Protocol", "OpenAI", "codex mcp list", "GitHub"], "also_reported_by": [], "takeaway": "Codex CLI 0.172.0's lazy startup defers optional stdio MCP servers with cached tool lists until the first call, so diagnose a stalled first call by classifying the server as cold catalog, warm catalog with cold process, or warm process before changing timeouts.", "recommendation": {"advice": "Check codex mcp list and /mcp for server config and tool filters first, then classify each MCP server as cold catalog, warm catalog with cold process, or warm process before raising timeouts.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/codex-mcp-lazy-startup-diagnose-slow-first-calls-and-missing-tools", "markdown": "https://wpnews.pro/news/codex-mcp-lazy-startup-diagnose-slow-first-calls-and-missing-tools.md", "text": "https://wpnews.pro/news/codex-mcp-lazy-startup-diagnose-slow-first-calls-and-missing-tools.txt", "jsonld": "https://wpnews.pro/news/codex-mcp-lazy-startup-diagnose-slow-first-calls-and-missing-tools.jsonld"}}