Optionalcapabilities?: ClientCapabilitiesOptionaljsonSchemaValidator?: jsonSchemaValidatorJSON Schema validator for tool output validation.
The validator is used to validate structured content returned by tools against their declared output schemas.
// ajv
const client = new Client(
{ name: 'my-client', version: '1.0.0' },
{
capabilities: {},
jsonSchemaValidator: new AjvJsonSchemaValidator()
}
);
// @cfworker/json-schema
const client = new Client(
{ name: 'my-client', version: '1.0.0' },
{
capabilities: {},
jsonSchemaValidator: new CfWorkerJsonSchemaValidator()
}
);
OptionallistChanged?: ListChangedHandlersConfigure handlers for list changed notifications (tools, prompts, resources).
const client = new Client(
{ name: 'my-client', version: '1.0.0' },
{
listChanged: {
tools: {
onChanged: (error, tools) => {
if (error) {
console.error('Failed to refresh tools:', error);
return;
}
console.log('Tools updated:', tools);
}
},
prompts: {
onChanged: (error, prompts) => console.log('Prompts updated:', prompts)
}
}
}
);
Capabilities to advertise as being supported by this client.