@@ -233,6 +233,18 @@ Returns tool schemas for a specific server.
233233// Get tools for a specific server
234234const timeTools = await client .servers .time .getTools ();
235235// Returns: [{ name: 'get_current_time', description: '...', inputSchema: {...} }]
236+
237+ // Iterate over tools
238+ for (const tool of timeTools ) {
239+ console .log (` ${tool .name }: ${tool .description } ` );
240+ }
241+
242+ // Works with dynamic server names
243+ const servers = await client .listServers ();
244+ for (const serverName of servers ) {
245+ const tools = await client .servers [serverName ].getTools ();
246+ console .log (` ${serverName }: ${tools .length } tools ` );
247+ }
236248```
237249
238250#### ` client.servers.<server>.tools.<tool>(args) `
@@ -250,25 +262,6 @@ const result = await client.servers.weather.tools.get_forecast({
250262const time = await client .servers .time .tools .get_current_time ();
251263```
252264
253- #### ` client.servers.<server>.getTools() `
254-
255- Get all tools available on a specific server.
256-
257- ``` typescript
258- // List tools for a server using property access
259- const tools = await client .servers .time .getTools ();
260- for (const tool of tools ) {
261- console .log (` ${tool .name }: ${tool .description } ` );
262- }
263-
264- // Useful in loops with dynamic server names
265- const servers = await client .listServers ();
266- for (const serverName of servers ) {
267- const tools = await client .servers [serverName ].getTools ();
268- console .log (` ${serverName }: ${tools .length } tools ` );
269- }
270- ```
271-
272265#### ` client.servers.<server>.callTool(toolName, args?) `
273266
274267Call a tool by name with the given arguments. This is useful for programmatic tool invocation when the tool name is in a variable.
0 commit comments