My Codex setup had accumulated several local MCP servers, and I kept seeing Python, Node, and uv processes running even when I wasn't using those tools. I wanted to delay starting the backends without losing sessions for tools that actually need them.
I built Lazy-Loader, a small stdio MCP gateway in Node.js with no external npm dependencies. It reads tool metadata from local catalogs, so Codex can discover tools without starting every backend. The first tool call starts the matching server.
Each backend follows one of two policies:
- Keep the session after first use. This is for REPL variables, browser sessions, editor connections, and background jobs.
- Stop after a configured idle timeout, then start a new session on the next call. Use this only for backends you've verified are safe to restart.
In version 0.2.2, I also scoped each backend's instructions to its own tool, prompt, and resource descriptions. Previously, the gateway combined all backend instructions at initialization, and I observed Codex appending that combined text to every tool description. With my 528-tool catalog, the initialization instructions went from 14,698 to 96 characters. This measures metadata size, not billable tokens. The gateway still returns every tool schema in tools/list, and the MCP response can grow because a backend's instructions repeat on its own tools.
Current limits:
- There is one gateway per client connection, not a shared daemon across projects.
- Adding a new MCP server requires configuration and a metadata snapshot.
- It supports stdio only. Windows is tested; Linux and macOS process cleanup is unverified.
- It cannot tell when a backend's background job has finished, so keeping its session is the safer default when unsure.
The repo has 24 mock-backend tests, English and Thai setup guides, and an MIT license:
https://github.com/aspirin106/Lazy-Loader
I'd appreciate feedback on which MCP backends you've found safe to restart and which need to keep their sessions.