MCP handshake fails with mcp-nixos although the server starts correctly
Open 💬 0 comments Opened Jul 5, 2026 by acloudygirl
What version of Codex CLI is running?
0.139.0
What subscription do you have?
API
Which model were you using?
gpt-5.5
What platform is your computer?
Linux 6.18.35 x86_64 unknown
What terminal emulator and version are you using (if applicable)?
xterm-kitty
Codex doctor report
{
"schemaVersion": 1,
"generatedAt": "1783229375s since unix epoch",
"overallStatus": "fail",
"codexVersion": "0.139.0",
"checks": {
"config.load": {
"id": "config.load",
"category": "config",
"status": "fail",
"summary": "config could not be loaded",
"details": {},
"notes": [
"failed to load Codex config"
],
"remediation": "Fix the reported config error, then rerun codex doctor.",
"durationMs": 0
},
"git.environment": {
"id": "git.environment",
"category": "git",
"status": "ok",
"summary": "git version 2.54.0",
"details": {
".git entry": "directory",
"PATH git #1": "/run/current-system/sw/bin/git",
"PATH git entries": "1",
"git branch": "main",
"git build options": "git version 2.54.0; cpu: x86_64; no commit associated with this build; sizeof-long: 8; sizeof-size_t: 8; shell-path: /nix/store/gik3rh1vz2jlgnifb9dh6vc6sxwwz9jj-bash-5.3p9/bin/bash; rust: enabled; gettext: enabled; libcurl: 8.20.0; OpenSSL: OpenSSL 3.6.2 7 Apr 2026; zlib-ng: 2.3.3; SHA-1: SHA1_DC; SHA-256: SHA256_BLK; default-ref-format: files; default-hash: sha1",
"git exec path": "/nix/store/bcnisk3ydfgv26v2gw3zlky24g00yww2-git-2.54.0/libexec/git-core",
"git version": "git version 2.54.0",
"repo detected": "true",
"repo root": "/home/cloudygirl/mcp-nixos",
"selected git": "/run/current-system/sw/bin/git"
},
"remediation": null,
"durationMs": 46
},
"installation": {
"id": "installation",
"category": "install",
"status": "ok",
"summary": "installation looks consistent",
"details": {
"PATH codex #1": "/run/current-system/sw/bin/codex",
"current executable": "/nix/store/9li75nh4fyk2m574lmim7wnjqm49hl39-codex-0.139.0/bin/.codex-wrapped",
"install context": "other",
"managed by bun": "false",
"managed by npm": "false",
"managed package root": "not set"
},
"remediation": null,
"durationMs": 1
},
"network.env": {
"id": "network.env",
"category": "network",
"status": "ok",
"summary": "network-related environment looks readable",
"details": {
"proxy env vars": "none"
},
"remediation": null,
"durationMs": 0
},
"network.provider_reachability": {
"id": "network.provider_reachability",
"category": "reachability",
"status": "fail",
"summary": "one or more required provider endpoints are unreachable over HTTP",
"details": {
"ChatGPT base URL": "https://chatgpt.com/backend-api/ request timed out (required)",
"reachability mode": "ChatGPT auth"
},
"remediation": "Check proxy, VPN, firewall, DNS, and custom CA configuration.",
"durationMs": 3046
},
"runtime.provenance": {
"id": "runtime.provenance",
"category": "runtime",
"status": "ok",
"summary": "running local build on linux-x86_64",
"details": {
"commit": "unknown",
"current executable": "/nix/store/9li75nh4fyk2m574lmim7wnjqm49hl39-codex-0.139.0/bin/.codex-wrapped",
"install method": "other",
"platform": "linux-x86_64",
"version": "0.139.0"
},
"remediation": null,
"durationMs": 0
},
"runtime.search": {
"id": "runtime.search",
"category": "search",
"status": "ok",
"summary": "search is OK (system)",
"details": {
"search command": "rg",
"search command readiness": "ripgrep 15.1.0",
"search provider": "system"
},
"remediation": null,
"durationMs": 3
},
"state.paths": {
"id": "state.paths",
"category": "state",
"status": "ok",
"summary": "CODEX_HOME was resolved without config",
"details": {
"CODEX_HOME": "/home/cloudygirl/.codex"
},
"remediation": null,
"durationMs": 0
},
"system.environment": {
"id": "system.environment",
"category": "system",
"status": "ok",
"summary": "OS language zh-CN",
"details": {
"EDITOR": "set",
"LANG": "zh_CN.UTF-8",
"PAGER": "set",
"VISUAL": "not set",
"os": "NixOS 26.11.0 [64-bit]",
"os language": "zh-CN",
"os type": "NixOS",
"os version": "26.11.0"
},
"remediation": null,
"durationMs": 1
},
"terminal.env": {
"id": "terminal.env",
"category": "terminal",
"status": "fail",
"summary": "TERMINFO unreadable - terminal capabilities are unknown",
"details": {
"COLORTERM": "truecolor",
"DISPLAY": "present",
"TERMINFO": "/nix/store/ibyqlgsq8if9b3ldd213c6p4mamlbp5x-kitty-0.47.4/lib/kitty/terminfo (dir)",
"TERMINFO_DIRS entry": [
"/home/cloudygirl/.local/share/flatpak/exports/share/terminfo (missing)",
"/var/lib/flatpak/exports/share/terminfo (missing)",
"/home/cloudygirl/.nix-profile/share/terminfo (missing)",
"/nix/profile/share/terminfo (missing)",
"/home/cloudygirl/.local/state/nix/profile/share/terminfo (missing)",
"/etc/profiles/per-user/cloudygirl/share/terminfo (dir)",
"/nix/var/nix/profiles/default/share/terminfo (missing)",
"/run/current-system/sw/share/terminfo (dir)"
],
"WAYLAND_DISPLAY": "present",
"color output": "enabled",
"effective locale": "zh_CN.UTF-8",
"stderr is terminal": "true",
"stdin is terminal": "true",
"stdout is terminal": "true",
"terminal": "kitty",
"terminal size": "112x61"
},
"issues": [
{
"severity": "fail",
"cause": "TERMINFO unreadable - terminal capabilities are unknown",
"measured": null,
"expected": "readable terminfo file or directory",
"remedy": "check that $TERMINFO points to a readable directory",
"fields": [
"TERMINFO",
"TERMINFO_DIRS entry"
]
}
],
"remediation": null,
"durationMs": 0
}
}
}
What issue are you seeing?
Summary
Codex CLI fails to initialize the mcp-nixos MCP server, although the server starts correctly when launched manually.
Environment
- OS: NixOS
- Codex CLI: 0.139.0
- MCP Server: mcp-nixos 2.4.3
- FastMCP: 3.2.4
MCP configuration
[mcp_servers.nixos]
command = "nix"
args = ["run", "/home/cloudygirl/mcp-nixos", "--"]
Reproduction
Running the server manually:
nix run /home/cloudygirl/mcp-nixos --
starts successfully:
FastMCP 3.2.4
Server: mcp-nixos 2.4.3
Starting MCP server 'mcp-nixos' with transport 'stdio'
The process remains running and waits for stdio connections.
However, when starting Codex CLI, it reports:
⚠ MCP client for `nixos` failed to start:
MCP startup failed: handshaking with MCP server failed:
connection closed: initialize response
Expected behavior
Codex should successfully initialize the MCP server and load its tools.
Additional information
- The server works correctly when started manually.
- The problem only occurs when Codex launches it.
- I also tested using a local clone instead of
github:utensils/mcp-nixos, and the same error occurs.
What steps can reproduce the bug?
- Clone mcp-nixos.
git clone git@github.com:utensils/mcp-nixos.git
cd mcp-nixos
- Verify the MCP server starts correctly.
nix run .
The server starts successfully and waits for stdio connections:
FastMCP 3.2.4
Server: mcp-nixos 2.4.3
Starting MCP server 'mcp-nixos' with transport 'stdio'
- Configure Codex CLI with:
[mcp_servers.nixos]
command = "nix"
args = ["run", "/home/cloudygirl/mcp-nixos", "--"]
- Launch Codex CLI.
- Observe the error:
⚠ MCP client for `nixos` failed to start:
MCP startup failed:
handshaking with MCP server failed:
connection closed: initialize response
What is the expected behavior?
Codex CLI should successfully complete the MCP initialize handshake, keep the connection open, and load the tools exposed by the mcp-nixos server.
The same server works correctly when started manually using:
nix run /home/cloudygirl/mcp-nixos --
### Additional information
---
## Additional information
```markdown
Environment:
- OS: NixOS
- Codex CLI: 0.139.0
- MCP Server: mcp-nixos 2.4.3
- FastMCP: 3.2.4
Additional notes:
- The issue persists when using a local clone instead of `github:utensils/mcp-nixos`.
- The server starts correctly outside of Codex.
- GitHub connectivity is no longer involved because the server is launched from a local flake.
- The problem appears during the MCP initialize handshake only.
-
$ codex --version
codex-cli 0.139.0
$ codex mcp list
Name Command
nixos nix run /home/cloudygirl/mcp-nixos --