Skip to content
22 changes: 19 additions & 3 deletions pkgs/mcpx/internal/e2e/toolparity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"strings"
"testing"
"time"
)

// Every tool an MCP client can see should be reachable from a script (#102).
Expand Down Expand Up @@ -68,9 +69,24 @@ func TestEveryToolInToolsListIsReachableFromAScript(t *testing.T) {
// A control for the predicate itself: demo.echo is configured by
// oneServer and is in the client, so a predicate that finds nothing
// fails here rather than blaming the adapter.
if !reachable("demo_echo") {
t.Fatal("the reachability check cannot find demo.echo, which is in the " +
"generated client; the check is wrong and this test proves nothing")
//
// The control only means anything once the client is warm. Since
// #1868 the daemon reads server schemas in the background, and a
// client generated before demo's read lands spells the namespace as
// a lazy proxy that names no tools -- reachable at call time, but
// not named, which is what this test compares. Parity is a claim
// about the generated client with the schemas in, so poll for the
// control tool to be named before comparing anything.
deadline := time.Now().Add(60 * time.Second)
for !reachable("demo_echo") {
if time.Now().After(deadline) {
t.Fatal("the generated client never named demo.echo, even after " +
"waiting for the daemon to read demo's schemas; the " +
"reachability check has nothing to compare and this test " +
"proves nothing")
}
time.Sleep(time.Second)
client = e.run("client")
}

var missing []string
Expand Down