MCPcopy Create free account
hub / github.com/coder/aibridge / validateToolOrder

Function validateToolOrder

mcp/mcp_test.go:338–353  ·  view source on GitHub ↗
(t *testing.T, proxy mcp.ServerProxier)

Source from the content-addressed store, hash-verified

336}
337
338func validateToolOrder(t *testing.T, proxy mcp.ServerProxier) {
339 t.Helper()
340
341 tools := proxy.ListTools()
342 require.NotEmpty(t, tools)
343 require.Greater(t, len(tools), 1)
344
345 // Ensure tools are sorted by ID; unstable order can bust the cache and lead to increased costs.
346 sorted := slices.Clone(tools)
347 slices.SortFunc(sorted, func(a, b *mcp.Tool) int {
348 return strings.Compare(a.ID, b.ID)
349 })
350 for i, tool := range tools {
351 require.Equal(t, tool.ID, sorted[i].ID, "tool order is not stable")
352 }
353}
354
355func createMockMCPSrv(t *testing.T) http.Handler {
356 t.Helper()

Callers 1

TestToolInjectionOrderFunction · 0.85

Calls 1

ListToolsMethod · 0.65

Tested by

no test coverage detected