fix(server,client): non-SEP draft spec conformance (eager list handlers, pagination docs, path-sanitization note) (#2269)
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
This commit is contained in:
parent
49c0a711c8
commit
e84c3e9ad0
2 changed files with 201 additions and 6 deletions
|
|
@ -143,11 +143,12 @@ async function Client_listTools_pagination(client: Client) {
|
|||
//#region Client_listTools_pagination
|
||||
const allTools: Tool[] = [];
|
||||
let cursor: string | undefined;
|
||||
// Note: an empty-string cursor is valid and does not signal the end of results.
|
||||
do {
|
||||
const { tools, nextCursor } = await client.listTools({ cursor });
|
||||
allTools.push(...tools);
|
||||
cursor = nextCursor;
|
||||
} while (cursor);
|
||||
} while (cursor !== undefined);
|
||||
console.log(
|
||||
'Available tools:',
|
||||
allTools.map(t => t.name)
|
||||
|
|
@ -162,11 +163,12 @@ async function Client_listPrompts_pagination(client: Client) {
|
|||
//#region Client_listPrompts_pagination
|
||||
const allPrompts: Prompt[] = [];
|
||||
let cursor: string | undefined;
|
||||
// Note: an empty-string cursor is valid and does not signal the end of results.
|
||||
do {
|
||||
const { prompts, nextCursor } = await client.listPrompts({ cursor });
|
||||
allPrompts.push(...prompts);
|
||||
cursor = nextCursor;
|
||||
} while (cursor);
|
||||
} while (cursor !== undefined);
|
||||
console.log(
|
||||
'Available prompts:',
|
||||
allPrompts.map(p => p.name)
|
||||
|
|
@ -181,11 +183,12 @@ async function Client_listResources_pagination(client: Client) {
|
|||
//#region Client_listResources_pagination
|
||||
const allResources: Resource[] = [];
|
||||
let cursor: string | undefined;
|
||||
// Note: an empty-string cursor is valid and does not signal the end of results.
|
||||
do {
|
||||
const { resources, nextCursor } = await client.listResources({ cursor });
|
||||
allResources.push(...resources);
|
||||
cursor = nextCursor;
|
||||
} while (cursor);
|
||||
} while (cursor !== undefined);
|
||||
console.log(
|
||||
'Available resources:',
|
||||
allResources.map(r => r.name)
|
||||
|
|
|
|||
|
|
@ -677,11 +677,12 @@ export class Client extends Protocol<ClientContext> {
|
|||
* ```ts source="./client.examples.ts#Client_listPrompts_pagination"
|
||||
* const allPrompts: Prompt[] = [];
|
||||
* let cursor: string | undefined;
|
||||
* // Note: an empty-string cursor is valid and does not signal the end of results.
|
||||
* do {
|
||||
* const { prompts, nextCursor } = await client.listPrompts({ cursor });
|
||||
* allPrompts.push(...prompts);
|
||||
* cursor = nextCursor;
|
||||
* } while (cursor);
|
||||
* } while (cursor !== undefined);
|
||||
* console.log(
|
||||
* 'Available prompts:',
|
||||
* allPrompts.map(p => p.name)
|
||||
|
|
@ -707,11 +708,12 @@ export class Client extends Protocol<ClientContext> {
|
|||
* ```ts source="./client.examples.ts#Client_listResources_pagination"
|
||||
* const allResources: Resource[] = [];
|
||||
* let cursor: string | undefined;
|
||||
* // Note: an empty-string cursor is valid and does not signal the end of results.
|
||||
* do {
|
||||
* const { resources, nextCursor } = await client.listResources({ cursor });
|
||||
* allResources.push(...resources);
|
||||
* cursor = nextCursor;
|
||||
* } while (cursor);
|
||||
* } while (cursor !== undefined);
|
||||
* console.log(
|
||||
* 'Available resources:',
|
||||
* allResources.map(r => r.name)
|
||||
|
|
@ -870,11 +872,12 @@ export class Client extends Protocol<ClientContext> {
|
|||
* ```ts source="./client.examples.ts#Client_listTools_pagination"
|
||||
* const allTools: Tool[] = [];
|
||||
* let cursor: string | undefined;
|
||||
* // Note: an empty-string cursor is valid and does not signal the end of results.
|
||||
* do {
|
||||
* const { tools, nextCursor } = await client.listTools({ cursor });
|
||||
* allTools.push(...tools);
|
||||
* cursor = nextCursor;
|
||||
* } while (cursor);
|
||||
* } while (cursor !== undefined);
|
||||
* console.log(
|
||||
* 'Available tools:',
|
||||
* allTools.map(t => t.name)
|
||||
|
|
|
|||
Loading…
Reference in a new issue