Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.
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

Closed

Description

@ptelang

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.

Activity

  1. self-assigned this
    on Nov 6, 2025
  2. therealnb commented on Nov 6, 2025

    @therealnb
    Contributor

    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?

  3. therealnb commented on Nov 6, 2025

    @therealnb
    Contributor

    The Answer
    The health endpoint is different because:

    1. It uses a separate HTTP client that goes directly to the target server
    2. It bypasses the proxy's tracingTransport.RoundTrip() method entirely
    3. Therefore, it never triggers the initialization detection logic
    4. The health check succeeds (server is up), but IsServerInitialized stays false
    5. 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.

    Maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions