sunpeak API
Overview
Returns a function to notify the host that the app’s available tools have changed. Call this after registering, removing, enabling, or disabling tools via useRegisterTool.
Import
import { useSendToolListChanged } from 'sunpeak';
Signature
function useSendToolListChanged(): () => Promise<void>
Returns
Function that sends a tools/list_changed notification to the host.
Usage
import { useRegisterTool, useSendToolListChanged } from 'sunpeak';
function DynamicTools() {
const registerTool = useRegisterTool();
const sendToolListChanged = useSendToolListChanged();
const addTool = () => {
registerTool("ping", { description: "Ping" }, () => ({
content: [{ type: "text", text: "pong" }],
}));
sendToolListChanged();
};
return <button onClick={addTool}>Add Tool</button>;
}