Test Lazy MCP Startup and Idle Recycling in Hermes Agent
Use lazy startup when a frequently configured but rarely used local MCP service adds startup work. Test warm-cache behavior and subprocess recycling separately. Lazy startup needs a previously discovered schema, while idle recycling governs what happens after a subprocess has already handled a call.
- Warm schema cache
- First tool call
- Idle recycle
Prepare a safe lifecycle fixture
Use an existing test-only stdio MCP server that exposes one harmless inventory lookup. Configure it in a disposable Hermes profile with an absolute command or script path. Give the subprocess no production credentials. Run one normal Hermes startup and invoke the tool to confirm live discovery and populate the documented schema cache. Record the process ID or a server-side startup marker written to stderr. Standard output belongs to the protocol.
Then merge the lifecycle settings under the server's existing mapping:
lazy: true
idle_timeout_seconds: 30
Use a fresh process for each measurement. Check whether the server process exists before the first invocation. Invoke the tool, confirm its result, and record when the subprocess starts. Let the server remain unused longer than the configured idle interval, then invoke it again and verify that it answers under a restarted process. Timing depends on scheduler and runtime behavior. Record observations instead of asserting an exact startup or recycle timestamp.
Test stale and missing discovery
In your test copy, change the tool schema or add a new operation. A cached discovery result may no longer match what the current server exposes. Reconnect and verify discovery before relying on the change. Use the installed version's documented reload path or restart with lazy disabled for a fresh live discovery. Avoid deleting an entire profile to refresh one server.
Decide whether to use it
Lazy startup can defer work from process startup to the first user action. An aggressive idle timeout can cause needless restarts and can reset state held only inside the subprocess. Use it for tools that can restart safely. Choose an inactivity window using workload observations, and avoid using PID alone as an identity over long periods.
Why does the tool appear before the server starts? Hermes can register the cached tool schema first and connect when called.
Where should lifecycle logs go? Write diagnostics to stderr or an approved log sink so JSON-RPC on stdout stays intact.
References
Official Hermes Agent documentation · ASP.NET PB on MCP tools and resources
Comments
Post a Comment