in lib/client.js [438:454]
addTool(definition, handler) {
if (!definition?.name) {
throw new Error(`Missing tool name in definition`);
}
const name = definition?.name;
if (this.tools[name]) {
throw new Error(
`Tool "${name}" already added. Please use .removeTool("${name}") before trying to add again.`,
);
}
if (typeof handler !== 'function') {
throw new Error(`Tool "${name}" handler must be a function`);
}
this.tools[name] = { definition, handler };
this.updateSession();
return this.tools[name];
}