Overview
onlisttools is a request handler that returns the list of tools your app provides to the host. The host calls this to discover what tools are available, then invokes them through oncalltool.
To use onlisttools, you must declare the tools capability when constructing the App. If you set listChanged: true, the host will re-query this handler whenever you send a tool list changed notification, allowing your app to dynamically add or remove tools at runtime.
Because this is a request handler, the host waits for your response. Return an object with a tools array containing the tool names or definitions your app supports.
Signature
Parameters
Standard MCP list tools request parameters (includes optional
cursor for pagination).Returns
Array of tool definitions. Each tool must have a
name and inputSchema (with type: "object"). Optional fields: description, annotations.Usage
Static tool list
Dynamic tools based on app state
WhenlistChanged: true is set, the host will re-query onlisttools after receiving a list-changed notification. This lets you add or remove tools based on the current state of your app:
Pair with oncalltool
The tools declared here must be handled inoncalltool:
Related
- Event Handlers overview — all notification and request handlers
oncalltool— handle incoming tool callsuseAppTools— sunpeak React convenience hook for app-side tools- App Class constructor — declaring
toolscapability