You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 15, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on May 15, 2026. It is now read-only.
Optimizer initialization takes long time causing warning and error messages in thv proxy logs #48
After a MCP server is launched, thv attempts to connect to the server. Since optimizer takes a long time to initialize before the server process is launched, thv proxy reports errors and warning messages like below.
10:58AM INFO MCP server not initialized yet, skipping health check for http://127.0.0.1:22262
10:58AM INFO MCP server not initialized yet, skipping health check for http://127.0.0.1:22262
10:58AM INFO MCP server not initialized yet, skipping health check for http://127.0.0.1:22262
To address this issue, we need to launch the server process early and move the server initialization steps out of that execution path.
I was looking at this PR, and I'm not convinced the original behaviour is wrong. There is no other mechanism to tell the client that the server isn't ready. We want to check frequently to be responsive, but perhaps not log it until it has failed N times.
The real problem is that we never seem to connect. Why is this?
The Answer
The health endpoint is different because:
It uses a separate HTTP client that goes directly to the target server
It bypasses the proxy's tracingTransport.RoundTrip() method entirely
Therefore, it never triggers the initialization detection logic
The health check succeeds (server is up), but IsServerInitialized stays false
The monitoring loop continues logging "MCP server not initialized yet" every 10 seconds
Only when a real MCP client connects and sends requests through the proxy (especially an initialize request) does the IsServerInitialized flag get set to true, stopping the log messages.
Potential Solution
You could make the health check also set the initialization flag when it succeeds, or have it go through the proxy's transport layer. This would stop the messages as soon as mcp-optimizer's server is responding, rather than waiting for the first client connection.
Activity
therealnb commentedon Nov 6, 2025
I was looking at this PR, and I'm not convinced the original behaviour is wrong. There is no other mechanism to tell the client that the server isn't ready. We want to check frequently to be responsive, but perhaps not log it until it has failed N times.
The real problem is that we never seem to connect. Why is this?
therealnb commentedon Nov 6, 2025
The Answer
The health endpoint is different because:
Only when a real MCP client connects and sends requests through the proxy (especially an initialize request) does the IsServerInitialized flag get set to true, stopping the log messages.
Potential Solution
You could make the health check also set the initialization flag when it succeeds, or have it go through the proxy's transport layer. This would stop the messages as soon as mcp-optimizer's server is responding, rather than waiting for the first client connection.
Maybe?