Skip to content

The agent that grows with you

fix: bootstrap the hermes-tools MCP server only when it runs as python -m

teknium118084881d559
diff --git a/agent/transports/hermes_tools_mcp_server.py b/agent/transports/hermes_tools_mcp_server.py
index 64a6118957d..d5287786963 100644
--- a/agent/transports/hermes_tools_mcp_server.py
+++ b/agent/transports/hermes_tools_mcp_server.py
@@ -8,10 +8,13 @@ exposed over stdio MCP; codex registers it via ``~/.codex/config.toml
from __future__ import annotations
# First, like every entry point: stdio, import-path and environ-lifetime fixes (hermes_bootstrap).
-try:
- import hermes_bootstrap # noqa: F401
-except ModuleNotFoundError:
- pass # a partial ``hermes update`` can leave the bootstrap unregistered
+# Only as ``python -m``: codex_runtime & co. import this module for a constant, and the
+# bootstrap's scratch/TMPDIR exports must not fire in those library importers.
+if __name__ == "__main__":
+ try:
+ import hermes_bootstrap # noqa: F401
+ except ModuleNotFoundError:
+ pass # a partial ``hermes update`` can leave the bootstrap unregistered
import inspect
import json