Tools
The model decidesActions with side effects. The model reads the description and picks the tool.
Chapter 03server.registerTool(
'delete_note',
{
title: 'Delete a note',
description: 'Delete one note by id. This cannot be undone.',
inputSchema: deleteNoteInput,
annotations: { destructiveHint: true, idempotentHint: true, openWorldHint: false },
},
({ id }) =>
safely('delete_note', async () => {
if (!(await store.delete(id))) return failure(`No note with id ${id}.`)
log('info', 'note_deleted', { id })
return { content: [{ type: 'text', text: `Deleted note ${id}.` }] }
}),
)