Part 1 attached. Now it asks.
Two lines
final tools = await client.listTools();
stdout.writeln('tools: ${tools.map((t) => t.name).join(", ")}');
for (final t in tools) {
stdout.writeln(' ${t.name} — ${t.description}');
}
final resources = await client.listResources();
stdout.writeln('resources: ${resources.map((r) => r.uri).join(", ")}');
tools: desk.admit
desk.admit — Admit a number of people from the queue
resources: ui://desk, desk://waiting
Write it down and it belongs to one server
You could write this instead.
// this server has desk.admit
await client.callTool('desk.admit', {'count': 1});
It runs. And at that moment this client belongs to that server. One tool name in the code and it cannot stand in front of anything else.
Asking is different. The list arrives at runtime, so the client does not need to know what it attached to. Attach to a board and led.set comes back; attach to the desk and desk.admit does. Same code.
This is where the description gets used
listTools() does not return names alone. The description and input schema come with them.
desk.admit — Admit a number of people from the queue
A human-facing client builds a button label and a tooltip from it. A model reads it to decide what to call. What server part 2 called "not a comment but running code" is consumed here.
This content requires Developer or above
Sign in and upgrade your plan to continue reading.
View Plans