expectToolExists function
Fails the current test if the server behind harness does not list a
tool named name.
Implementation
Future<void> expectToolExists(McpServerHarness harness, String name) async {
final result = await harness.listTools();
final names = [
for (final tool in result.tools)
_describe((tool as Map<String, Object?>)['name'], '<unnamed>'),
];
if (!names.contains(name)) {
fail(
'Expected the server to list a tool named "$name". '
'Listed tools: ${names.isEmpty ? '(none)' : names.join(', ')}.',
);
}
}