Skip to content

mcp-optimizer cannot discover remote workloads (thv serve API doesn't return them) #3247

@gkatz2

Description

@gkatz2

Problem

The ToolHive API (/api/v1beta/workloads) does not return running remote workloads that are visible via thv list. This causes mcp-optimizer to not discover those servers.

Without a fix, mcp-optimizer is much less useful for reducing context window bloat because remote servers must be registered separately with MCP clients, bypassing mcp-optimizer entirely.

Environment

  • ToolHive: v0.6.17
  • Platform: macOS (darwin/arm64)

Steps to Reproduce

  1. Start the API server:

    thv serve --port 50000
  2. Run a container-based workload:

    thv run time
  3. Run a remote workload:

    thv run --name cloudflare_docs https://docs.mcp.cloudflare.com/sse
  4. Verify both appear in CLI:

    thv list
    # Shows both time (container) and cloudflare_docs (remote)
  5. Query the API:

    curl http://127.0.0.1:50000/api/v1beta/workloads
  6. Observe that the remote workload is missing from the API response

Expected Behavior

API returns both workloads:

{
  "workloads": [
    {"name": "time", "remote": null, ...},
    {"name": "cloudflare_docs", "remote": true, ...}
  ]
}

Actual Behavior

API returns only the container workload:

{
  "workloads": [
    {"name": "time", "remote": null, ...}
  ]
}

Individual query also fails:

curl http://127.0.0.1:50000/api/v1beta/workloads/cloudflare_docs
# Returns: "Workload configuration not found"

Notes

  • thv list correctly shows both workloads
  • The discrepancy is between the CLI and the thv serve API
  • This may indicate an issue with how remote workload state is stored/retrieved by the API server

Impact

mcp-optimizer cannot discover running remote workloads, making those tools unavailable to MCP clients.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiItems related to the APIbugSomething isn't workingcliChanges that impact CLI functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions