Skip to content

Commit 3671334

Browse files
committed
clean up and write notes for now
1 parent f3d12d6 commit 3671334

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

src/client/index.ts

+29-24
Original file line numberDiff line numberDiff line change
@@ -240,30 +240,6 @@ export class Client<
240240
this._toolRefreshOptions.onError = handler;
241241
}
242242

243-
/**
244-
* Manually triggers a refresh of the tools list
245-
*/
246-
public async refreshToolsList(): Promise<
247-
ListToolsResult["tools"] | undefined
248-
> {
249-
if (!this._serverCapabilities?.tools) {
250-
return undefined;
251-
}
252-
253-
try {
254-
const result = await this.listTools();
255-
return result.tools;
256-
} catch (error) {
257-
// Use error callback if provided, otherwise log to console
258-
if (this._toolRefreshOptions.onError) {
259-
this._toolRefreshOptions.onError(error instanceof Error ? error : new Error(String(error)));
260-
} else {
261-
console.error("Failed to manually refresh tools list:", error);
262-
}
263-
return undefined;
264-
}
265-
}
266-
267243
protected assertCapability(
268244
capability: keyof ServerCapabilities,
269245
method: string,
@@ -576,6 +552,35 @@ export class Client<
576552
);
577553
}
578554

555+
/**
556+
* Retrieves the list of available tools from the server.
557+
*
558+
* This method is called automatically when a tools list changed notification
559+
* is received (if auto-refresh is enabled and after debouncing).
560+
*
561+
* To manually refresh the tools list:
562+
* ```typescript
563+
* try {
564+
* const result = await client.listTools();
565+
* // Use result.tools
566+
* } catch (error) {
567+
* // Handle error
568+
* }
569+
* ```
570+
*
571+
* Alternatively, register an error handler:
572+
* ```typescript
573+
* client.setToolRefreshErrorHandler((error) => {
574+
* // Handle error
575+
* });
576+
*
577+
* const result = await client.listTools();
578+
* ```
579+
*
580+
* @param params Optional parameters for the list tools request
581+
* @param options Optional request options
582+
* @returns The list tools result containing available tools
583+
*/
579584
async listTools(
580585
params?: ListToolsRequest["params"],
581586
options?: RequestOptions,

0 commit comments

Comments
 (0)